This repository was archived by the owner on Jun 14, 2024. It is now read-only.
This repository was archived by the owner on Jun 14, 2024. It is now read-only.
Initializing MediaCapture fails when WebRTC has been used before #322
Open
Description
I try to use SpectatorView together with WebRTC. Together as in "as part of the same Unity app", not at the same time. It seems that when one service has initialized the MediaCapture, the other one cannot do it afterwards unless I restart the app. So even after ArUcoMarkerDetector
has been released and HoloLensCamera
has been disposed, WebRTC fails to get a hold of the capture. Similar issue when I first start WebRTC, destroy the GameObject and then try to ArUcoMarkerDetector
. Both services work fine in conjunction with Vuforia. I can switch back and forth without any issues.
System
- Unity: 2019.2.19f1
- WebRTC: microsoft/MixedReality-WebRTC@73b69d7
- SpectatorView: 8f7d76c
- HoloLens: 17763.973.x86fre.rs5_release_svc_prod1.200103-1310
Scenario 1: Spectator View first, WebRTC second
Initializing HoloLensCamera
StateSynchronizationBroadcaster: Broadcaster received connection from xxx.xxx.xxx.xxx.
SpatialCoordinateSystemManager: Creating new SpatialCoordinateSystemParticipant, IPAddress: xxx.xxx.xxx.xxx, DebugLogging: True
SpatialCoordinateSystemManager: Invoking ParticipantConnected event
SpatialCoordinateWorldOriginTransformer: Participant connected: xxx.xxx.xxx.xxx
SpatialCoordinateSystemManager: LocalizeMessageReceived
CameraStateManager: Entering State 'SpectatorView'
MarkerVisualDetectorSpatialLocalizer.LocalizationSession: Waiting for marker visual, CanBeCanceled:True, IsCancellationRequested:False
SpatialCoordinateSystemManager: Data received for participant: xxx.xxx.xxx.xxx, LocalizationDataExchange
MarkerVisualDetectorSpatialLocalizer.LocalizationSession: Received command: MVISUALDISC
MarkerVisualDetectorSpatialLocalizer.LocalizationSession: GetMarkerId currently returns 1 when possible to avoid conficts with the MarkerDetectorSpatialLocalizer that uses 0. Additional work is still required to enable assigning unique marker ids to different application participants.
MarkerVisualDetectorSpatialLocalizer.LocalizationSession: Sending coordinate assignment: 1
MarkerVisualDetectorSpatialLocalizer.LocalizationSession: Attempting to discover coordinate: 1, CanBeCanceled:True, IsCancellationRequested:False
MarkerDetector: Starting detection
ArUcoMarkerDetector: Starting ArUco marker detection
ArUcoMarkerDetector: Setting up HoloLensCamera
MarkerDetector: Marker with id: 1 wasn't found yet.
MarkerDetector: Waiting another second
ArUcoMarkerDetector: HoloLensCamera initialized
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: WinRT originate error - 0xC00DABE0 : 'No capture devices are available.'.
ArUcoMarkerDetector: HoloLensCamera successfully started
ArUcoMarkerDetector: Image obtained from HoloLens
Releasing HoloLensCamera
MarkerDetector: Markers Updated
MarkerDetector: Processed all markers
MarkerDetector: Marker 1 not seen this time.
MarkerDetector: Found all markers
ArUcoMarkerDetector: Stopping ArUco marker detection
ArUcoMarkerDetector: Cleaning up HoloLensCamera
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: WinRT originate error - 0x80000013 : 'The object has been closed.'.
Exception thrown at 0x76EA3072 in Avikom.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x019FF2A0.
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: WinRT originate error - 0x80000013 : 'System.ObjectDisposedException: The object has been closed.
The object has been closed.
at Windows.Media.Devices.VideoDeviceController.get_IsoSpeedControl () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.PhotoCapture.HoloLensCamera.get_Gain () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.PhotoCapture.HoloLensCamera.GetFrameFromMediaFrameReader (Windows.Media.Capture.Frames.MediaFrameReader frameReader) [0x00000] in <000000000000000'.
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: 0x40080202: WinRT transform error (parameters: 0x80000013, 0x00000000, 0x00000027, 0x019FEF60).
MarkerDetector: Stopped detection
MarkerVisualDetectorSpatialLocalizer.LocalizationSession: Coordinate discovery completed: 1
MarkerVisualDetectorSpatialLocalizer.LocalizationSession: Sending coordinate found: 1
MarkerDetector: Disposed
CameraStateManager: Entering State 'Unallocated'
Initializing MediaCapture
in PeerConnection
CameraStateManager: Entering State 'WebRTC'
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: WinRT originate error - 0xC00D36BB : 'An unexpected error has occurred in the operation requested.'.
Exception thrown at 0x76EA3072 in Avikom.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x01CFED14.
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 (Windows.Media.Capture.MediaCaptureInitializationSettings mediaCaptureInitializationSettings) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.WebRTC.Unity.PeerConnection.RequestAccessAndInitAsync (System.Threading.CancellationToken token) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.WebRTC.Unity.PeerConnection+<>c__DisplayClass16_0.<InitializeAsync>b__0 () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.WSA.AppCallbackItem.Invoke () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
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 (Windows.Media.Capture.MediaCaptureInitializationSettings mediaCaptureInitializationSettings) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.WebRTC.Unity.PeerConnection.RequestAccessAndInitAsync (System.Threading.CancellationToken token) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.WebRTC.Unity.PeerConnection+<>c__DisplayClass16_0.<InitializeAsync>b__0 () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.WSA.AppCallbackItem.Invoke () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
Found video capture device 'MN34150' (id:\\?\DISPLAY#INT22B8#4&27b432bd&0&UID139960#{e5323777-f976-4f5b-9b55-b94699c46e44}\{CDD6871A-56CA-4386-BAE7-D24B564378A9}).
CameraStateManager: Entering State 'Unallocated'
Scenario 2: WebRTC first. SpectatorView second
Initializing MediaCapture
in PeerConnection
CameraStateManager: Entering State 'WebRTC'
Initializing WebRTC plugin...
WebRTC plugin initialized successfully.
Found video capture device 'MN34150' (id:\\?\DISPLAY#INT22B8#4&27b432bd&0&UID139960#{e5323777-f976-4f5b-9b55-b94699c46e44}\{CDD6871A-56CA-4386-BAE7-D24B564378A9}).
VideoEffect Added
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'.
Destroying WebRTC GameObject (or disabling it)
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: WinRT originate error - 0xC00D36B5 : 'The callee is currently not accepting further input.'.
VideoEffect removed
CameraStateManager: Entering State 'Unallocated'
Initializing HoloLensCamera
MarkerDetector: Starting detection
ArUcoMarkerDetector: Starting ArUco marker detection
ArUcoMarkerDetector: Setting up HoloLensCamera
MarkerDetector: Marker with id: 1 wasn't found yet.
MarkerDetector: Waiting another second
ArUcoMarkerDetector: HoloLensCamera initialized
Exception thrown at 0x76EA3072 (KernelBase.dll) in Avikom.exe: 0x8001010E: The application called an interface that was marshalled for a different thread.
Exception thrown at 0x76EA3072 in Avikom.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x026DDD94.
Exception thrown at 0x76EA3072 in Avikom.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x026DEEE0.
Exception: Exception of type 'System.Exception' was thrown.
at Windows.Media.Capture.MediaCapture..ctor () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.PhotoCapture.StreamSelector.set_StreamDescriptions (System.Collections.Generic.List`1[T] value) [0x00000] in <00000000000000000000000000000000>:0
at Vuforia.VuforiaConfiguration+WebCamConfiguration.get_TurnOffWebCam () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.PhotoCapture.HoloLensCamera.Start (Microsoft.MixedReality.PhotoCapture.StreamDescription streamDesc) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.SpectatorView.ArUcoMarkerDetector.CameraInitialized (Microsoft.MixedReality.PhotoCapture.HoloLensCamera sender, System.Boolean initializeSuccessful) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.PhotoCapture.OnCameraInitializedHandler.Invoke (Microsoft.MixedReality.PhotoCapture.HoloLensCamera sender, System.Boolean initializeSuccessful) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.PhotoCapture.StreamSelector.set_StreamDescriptions (System.Collections.Generic.List`1[T] value) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0
at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c.<.cctor>b__7_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.SendOrPostCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.WSA.WindowSizeChanged..ctor (System.Object object, System.IntPtr method) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.SendOrPostCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.WSA.WindowSizeChanged..ctor (System.Object object, System.IntPtr method) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.WSA.WindowSizeChanged:.ctor(Object, IntPtr)
UnityEngine.UnitySynchronizationContext:Exec()
UnityEngine.UnitySynchronizationContext:ExecuteTasks()
(Filename: currently not available on il2cpp Line: -1)
MarkerDetector: Marker with id: 1 wasn't found yet.
MarkerDetector: Waiting another second