Skip to content
This repository was archived by the owner on Jan 24, 2020. It is now read-only.

WebRTC support for XRMP #4

Closed
wants to merge 18 commits into from
Closed

WebRTC support for XRMP #4

wants to merge 18 commits into from

Conversation

chrislatorres
Copy link
Contributor

@chrislatorres chrislatorres commented Jun 6, 2019

This PR is for #3 . Replacing websockets in favor of serverless webRTC data channels in XRMP. This allows for peer to peer connection, which reduces the latency of having to use an intermediary server for communications.

multi4
multi3

@chrislatorres chrislatorres changed the title xrmp changes WebRTC support for XRMP Jun 6, 2019
@chrislatorres
Copy link
Contributor Author

almost complete, everything is set except the last part of the answer submit / pc.setRemoteDescription

crashing at: https://github.com/exokitxr/studio/pull/4/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR1070

gdb trace:

Thread 96 "Thread 0x000001ECC851" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 25532.0x8644]
0x00007ffb0a6f9c90 in ntdll!RtlEnterCriticalSection ()
   from C:\WINDOWS\SYSTEM32\ntdll.dll
(gdb) bt
#0  0x00007ffb0a6f9c90 in ntdll!RtlEnterCriticalSection ()
   from C:\WINDOWS\SYSTEM32\ntdll.dll
#1  0x00007ffb0a6f9ad0 in ntdll!RtlEnterCriticalSection ()
   from C:\WINDOWS\SYSTEM32\ntdll.dll
#2  0x00007ffaa6a96df2 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#3  0x00007ffaa6a5bc51 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#4  0x00007ffaa744fb27 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#5  0x00007ffaa7450fdb in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#6  0x00007ffaa6a5c39f in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#7  0x00007ffaa6a5cfd9 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#8  0x00007ffaa6c63b74 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#9  0x00007ffaa6c63abd in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#10 0x00007ffaa6b69313 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#11 0x00007ffaa6b68d32 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#12 0x00007ffaa6b68a11 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#13 0x00007ffaa6b47cfc in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#14 0x00007ffaa6a95c11 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#15 0x00007ffaa6a560d5 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#16 0x00007ffaa6a55eb2 in node_register_module_v72 ()
   from \\?\C:\Users\chris\github\studio\exokit\build\Release\exokit.node
#17 0x00007ffb08147974 in KERNEL32!BaseThreadInitThunk ()
   from C:\WINDOWS\System32\kernel32.dll
#18 0x00007ffb0a75a271 in ntdll!RtlUserThreadStart ()
   from C:\WINDOWS\SYSTEM32\ntdll.dll
#19 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

@chrislatorres
Copy link
Contributor Author

chrislatorres commented Jun 6, 2019

sdp could be base64 encoded to be in a more friendlier format (sdp requires specific formating/spacing which can get lost in copy/pasting and is not well suited for exokit:// type links).

Tried encoding with base64 and it worked well, maintaining the formatting/spacing:


raw:

v=0
o=- 1632853972366540933 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE data
a=msid-semantic: WMS
m=application 50344 DTLS/SCTP 5000
c=IN IP4 192.168.206.241
a=candidate:2054832600 1 udp 2122260223 192.168.206.241 50344 typ host generation 0 network-id 4
a=candidate:3960013048 1 udp 2122194687 192.168.254.43 50345 typ host generation 0 network-id 1 network-cost 10
a=candidate:888782120 1 tcp 1518280447 192.168.206.241 51337 typ host tcptype passive generation 0 network-id 4
a=candidate:2727017480 1 tcp 1518214911 192.168.254.43 51338 typ host tcptype passive generation 0 network-id 1 network-cost 10
a=ice-ufrag:kEHX
a=ice-pwd:CWfTKGKEg41QYmtZphHepFp3
a=ice-options:trickle
a=fingerprint:sha-256 13:75:9D:E7:50:46:C6:09:72:58:5B:EE:18:88:D4:EB:98:1C:2F:23:34:50:AF:BB:A6:6E:7E:BB:87:69:D9:71
a=setup:actpass
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024

base64 encoded:

dj0wCm89LSAxNjMyODUzOTcyMzY2NTQwOTMzIDIgSU4gSVA0IDEyNy4wLjAuMQpzPS0KdD0wIDAKYT1ncm91cDpCVU5ETEUgZGF0YQphPW1zaWQtc2VtYW50aWM6IFdNUwptPWFwcGxpY2F0aW9uIDUwMzQ0IERUTFMvU0NUUCA1MDAwCmM9SU4gSVA0IDE5Mi4xNjguMjA2LjI0MQphPWNhbmRpZGF0ZToyMDU0ODMyNjAwIDEgdWRwIDIxMjIyNjAyMjMgMTkyLjE2OC4yMDYuMjQxIDUwMzQ0IHR5cCBob3N0IGdlbmVyYXRpb24gMCBuZXR3b3JrLWlkIDQKYT1jYW5kaWRhdGU6Mzk2MDAxMzA0OCAxIHVkcCAyMTIyMTk0Njg3IDE5Mi4xNjguMjU0LjQzIDUwMzQ1IHR5cCBob3N0IGdlbmVyYXRpb24gMCBuZXR3b3JrLWlkIDEgbmV0d29yay1jb3N0IDEwCmE9Y2FuZGlkYXRlOjg4ODc4MjEyMCAxIHRjcCAxNTE4MjgwNDQ3IDE5Mi4xNjguMjA2LjI0MSA1MTMzNyB0eXAgaG9zdCB0Y3B0eXBlIHBhc3NpdmUgZ2VuZXJhdGlvbiAwIG5ldHdvcmstaWQgNAphPWNhbmRpZGF0ZToyNzI3MDE3NDgwIDEgdGNwIDE1MTgyMTQ5MTEgMTkyLjE2OC4yNTQuNDMgNTEzMzggdHlwIGhvc3QgdGNwdHlwZSBwYXNzaXZlIGdlbmVyYXRpb24gMCBuZXR3b3JrLWlkIDEgbmV0d29yay1jb3N0IDEwCmE9aWNlLXVmcmFnOmtFSFgKYT1pY2UtcHdkOkNXZlRLR0tFZzQxUVltdFpwaEhlcEZwMwphPWljZS1vcHRpb25zOnRyaWNrbGUKYT1maW5nZXJwcmludDpzaGEtMjU2IDEzOjc1OjlEOkU3OjUwOjQ2OkM2OjA5OjcyOjU4OjVCOkVFOjE4Ojg4OkQ0OkVCOjk4OjFDOjJGOjIzOjM0OjUwOkFGOkJCOkE2OjZFOjdFOkJCOjg3OjY5OkQ5OjcxCmE9c2V0dXA6YWN0cGFzcwphPW1pZDpkYXRhCmE9c2N0cG1hcDo1MDAwIHdlYnJ0Yy1kYXRhY2hhbm5lbCAxMDI0Cg==

@chrislatorres
Copy link
Contributor Author

current WebRTC party menu:

settingtextCapture

@chrislatorres
Copy link
Contributor Author

module that can be pulled from to reduce sdp size: https://github.com/chrisplatorres/sdp-minimizer

write-up on it: https://webrtchacks.com/the-minimum-viable-sdp/

@avaer
Copy link
Member

avaer commented Jun 6, 2019

node_register_module_v72

This is a native module bootstrap -- node version incompatibility in the build?

@chrislatorres
Copy link
Contributor Author

Debugging notes

rtcdebugCapture

so I knew that SetRemoteDescription was crashing, but this shows that it crashes on the messaging, which shows that it was trying to start the datachannel connection

10:33 AM] Avaer: called on the wrong thread
[10:34 AM] Avaer: or on a dead connection
[10:34 AM] Avaer: is this webrtc infra being GC'd behind our back?
[10:34 AM] Avaer: is it attatched globally to window?
[10:35 AM] Avaer: it shouldn't have to be but these are questions to ask for debugging

https://github.com/exokitxr/exokit/blob/master/deps/exokit-bindings/webrtc/src/peerconnection.cc#L393

@avaer
Copy link
Member

avaer commented Jun 6, 2019

Was there a parse error? https://github.com/exokitxr/exokit/blob/master/deps/exokit-bindings/webrtc/src/peerconnection.cc#L405

This looks ripe for logging 📝.

@chrislatorres
Copy link
Contributor Author

The WebRTC here might be dropped in favor of using websockets, atleast for signalling. The audio will likely still use WebRTC.

@chrislatorres
Copy link
Contributor Author

Closing in favor of #47.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants