microsoft / MixedReality-WebRTC

MixedReality-WebRTC is a collection of components to help mixed reality app developers integrate audio and video real-time communication into their application and improve their collaborative experience
https://microsoft.github.io/MixedReality-WebRTC/
MIT License
913 stars 283 forks source link

Camera access request throws unhandled exception if access has already been granted. #763

Open zxubian opened 3 years ago

zxubian commented 3 years ago

To Reproduce Steps to reproduce the behavior:

  1. Request camera access in some place other than the WebRTC components (PeerConnection/WebCamSource) (e.g. via the Unity WebCamTexture class)
  2. User grants access
  3. Instantiate Unity GameObject with Peer Connection & WebCamSource components; initialize

Expected behavior PeerConnection, WebCamSource initialize properly.

Actual behaviour

Similar to this comment in a closed issue: https://github.com/microsoft/MixedReality-WebRTC/issues/159#issuecomment-588180374

The following error gets thrown:

Cross thread invocation callback threw an exception. Exception: An unexpected error has occurred in the operation requested.
An unexpected error has occurred in the operation requested.
  at Windows.Media.Capture.MediaCapture.InitializeAsync 

Issue gets fixed when RequestAccessAsync code path is disabled in PeerConnection and WebCamSource.

Environment

Additional context Similar issue with combining WebRTC and Spectator View: https://github.com/microsoft/MixedReality-SpectatorView/issues/322