Search Issue Tracker
UWP player fails to play WebCamTexture when using specific webcam
Steps to reproduce:
1. Download attached project
2. Build project for UWP with IL2CPP or .NET backend
3. Launch UWP player
Actual results: UWP player fails to play WebCamTexture
Exception thrown at 0x00007FFB828FA388 in WebcamText.exe: Microsoft C++ exception: detail::system_hresult_exception at memory location 0x0000000E0C3FE0A8.
Error: Operation has failed with error 0x80028019: Old format or invalid type library.
(C:/buildslave/unity/build/PlatformDependent/MetroPlayer/MetroWebCamTexture.cpp:WebCamTexture::Play at 452)
Reproduced with: 2019.2.0a6, 2019.1.0b3, 2018.3.6f1, 2017.4.20f1
- Issue reproducible with Logitech HD Webcam C270, Logitech HD Webcam 525 and QuickCam Orbit/Sphere AF.
- Not reproducible with Logitech HD Webcam 615 and Surface Pro 4 build in camera
- Reproducible with x64 and x86 architecture
- Reproducible with .NET 3.5 and .NET 4.x runtime
- Not reproducible on Standalone player (mono and IL2CPP)
I don't have one of the specific webcams available and so wasn't able to repro the issue. However, by reviewing the code I believe I found the error case this scenario is hitting. The UWP player does not support video streams that utilize "temporal compression", such as MPEG. Only video streams that contain the MediaFoundation attribute MF_MT_ALL_SAMPLES_INDEPENDENT will be opened for WebCamTexture, which includes YUY2, NV12, and MJPEG formats. My guess for this case is: the script is initializing WebCamTexture with the first available webcam, which happens to default to an unsupported video stream for these specific cameras, whereas most other cameras default to a supported stream. Instead, the script should initialize WebCamTexture with a specific video device name. Unfortunately, the Unity scripting API doesn't expose this level of detail for the video devices WebCamTexture returns, and instead the Windows.Media.Capture.MediaCapture API needs to be directly invoked to enumerate devices and find a compatible one (https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/camera-profiles).
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- [iOS][Editor]Legacy Launch Images iPhone 6.5 Landscape resolution mislabelled in Player Settings/Splash Image
- Memory leaks and Editor crashes/freezes when using decimal values in Gizmos
- Crash on PhysicsScene::ProcessTriggerEnterExits when splitting meshes that also exit a Trigger with OnTriggerExit
- "The page you were looking for doesn't exist" message appears when trying to Sign in using Unity Hub/Editor
- [Regression] Enviroment lighting is broken in the 2017.4.27f1 version