WebRTC Native Crash: When Reopening WebRTC Calling Screen to Restart Call Functionality in Single Session

I am currently developing an application using the Magic Leap headset and I've encountered an issue related to disconnecting and then reestablishing WebRTC call sessions.

Unity Editor version: 2022-2.0f1
ML2 OS version: 1.3.0-dev2
MLSDK version: 1.7.0
Host OS: Windows 11

Here's the disconnect function I'm currently using in my code:

 public void Disconnect()
        {
            if (connection == null)
            {
                return;
            }

            webRequestManager.HttpPost(serverURI + "/logout/" + localId, string.Empty);

            if (dataChannel != null)
            {
                dataChannel.OnClosed -= OnDataChannelClosed;
                dataChannel.OnOpened -= OnDataChannelOpened;
                dataChannel.OnMessageText -= OnDataChannelTextMessage;
                dataChannel.OnMessageBinary -= OnDataChannelBinaryMessage;
                dataChannel = null;
            }

            UnsubscribeFromConnection(connection);

            connection.Destroy();
            connection = null;

            localVideoSource.DestroyLocal();

            remoteMediaStream = null;
            waitingForAnswer = false;
            waitingForAnswerGetRequest = false;

            connectButton.gameObject.SetActive(true);
            serverInput.gameObject.SetActive(true);
            localVideoSinkBehavior.gameObject.SetActive(false);
            remoteStatusText.text = "Disconnected";
            //localStatusText.text = "";
            remoteVideoSinkBehavior.VideoSink.SetStream(null);
            remoteAudioSinkBehavior.gameObject.SetActive(false);
            remoteVideoSinkBehavior.gameObject.SetActive(false);
            disconnectUI.SetActive(false);
            messageUI.SetActive(false);
            //dataChannelText.text = "";
            localVideoSourceDropdown.interactable = true;
            localVideoSizeDropdownRGB.interactable = true;
            localVideoSizeDropdownMR.interactable = true;

            remoteId = "";
            localId = "";
        }

I am getting the following crash, when I am trying to reopen webrtc calling screen to restart the calling functionality in single session of the app.

2023/07/21 16:39:15.754 7534 7567 Info Unity ICE Servers: UnityEngine.XR.MagicLeap.MLWebRTC+IceServer[]
2023/07/21 16:39:15.754 7534 7567 Info Unity UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
2023/07/21 16:39:15.754 7534 7567 Info Unity UnityEngine.Logger:Log(LogType, Object)
2023/07/21 16:39:15.754 7534 7567 Info Unity UnityEngine.Debug:Log(Object)
2023/07/21 16:39:15.754 7534 7567 Info Unity MagicLeap.Examples.<WaitForIceServers>d__100:MoveNext() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Assets\ExpertCall\Scripts\WebRTC\MLWebRTCExample.cs:918)
2023/07/21 16:39:15.754 7534 7567 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at \home\bokken\build\output\unity\unity\Runtime\Export\Scripting\Coroutines.cs:17)
2023/07/21 16:39:15.754 7534 7567 Info Unity UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) (at \home\bokken\build\output\unity\unity\Runtime\Export\Scripting\MonoBehaviour.bindings.cs:112)
2023/07/21 16:39:15.754 7534 7567 Info Unity MagicLeap.Examples.MLWebRTCExample:CreateIceServers() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Assets\ExpertCall\Scripts\WebRTC\MLWebRTCExample.cs:954)
2023/07/21 16:39:15.754 7534 7567 Info Unity MagicLeap.Examples.<<Login>b__67_0>d:MoveNext() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Assets\ExpertCall\Scripts\WebRTC\MLWebRTCExample.cs:325)
2023/07/21 16:39:15.754 7534 7567 Info Unity System.Runtime.CompilerServ
2023/07/21 16:39:15.755 7534 7567 Info luminkarrot nova/frameworks/kali/kaliwebrtc/simple/src/Factory.cpp:71 Creating peer connection
2023/07/21 16:39:15.756 7534 9107 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/videofactory/src/KarrotVideoFactory.cpp:197 VideoEncoderFactory:GetSupportedFormats
2023/07/21 16:39:15.760 7534 7567 Info Unity GET YUV FRAME
2023/07/21 16:39:15.760 7534 7567 Info Unity UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
2023/07/21 16:39:15.760 7534 7567 Info Unity UnityEngine.Logger:Log(LogType, Object)
2023/07/21 16:39:15.760 7534 7567 Info Unity UnityEngine.Debug:Log(Object)
2023/07/21 16:39:15.760 7534 7567 Info Unity MagicLeap.Core.MLWebRTCVideoSinkBehavior:RenderWebRTCFrameYUV(Frame) (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\APIs\WebRTC\Scripts\MLWebRTCVideoSinkBehavior.cs:265)
2023/07/21 16:39:15.760 7534 7567 Info Unity MagicLeap.Core.MLWebRTCVideoSinkBehavior:RenderWebRTCFrame(Frame) (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\APIs\WebRTC\Scripts\MLWebRTCVideoSinkBehavior.cs:182)
2023/07/21 16:39:15.760 7534 7567 Info Unity MagicLeap.Core.MLWebRTCVideoSinkBehavior:Update() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\APIs\WebRTC\Scripts\MLWebRTCVideoSinkBehavior.cs:131)
2023/07/21 16:39:15.760 7534 7567 Info Unity 
2023/07/21 16:39:15.760 7534 17835 Info ml_camera_client Camonly OnUnavailable CamId = 0
2023/07/21 16:39:15.760 7534 7534 Warn UnityGfxDeviceW type=1400 audit(0.0:5361): avc: denied { search } for name="traces" dev="nvme0n1p37" ino=7340035 scontext=u:r:untrusted_app:s0:c105,c256,c512,c768 tcontext=u:object_r:trace_data_file:s0 tclass=dir permissive=0
2023/07/21 16:39:15.772 7534 17828 Info Unity StartCapture with stream config: CaptureType : Video, Width : 1920, Height : 1080, OutputFormat : YUV_420_888, MediaRecorder : NULL
2023/07/21 16:39:15.772 7534 17828 Info Unity UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
2023/07/21 16:39:15.772 7534 17828 Info Unity UnityEngine.Logger:Log(LogType, Object)
2023/07/21 16:39:15.772 7534 17828 Info Unity UnityEngine.Debug:Log(Object)
2023/07/21 16:39:15.772 7534 17828 Info Unity UnityEngine.XR.MagicLeap.MLCameraVideoSource:StartCapture() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\APIs\WebRTC\API\MLWebRTCCameraVideoSource.cs:189)
2023/07/21 16:39:15.772 7534 17828 Info Unity UnityEngine.XR.MagicLeap.MLCameraVideoSource:CreateLocal(MLCameraBase, CaptureConfig, MLResult&, String, Renderer, Boolean, Boolean) (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\APIs\WebRTC\API\MLWebRTCCameraVideoSource.cs:112)
2023/07/21 16:39:15.772 7534 17828 Info Unity MagicLeap.Examples.<>c__DisplayClass68_0:<CreateLocalMediaStream>b__0() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Assets\ExpertCall\Scripts\WebRTC\MLWebRTCExample.cs:456)
2023/07/21 16:39:15.772 7534 17828 Info Unity System.Threading.Tasks.Task`1:InnerInvoke()
2023/07/21 16:39:15.772 7534 17828 Info Unity System.Threading.Tasks.Task:Execute()
2023/07/21 16:39:15.772 7534 17828 Info ml_camera_client  prepareCapture captureFrameRate = 30fps numStreamConfigs = 1 
2023/07/21 16:39:15.772 7534 17828 Info ml_camera_client  Stream 0 type = Video resolution = 1080P 
2023/07/21 16:39:15.772 7534 17828 Info ml_camera_client Stream 1 type = Image resolution =  
2023/07/21 16:39:15.773 7534 17828 Info ml_camera_client  prepareCapture device state = Idle numStreamConfigs = 1 
2023/07/21 16:39:15.773 7534 17828 Info ml_camera_client  Stream 0 type = Video resolution = 1080P state = Configured 
2023/07/21 16:39:15.773 7534 17828 Info ml_camera_client Stream 1 type = Image resiolution =  state = Invalid 
2023/07/21 16:39:15.773 7534 17828 Debug ml_camera_client  PreCaptureAEAWB ++
2023/07/21 16:39:15.788 7534 7534 Warn UnityGfxDeviceW type=1400 audit(0.0:5367): avc: denied { search } for name="traces" dev="nvme0n1p37" ino=7340035 scontext=u:r:untrusted_app:s0:c105,c256,c512,c768 tcontext=u:object_r:trace_data_file:s0 tclass=dir permissive=0
2023/07/21 16:39:16.667 7534 7703 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:16.667 7534 7703 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:16.700 7534 7703 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:16.700 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:16.766 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:16.767 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:16.833 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:16.833 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:16.900 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:16.900 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:16.933 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:16.933 7534 7703 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:16.967 7534 7703 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:16.967 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.000 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.000 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.033 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.033 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.033 7534 7552 Debug ml_camera_client aeawb convergence signaled
2023/07/21 16:39:17.066 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.067 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.100 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.100 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.133 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.133 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.166 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.167 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.200 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.200 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.233 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.233 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.266 7534 7552 Info ml_camera_client aeawb frame listener
2023/07/21 16:39:17.266 7534 7552 Debug ml_camera_client aeawb session capturecompleted
2023/07/21 16:39:17.264 7534 7534 Warn com.concepthealth.arconsultwfvr type=1400 audit(0.0:5403): avc: denied { search } for comm=494C3243505020546872656164706F name="traces" dev="nvme0n1p37" ino=7340035 scontext=u:r:untrusted_app:s0:c105,c256,c512,c768 tcontext=u:object_r:trace_data_file:s0 tclass=dir permissive=0
2023/07/21 16:39:17.269 7534 17828 Error Camera-Device endConfigure fail Status(-8, EX_SERVICE_SPECIFIC): '3: endConfigure:739: Camera 0: Unsupported set of inputs/outputs provided'
2023/07/21 16:39:17.269 7534 17828 Info ml_camera_client startRepeatingCaptureVideo device state = Idle numStreamConfigs = 1 
2023/07/21 16:39:17.269 7534 17828 Info ml_camera_client  Stream 0 type = Video resolution = 1080P state = Configured 
2023/07/21 16:39:17.269 7534 17828 Info ml_camera_client Stream 1 type = Image resiolution =  state = Invalid 
2023/07/21 16:39:17.333 7534 7703 Debug ml_camera_client  got video buffer 3146 timestamp = 1012951735960
2023/07/21 16:39:17.333 7534 7552 Debug ml_camera_client capturecompletecount = 4271 timestamp = 1012951735960
2023/07/21 16:39:17.333 7534 7552 Debug ml_camera_client capture complete for 1012951735960
2023/07/21 16:39:17.335 7534 17850 Debug ml_camera_client Ready for raw video frame callback
2023/07/21 16:39:17.340 7534 17850 Debug ml_camera_client  released video buffer 3147 timestamp = 1012951735960
2023/07/21 16:39:17.343 7534 7567 Info luminkarrot nova/frameworks/kali/kaliwebrtc/simple/src/Factory.cpp:106 Creating microphone audio source
2023/07/21 16:39:17.344 7534 7567 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/simple/src/video/Source.cpp:186 Video track created and enabled
2023/07/21 16:39:17.344 7534 7567 Info luminkarrot nova/frameworks/kali/kaliwebrtc/simple/src/Connection.cpp:471 Add track: source = 0x7bb3d14c27d8; track id = local
2023/07/21 16:39:17.344 7534 9107 Info luminkarrot nova/frameworks/kali/kaliwebrtc/simple/src/Connection.cpp:77 Renegotiation needed in state 0
2023/07/21 16:39:17.344 7534 7567 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/simple/src/audio/Source.cpp:67 Audio track created and enabled
2023/07/21 16:39:17.344 7534 7567 Info luminkarrot nova/frameworks/kali/kaliwebrtc/simple/src/Connection.cpp:471 Add track: source = 0x7bb2f27260c0; track id = audio_track
2023/07/21 16:39:17.365 7534 7567 Error CRASH *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2023/07/21 16:39:17.365 7534 7567 Error CRASH Version '2022.2.0f1 (35dcd44975df)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'x86_64'
2023/07/21 16:39:17.365 7534 7567 Error CRASH Build fingerprint: 'ml/demophon_aosp/demophon:10/B3E.230526.01-R.026/29:user/release-keys'
2023/07/21 16:39:17.365 7534 7567 Error CRASH Revision: '0'
2023/07/21 16:39:17.365 7534 7567 Error CRASH ABI: 'x86_64'
2023/07/21 16:39:17.365 7534 7567 Error CRASH Timestamp: 2023-07-21 16:39:17.365339996+0000
2023/07/21 16:39:17.365 7534 7567 Error CRASH pid: 7534, tid: 7567, name: UnityMain  >>> com.concepthealth.arconsultwfvr <<<
2023/07/21 16:39:17.365 7534 7567 Error CRASH uid: 10105
2023/07/21 16:39:17.365 7534 7567 Error CRASH signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr --------
2023/07/21 16:39:17.365 7534 7567 Error CRASH Cause: null pointer dereference
2023/07/21 16:39:17.365 7534 7567 Error CRASH     rax 00007bb3d2aeb8a0  rbx 0000000000000000  rcx 00007bb3d2aeb8a0  rdx 00007bb360cfb030
2023/07/21 16:39:17.365 7534 7567 Error CRASH     r8  0000000000000000  r9  00007bb420462300  r10 00007bb3d2aeb530  r11 0000000000000246
2023/07/21 16:39:17.365 7534 7567 Error CRASH     r12 00007bb3d09b6798  r13 00007bb4186b2f60  r14 00007bb3d14c2624  r15 00007bb3d14c2618
2023/07/21 16:39:17.365 7534 7567 Error CRASH     rdi 00007bb3d14c2624  rsi 00007bb3d09b6798
2023/07/21 16:39:17.365 7534 7567 Error CRASH     rbp 00007bb3d14c27d8  rsp 00007bb3d2aeb820  rip 00007bb2f7beb010
2023/07/21 16:39:17.365 7534 7567 Error CRASH 
2023/07/21 16:39:17.365 7534 7567 Error CRASH backtrace:
2023/07/21 16:39:17.365 7534 7567 Error CRASH       #00 pc 00000000002db010  /system/lib64/liblumin_webrtc_simple.so (lumin::karrot::simple::video::Source::removeSink(lumin::karrot::simple::video::Sink*)+48) (BuildId: 3bd55de1e660953b7e7be510486d0ab6)
2023/07/21 16:39:17.365 7534 7567 Error CRASH       #01 pc 00000000002da9fa  /system/lib64/liblumin_webrtc_simple.so (lumin::karrot::simple::video::Sink::setSource(std::__1::shared_ptr<lumin::karrot::simple::video::Source>)+26) (BuildId: 3bd55de1e660953b7e7be510486d0ab6)
2023/07/21 16:39:17.366 7534 7552 Debug ml_camera_client  got video buffer 3147 timestamp = 1012985154662
2023/07/21 16:39:17.366 7534 7551 Debug ml_camera_client capturecompletecount = 4272 timestamp = 1012985154662
2023/07/21 16:39:17.367 7534 7551 Debug ml_camera_client capture complete for 1012985154662
2023/07/21 16:39:17.368 7534 17852 Debug ml_camera_client Ready for raw video frame callback
2023/07/21 16:39:17.373 7534 17852 Debug ml_camera_client  released video buffer 3148 timestamp = 1012985154662
2023/07/21 16:39:17.400 7534 7551 Debug ml_camera_client  got video buffer 3148 timestamp = 1013018548538
2023/07/21 16:39:17.400 7534 7552 Debug ml_camera_client capturecompletecount = 4273 timestamp = 1013018548538
2023/07/21 16:39:17.400 7534 7552 Debug ml_camera_client capture complete for 1013018548538
2023/07/21 16:39:17.402 7534 17854 Debug ml_camera_client Ready for raw video frame callback
2023/07/21 16:39:17.404 7534 17854 Debug ml_camera_client  released video buffer 3149 timestamp = 1013018548538
2023/07/21 16:39:17.433 7534 7551 Debug ml_camera_client  got video buffer 3149 timestamp = 1013051669782
2023/07/21 16:39:17.466 7534 7551 Debug ml_camera_client  got video buffer 3150 timestamp = 1013085051675
2023/07/21 16:39:17.499 7534 7551 Debug ml_camera_client  got video buffer 3151 timestamp = 1013118403562
2023/07/21 16:39:17.510 7534 7567 Error CRASH Tombstone written to: /storage/emulated/0/Android/data/com.concepthealth.arconsultwfvr/files/tombstone_01
2023/07/21 16:39:17.533 7534 7551 Debug ml_camera_client  got video buffer 3152 timestamp = 1013151904578
2023/07/21 16:39:17.566 7534 7551 Debug ml_camera_client  got video buffer 3153 timestamp = 1013185335373
2023/07/21 16:39:17.600 7534 7703 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/21 16:39:17.600 7534 7703 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/21 16:39:17.600 7534 7703 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/21 16:39:17.633 7534 7703 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/21 16:39:17.633 7534 7703 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/21 16:39:17.633 7534 7703 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/21 16:39:17.666 7534 7703 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/21 16:39:17.666 7534 7703 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/21 16:39:17.666 7534 7703 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/21 16:39:17.699 7534 7703 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/21 16:39:17.700 7534 7703 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/21 16:39:17.700 7534 7703 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/21 16:39:17.733 7534 7703 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/21 16:39:17.733 7534 7703 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/21 16:39:17.733 7534 7703 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38

The problem occurs when I am trying to reopen the WebRTC calling screen to restart the calling functionality within a single session of the app. This results in the application crashing. I have observed crash is coming in webrtc library.
Additionally, I've noticed that the "Camera Indicator" persists on the screen even after the WebRTC call has been disconnected and I've navigated away from the canvas that hosts the calling functionality.

Here are my questions:

  1. Is there a known issue with reopening the WebRTC calling screen after a disconnect? How can this situation be properly handled to avoid crashes?
  2. What could be causing the "Camera Indicator" to remain active after a WebRTC call has been disconnected and the canvas has been switched? How can it be correctly disabled?

Any advice or guidance on these issues would be greatly appreciated. If more details are needed regarding my application's implementation, please let me know.

I have also performed another test. While opening Camera Preview and Camera Recording functionality right after ending WebRTC Call, I am getting the following logs in the console:

2023/07/21 17:01:46.401 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.461 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 5 lines
2023/07/21 17:01:46.470 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.484 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.645 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 14 lines
2023/07/21 17:01:46.655 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.668 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.677 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.828 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 13 lines
2023/07/21 17:01:46.838 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.851 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.897 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 4 lines
2023/07/21 17:01:46.906 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.920 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.967 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 4 lines
2023/07/21 17:01:46.976 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:46.990 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.012 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 2 lines
2023/07/21 17:01:47.022 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.035 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.114 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 7 lines
2023/07/21 17:01:47.127 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.136 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.196 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 5 lines
2023/07/21 17:01:47.206 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.219 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.251 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 3 lines
2023/07/21 17:01:47.265 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.274 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.389 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 10 lines
2023/07/21 17:01:47.402 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.412 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.425 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 1 line
2023/07/21 17:01:47.434 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.448 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.618 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 15 lines
2023/07/21 17:01:47.632 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.641 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.655 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.802 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 13 lines
2023/07/21 17:01:47.816 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.825 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.907 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 7 lines
2023/07/21 17:01:47.917 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.930 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:47.986 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 5 lines
2023/07/21 17:01:47.999 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.009 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.114 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 9 lines
2023/07/21 17:01:48.123 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.137 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.146 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.182 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 3 lines
2023/07/21 17:01:48.191 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.205 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.214 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.411 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 17 lines
2023/07/21 17:01:48.420 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.434 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.593 22213 31018 Info chatty uid=10105(com.concepthealth.arconsultwfvr) Thread 0x0x7bb3 identical 14 lines
2023/07/21 17:01:48.602 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.
2023/07/21 17:01:48.616 22213 31018 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:127 Not enough data to read.

For the sake of understanding: Our application has two features:

  1. Camera Recording (Camera Preview and Recording at the same time)
  2. WebRTC Calling between device and Browser

But both of functionalities are entirely independent. Right now, My focus point is when I am leaving the WebRTC Calling section and coming back to the same Canvas after disconnecting, I am getting crash.

Camera Indicator points that Camera is already accessed by Video Calling functionality, so any other process which has involvement of Camera Capturing may not work.

I need assistance to properly close and reopen the WebRTC Call.

Here is my script:

        private void OnEnable()
        {
            permissionCallbacks.OnPermissionGranted += OnPermissionGranted;
            permissionCallbacks.OnPermissionDenied += OnPermissionDenied;
            permissionCallbacks.OnPermissionDeniedAndDontAskAgain += OnPermissionDenied;

            // To fetch ICE Servers from Backend of Concept health
            StartCoroutine(FetchIceServers());

            // Camera and Microphone must be checked at runtime
            foreach (string permission in requiredPermissions)
            {
                MLPermissions.RequestPermission(permission, permissionCallbacks);
            }

            if (surviveSceneChange)
            {
                SceneManager.sceneUnloaded += SceneManager_sceneUnloaded;
            }
        }

        private void OnDisable()
        {
            permissionCallbacks.OnPermissionGranted -= OnPermissionGranted;
            permissionCallbacks.OnPermissionDenied -= OnPermissionDenied;
            permissionCallbacks.OnPermissionDeniedAndDontAskAgain -= OnPermissionDenied;
        }

        void OnDestroy()
        {
            permissionCallbacks.OnPermissionGranted -= OnPermissionGranted;
            permissionCallbacks.OnPermissionDenied -= OnPermissionDenied;
            permissionCallbacks.OnPermissionDeniedAndDontAskAgain -= OnPermissionDenied;

            if (!surviveSceneChange)
            {
                if (this == instance)
                {
                    instance = null;
                }
                Disconnect();
            }
        }

 public void Disconnect()
        {
            if (connection == null)
            {
                return;
            }

            webRequestManager.HttpPost(serverURI + "/logout/" + localId, string.Empty);

            if (dataChannel != null)
            {
                dataChannel.OnClosed -= OnDataChannelClosed;
                dataChannel.OnOpened -= OnDataChannelOpened;
                dataChannel.OnMessageText -= OnDataChannelTextMessage;
                dataChannel.OnMessageBinary -= OnDataChannelBinaryMessage;
                dataChannel = null;
            }

            UnsubscribeFromConnection(connection);

            connection.Destroy();
            connection = null;

            localVideoSource.DestroyLocal();

            remoteMediaStream = null;
            waitingForAnswer = false;
            waitingForAnswerGetRequest = false;

            connectButton.gameObject.SetActive(true);
            serverInput.gameObject.SetActive(true);
            localVideoSinkBehavior.gameObject.SetActive(false);
            remoteStatusText.text = "Disconnected";
            //localStatusText.text = "";
            remoteVideoSinkBehavior.VideoSink.SetStream(null);
            remoteAudioSinkBehavior.gameObject.SetActive(false);
            remoteVideoSinkBehavior.gameObject.SetActive(false);
            disconnectUI.SetActive(false);
            messageUI.SetActive(false);
            //dataChannelText.text = "";
            localVideoSourceDropdown.interactable = true;
            localVideoSizeDropdownRGB.interactable = true;
            localVideoSizeDropdownMR.interactable = true;

            remoteId = "";
            localId = "";
        }

@usman.bashir Have you been able to reproduce this crash when Using the Magic Leap unity Example project? When testing, I am able to connect and disconnect from the session without any issues .Your crash might be related to the incorrect disposal or stopping of the camera and audio streams. Make sure you Stop the camera before trying to disconnect.

Are you using the separate CV and Main cameras for the recording and calling features?

I have updated my disconnect function.

  private void DisconnectCamera()
        {
            if (mlCamera == null)
            {
                // Note that some APIs like MLCameraInit() can be called before MLCameraConnect()
                // is called. This is to make sure all is cleaned up if CameraConnect is not called
                MLCamera.Uninitialize();
                return;
            }

            streamCapabilities = null;

            // media player not supported in Magic Leap App Simulator
            mlCamera.Disconnect();
        }

        public void Disconnect()
        {
            if (connection == null)
            {
                return;
            }

            webRequestManager.HttpPost(serverURI + "/logout/" + localId, string.Empty);

            if (dataChannel != null)
            {
                dataChannel.OnClosed -= OnDataChannelClosed;
                dataChannel.OnOpened -= OnDataChannelOpened;
                dataChannel.OnMessageText -= OnDataChannelTextMessage;
                dataChannel.OnMessageBinary -= OnDataChannelBinaryMessage;
                dataChannel = null;
            }

            UnsubscribeFromConnection(connection);

            connection.Destroy();
            connection = null;

            localVideoSource.DestroyLocal();

            remoteMediaStream = null;
            waitingForAnswer = false;
            waitingForAnswerGetRequest = false;

            connectButton.gameObject.SetActive(true);
            serverInput.gameObject.SetActive(true);
            localVideoSinkBehavior.gameObject.SetActive(false);
            remoteStatusText.text = "Disconnected";
            //localStatusText.text = "";
            remoteVideoSinkBehavior.VideoSink.SetStream(null);
            remoteAudioSinkBehavior.gameObject.SetActive(false);
            remoteVideoSinkBehavior.gameObject.SetActive(false);
            disconnectUI.SetActive(false);
            messageUI.SetActive(false);
            //dataChannelText.text = "";
            localVideoSourceDropdown.interactable = true;
            localVideoSizeDropdownRGB.interactable = true;
            localVideoSizeDropdownMR.interactable = true;

            remoteId = "";
            localId = "";

            mlCamera.CapturePreviewStop();
            mlCamera.CaptureVideoStop();

            DisconnectCamera();
        }

Please let me know, If sequence of steps are not correct. Secondly, I want to reopen the WebRTC Calling Example in the same session of the App. Right now, If I am killing the app and opening it again, I am able to find working functionality of WebRTC calling. But If I am opening again, I am getting random crashes.

Unfortunately, I cannot debug your code directly since I am not familiar with your project and your project's source code. I recommend referencing the Magic Leap Unity Examples WebRTC scene and example script for information on how to connect and disconnect from the WebRTC call properly.

I went ahead and sent feedback to our voice of customer team regarding this issue and requested an simple WebRTC example and walkthrough.

I am using the same example from MagicLeapExamples for video calling. I am using MLWebRTCExample.cs and I have modified this file to update ICE Servers. But everything other than this is similar to what you have in MLWebRTCExample.cs file:

Here is the code base:

I want to properly close WebRTC thing along with Camera Indicator, so that If I want to reopen Video Calling Canvas. It should be on initial state where I can wait for other member to join.

Do you get the LocalVideoSource_OnCaptureStatusChanged call back when you disconnect from the call?

It looks like the issue with the camera not disconnecting properly is a known issue. in both the 1.7.0 and the 1.8.0 Unity Magic Leap SDK.

MLWebRTC: When disconnecting from a session, the camera does not shut down cleanly if the NativeSurface buffer format was used, causing the application to hang for as much as 30 seconds.

Can you try connecting without using the Native Surface ? Additionally, have you considered using the Unity Web RTC package? The latest commit includes the build scripts for the x86_64 plugin which are compatible with Magic Leap 2.

Can you also upload a bugreport ?

Just wanted to notify you that we are investigating an issue with the Unity WebRTC package not running properly when deployed to Magic Leap 2. I will provide an update as soon as we track down the issue.

Sorry for any inconvenience this may cause.

@kbabilinski I want to confirm how much time it will take to resolve issue on your end?

As we are almost running out of time.

Unfortunately I do not have an estimate for this at this time so I suggest moving forward with the webRTC api provided in the Magic Leap SDK.

Regarding the original issue:

  1. I have not been able to reproduce the start/ restart issue when using the Magic Leap Examples.
  2. Can you collect a bugreport from the device after running your application?

Okay, I will try to reproduce these issues and will attach the minimal reproducible example on your end.
I will further ask team if we can provide you with APK of our production app.

2023/07/24 17:16:05.214 6512 8865 Debug ml_camera_client Ready for raw video frame callback
2023/07/24 17:16:05.214 6512 8865 Debug ml_camera_client  released video buffer 940 timestamp = 222490501586
2023/07/24 17:16:05.247 6512 6548 Debug ml_camera_client  got video buffer 940 timestamp = 222523993435
2023/07/24 17:16:05.247 6512 6548 Debug ml_camera_client capturecompletecount = 940 timestamp = 222523993435
2023/07/24 17:16:05.247 6512 6548 Debug ml_camera_client capture complete for 222523993435
2023/07/24 17:16:05.248 6512 8867 Debug ml_camera_client Ready for raw video frame callback
2023/07/24 17:16:05.248 6512 8867 Debug ml_camera_client  released video buffer 941 timestamp = 222523993435
2023/07/24 17:16:05.500 6512 6547 Info ml_camera_client stopRepeatingCapturePreview device state = Idle numStreamConfigs = 1 
2023/07/24 17:16:05.500 6512 6547 Info ml_camera_client  Stream 0 type = Video resolution = 1080P state = Configured 
2023/07/24 17:16:05.500 6512 6547 Info ml_camera_client Stream 1 type =  resiolution = 1080P state = Invalid 
2023/07/24 17:16:05.500 6512 6547 Error ml_camera_client stop preview called when device not streaming
2023/07/24 17:16:05.498 6512 6512 Warn com.concepthealth.arconsultwfvr type=1400 audit(0.0:1698): avc: denied { search } for comm=494C3243505020546872656164706F name="traces" dev="nvme0n1p37" ino=7340035 scontext=u:r:untrusted_app:s0:c105,c256,c512,c768 tcontext=u:object_r:trace_data_file:s0 tclass=dir permissive=0
2023/07/24 17:16:05.502 6512 8868 Error Camera-Device endConfigure fail Status(-8, EX_SERVICE_SPECIFIC): '3: endConfigure:739: Camera 0: Unsupported set of inputs/outputs provided'
2023/07/24 17:16:05.502 6512 6547 Error Unity Error: MLCameraCapturePreviewStop in the Magic Leap API failed. Reason: InvalidOperation 
2023/07/24 17:16:05.502 6512 6547 Error Unity UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
2023/07/24 17:16:05.502 6512 6547 Error Unity UnityEngine.Logger:LogFormat(LogType, String, Object[])
2023/07/24 17:16:05.502 6512 6547 Error Unity UnityEngine.Debug:LogErrorFormat(String, Object[])
2023/07/24 17:16:05.502 6512 6547 Error Unity UnityEngine.XR.MagicLeap.MLPluginLog:ErrorFormat(String, Object[]) (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\Common\Utils\MLPluginLog.cs:121)
2023/07/24 17:16:05.502 6512 6547 Error Unity UnityEngine.XR.MagicLeap.MLResult:DidNativeCallSucceed(Code, String, Predicate`1, Boolean) (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\Common\MLResult.cs:873)
2023/07/24 17:16:05.502 6512 6547 Error Unity UnityEngine.XR.MagicLeap.MLCameraBase:CapturePreviewStop() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Packages\com.magicleap.unitysdk\Runtime\APIs\Camera\API\MLCameraBase.cs:81)
2023/07/24 17:16:05.502 6512 6547 Error Unity MagicLeap.Examples.MLWebRTCExample:Disconnect() (at D:\Android\AR\wavefunction\ConceptHealth-A-Consult\Assets\ExpertCall\Scripts\WebRTC\MLWebRTCExample.cs:110
2023/07/24 17:16:05.502 6512 6547 Info ml_camera_client stopRepeatingCaptureVideo device state = Idle numStreamConfigs = 0 
2023/07/24 17:16:05.502 6512 6547 Info ml_camera_client  Stream 0 type = Video resolution = 1080P state = Configured 
2023/07/24 17:16:05.502 6512 6547 Info ml_camera_client Stream 1 type =  resiolution =  state = Invalid 
2023/07/24 17:16:05.512 6512 8871 Info ml_camera_client Camonly OnAvailable CamId = 0

Here is the code:

        private void DisconnectCamera()
        {
            if (mlCamera == null)
            {
                // Note that some APIs like MLCameraInit() can be called before MLCameraConnect()
                // is called. This is to make sure all is cleaned up if CameraConnect is not called
                MLCamera.Uninitialize();
                return;
            }

            streamCapabilities = null;

            // media player not supported in Magic Leap App Simulator
            mlCamera.Disconnect();
        }

        public void Disconnect()
        {
            if (connection == null)
            {
                return;
            }

            webRequestManager.HttpPost(serverURI + "/logout/" + localId, string.Empty);

            if (dataChannel != null)
            {
                dataChannel.OnClosed -= OnDataChannelClosed;
                dataChannel.OnOpened -= OnDataChannelOpened;
                dataChannel.OnMessageText -= OnDataChannelTextMessage;
                dataChannel.OnMessageBinary -= OnDataChannelBinaryMessage;
                dataChannel = null;
            }

            UnsubscribeFromConnection(connection);

            connection.Destroy();
            connection = null;

            localVideoSource.DestroyLocal();

            remoteMediaStream = null;
            waitingForAnswer = false;
            waitingForAnswerGetRequest = false;

            connectButton.gameObject.SetActive(true);
            serverInput.gameObject.SetActive(true);
            localVideoSinkBehavior.gameObject.SetActive(false);
            remoteStatusText.text = "Disconnected";
            //localStatusText.text = "";
            remoteVideoSinkBehavior.VideoSink.SetStream(null);
            remoteAudioSinkBehavior.gameObject.SetActive(false);
            remoteVideoSinkBehavior.gameObject.SetActive(false);
            disconnectUI.SetActive(false);
            messageUI.SetActive(false);
            //dataChannelText.text = "";
            localVideoSourceDropdown.interactable = true;
            localVideoSizeDropdownRGB.interactable = true;
            localVideoSizeDropdownMR.interactable = true;

            mlCamera.CapturePreviewStop();
            mlCamera.CaptureVideoStop();

            DisconnectCamera();

            remoteId = "";
            localId = "";

        }

Test Scenario: 2

I killed the webrtc calling functionality and got some random crash. I opened fresh application.

2023/07/24 17:19:19.077 9443 9462 Debug ml_camera_client  got video buffer 138 timestamp = 416354448186
2023/07/24 17:19:19.077 9443 9479 Debug ml_camera_client capturecompletecount = 138 timestamp = 416354448186
2023/07/24 17:19:19.077 9443 9479 Debug ml_camera_client capture complete for 416354448186
2023/07/24 17:19:19.079 9443 10133 Debug ml_camera_client Ready for raw video frame callback
2023/07/24 17:19:19.111 9443 9462 Debug ml_camera_client  got video buffer 139 timestamp = 416388124571
2023/07/24 17:19:19.115 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.144 9443 9462 Debug ml_camera_client  got video buffer 140 timestamp = 416421171566
2023/07/24 17:19:19.177 9443 9462 Debug ml_camera_client  got video buffer 141 timestamp = 416454505188
2023/07/24 17:19:19.206 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.211 9443 9462 Debug ml_camera_client  got video buffer 142 timestamp = 416487873486
2023/07/24 17:19:19.244 9443 9460 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/24 17:19:19.244 9443 9460 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/24 17:19:19.244 9443 9460 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/24 17:19:19.277 9443 9460 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/24 17:19:19.277 9443 9460 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/24 17:19:19.277 9443 9460 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/24 17:19:19.296 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.311 9443 9460 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/24 17:19:19.311 9443 9460 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/24 17:19:19.311 9443 9460 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/24 17:19:19.344 9443 9460 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/24 17:19:19.344 9443 9460 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/24 17:19:19.344 9443 9460 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/24 17:19:19.377 9443 9460 Error BufferQueueConsumer [BufferItemQueue] acquireBuffer: max acquired buffer count reached: 5 (max 4)
2023/07/24 17:19:19.377 9443 9460 Error BufferItemConsumer [BufferItemQueue] Error acquiring buffer: Unknown error -38 (-38)
2023/07/24 17:19:19.377 9443 9460 Error : acquireBuffer BufferItemConsumer::acquireBuffer fail, status -38
2023/07/24 17:19:19.386 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.476 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.567 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.657 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.747 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.837 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320
2023/07/24 17:19:19.927 9443 9862 Debug luminkarrot nova/frameworks/kali/kaliwebrtc/common/src/CircularBuffer.cpp:148 Total overwritten size prior to this read 320

@kbabilinski Here is the detailed crash report:

You can download this file:

Do you mind capturing a bugreport. You can send the files to me as a DM if you do not wish to share them publicly. Previous thread.