microsoft / WebRTC-universal-samples

WebRTC samples for the Universal Windows Platform.
177 stars 71 forks source link

Program with data channel crashing after hang up. #38

Open Jelop opened 6 years ago

Jelop commented 6 years ago

Hi,

I've adapted parts of the PeerCC sample and integrated them into my own project. A large part of the adaptation was to get a Data Channel connection up and running. I've managed to do this but the program crashes consistently when hanging up the call when the data channel has been in use. I'm getting error 0xc0000374, which means a corrupted heap. I've been unable to diagnose the problem further. I have debug logs in the likely event that more information be required.

jamescadd commented 6 years ago

Hello - yes debug logs would be helpful. Make sure you enable mixed-mode debugging so we get the full WebRTC logs as well. Are you using the NuGet package, if so what version? I would be interested if this still repros with the M66 builds (alpha).

Jelop commented 6 years ago

Excuse my ignorance James, but I am unclear on a lot of this stuff as I am quite new to .net and visual studio. By chance I had already enabled the mixed mode debugging. I got about 10,000 lines of output due to repeated D3D warnings. The way I have incorporated WebRtc into my project is by taking the control script and the dlls from PeerCC. So when I need to make changes to Conductor.cs I modify it via the PeerConnectionClient.WebRtc.UnityD3D and update the relevant files in my Unity project. In the aforementioned solution the WebRtc NuGet package is installed and it is version 1.62.1.1-Beta.

Below is the last section of the logs. Most of what I have omitted is the D3D11 warning. But I have a feeling the logs are incomplete for the purpose as the WebRtc symbols were not loaded and I am unsure how to remedy this.

D3D11 WARNING: ID3D11DeviceContext::Draw: Input vertex slot 0 has stride 12 which is less than the minimum stride logically expected from the current Input Layout (40 bytes). This is OK, as hardware is perfectly capable of reading overlapping data. However the developer probably did not intend to make use of this behavior.  [ EXECUTION WARNING #355: DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL]
D3D11 WARNING: ID3D11DeviceContext::Draw: Vertex Buffer at the input vertex slot 0 is not big enough for what the Draw*() call expects to traverse. This is OK, as reading off the end of the Buffer is defined to return 0. However the developer probably did not intend to make use of this behavior.  [ EXECUTION WARNING #356: DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL]
Exception thrown at 0x773BC7D2 in AR_Maintenance.exe: Microsoft C++ exception: _com_error at memory location 0x0EDF9C38.
'AR_Maintenance.exe' (Win32): Unloaded 'C:\Program Files\Intel\Media SDK\libmfxhw32.dll'
H264StreamSink::~H264StreamSink()
H264MediaSink::~H264MediaSink()
The thread 0x14f8 has exited with code 0 (0x0).
The thread 0xaa8 has exited with code 0 (0x0).
The thread 0x7a8 has exited with code 1 (0x1).
The thread 0x2d8 has exited with code 1 (0x1).
The thread 0x7e4 has exited with code 0 (0x0).
The thread 0x1674 has exited with code 0 (0x0).
The thread 0x280 has exited with code 0 (0x0).
The thread 0x168c has exited with code 0 (0x0).
PeerConnection.Close called and returned
OnReadyToConnect invoked and returned
Garbage collector collects and returns. This is the end of the ClosePeerConnection method
Critical error detected c0000374
AR_Maintenance.exe has triggered a breakpoint.

---After continuing.

The thread 0x560 has exited with code 0 (0x0).
The thread 0xa74 has exited with code 0 (0x0).
Signaling: Headers received [i=421 data(450)]
'AR_Maintenance.exe' (Win32): Unloaded 'C:\Windows\System32\deviceaccess.dll'
'AR_Maintenance.exe' (Win32): Unloaded 'C:\Windows\System32\RTMediaFrame.dll'
'AR_Maintenance.exe' (Win32): Unloaded 'C:\Windows\System32\Windows.StateRepositoryPS.dll'
'AR_Maintenance.exe' (Win32): Unloaded 'C:\Windows\System32\Windows.Mirage.Internal.Capture.Pipeline.ProxyStub.dll'
'AR_Maintenance.exe' (Win32): Unloaded 'C:\Windows\System32\Windows.Shell.ServiceHostBuilder.dll'
Exception thrown at 0x7778CBAB (ntdll.dll) in AR_Maintenance.exe: 0xC0000374: A heap has been corrupted (parameters: 0x777B4890).
Unhandled exception at 0x7778CBAB (ntdll.dll) in AR_Maintenance.exe: 0xC0000374: A heap has been corrupted (parameters: 0x777B4890).
jamescadd commented 6 years ago

Is there anyway you can share your repro project so I can try it against the full source code? The other option is to clone this branch recursively, add your project to the solution, and do a build with the full WebRTC source.

To try M66, remove the reference to Org.WebRtc.dll/winmd and right click your project, choose "Manage NuGet packages." Click the checkbox to include preview, then search for WebRTC. You should see our package come up. Add a ref to that and try running the repro again.

Jelop commented 6 years ago

Unfortunately, sharing the project is not feasible. Do you mean that I should try compile my modified version of the PeerConnectionClientUnityD3DCore project against the full WebRTC source rather than the NuGet Package?

I have managed to change the version of the NuGet package to the latest M66 package. But I am met with many type not found and ambiguous reference errors in Conductor.cs. I'm not sure what I need to remove/add. I couldn't find a removable reference to Org.WebRtc.dll/winmd.

binxie33 commented 6 years ago

the issue should be this one: https://github.com/webrtc-uwp/webrtc-windows/pull/19 . The code fix is merged in master but apparently not yet built in the latest nuget package yet.

jamescadd commented 6 years ago

@binxie33 Thanks for drawing the connection :) I'll see if we can get an updated M62 package with the fix. Right now M66 isn't quite ready for Unity applications (we're in the process of working through some issues in the move to IL2CPP).

Jelop commented 6 years ago

Awesome, thanks guys!