godotengine / webrtc-native

The official GDNative WebRTC implementation for non-html exports.
MIT License
207 stars 30 forks source link

WebRTCPeerConnection crashes when initialized with TURN Server #7

Closed dryw closed 4 years ago

dryw commented 4 years ago

The following code initializes correctly (The server is both STUN/TURN): peer.initialize({ "iceServers": [ { "urls": ["stun:159.203.29.246:3478"] } ] })

However, the following will produce a backtrace: peer.initialize({ "iceServers": [ { "urls": ["turn:159.203.29.246:3478"], "username": "dryw", "credentials": "testing123" } ] })

The crash appears to happen both on windows and linux. Editor is a custom build with Faless/godot@abcb079 + godot master godotengine/godot@930d6d8:

`Running: C:\Users\dpaulic\Desktop\godot\godot\bin\godot_windows_3.2_alpha2_Dryw.exe --path C:/Users/dpaulic/Desktop/bomber-rtc --remote-debug 127.0.0.1:6007 --allow_focus_steal_pid 6612 --position 448,240 Godot Engine v3.2.alpha.custom_build.acf1523e0 - https://godotengine.org OpenGL ES 3.0 Renderer: Intel(R) HD Graphics 630

Connected 1456400343 Peer connected 1 ERROR: PeerConnection could not be created ERROR: peer_connection.get() == nullptr ERROR: WebRTCMultiplayer::add_peer: Condition ' p_peer->get_connection_state() != WebRTCPeerConnection::STATE_NEW ' is true. returned: ERR_INVALID_PARAMETER At: modules\webrtc\webrtc_multiplayer.cpp:242 CrashHandlerException: Program crashed Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues [0] godot_nativescript_init [1] godot_nativescript_init [2] <couldn't map PC to fn name> [3] NativeScriptInstance::scalar deleting destructor' [4] Object::~Object (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:1942) [5] WebRTCPeerConnectionGDNative::scalar deleting destructor' [6] Ref::unref (c:\users\dpaulic\desktop\godot\godot\core\reference.h:279) [7] Variant::clear (c:\users\dpaulic\desktop\godot\godot\core\variant.cpp:1165) [8] Variant::call_ptr (c:\users\dpaulic\desktop\godot\godot\core\variant_call.cpp:1117) [9] GDScriptFunction::call (c:\users\dpaulic\desktop\godot\godot\modules\gdscript\gdscript_function.cpp:1082) [10] GDScriptInstance::call (c:\users\dpaulic\desktop\godot\godot\modules\gdscript\gdscript.cpp:1170) [11] Object::call (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:900) [12] Object::emit_signal (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:1218) [13] Object::_emit_signal (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:1150) [14] MethodBindVarArg::call (c:\users\dpaulic\desktop\godot\godot\core\method_bind.h:344) [15] Object::call (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:921) [16] Variant::call_ptr (c:\users\dpaulic\desktop\godot\godot\core\variant_call.cpp:1096) [17] GDScriptFunction::call (c:\users\dpaulic\desktop\godot\godot\modules\gdscript\gdscript_function.cpp:1082) [18] GDScriptInstance::call (c:\users\dpaulic\desktop\godot\godot\modules\gdscript\gdscript.cpp:1170) [19] Object::call (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:900) [20] Object::emit_signal (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:1218) [21] Object::emit_signal (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:1275) [22] WebSocketClient::_on_peer_packet (c:\users\dpaulic\desktop\godot\godot\modules\websocket\websocket_client.cpp:109) [23] wslay_event_recv (c:\users\dpaulic\desktop\godot\godot\thirdparty\wslay\wslay_event.c:753) [24] WSLPeer::poll (c:\users\dpaulic\desktop\godot\godot\modules\websocket\wsl_peer.cpp:231) [25] WSLClient::poll (c:\users\dpaulic\desktop\godot\godot\modules\websocket\wsl_client.cpp:224) [26] MethodBind0::call (c:\users\dpaulic\desktop\godot\godot\core\method_bind.gen.inc:150) [27] Object::call (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:921) [28] Variant::call_ptr (c:\users\dpaulic\desktop\godot\godot\core\variant_call.cpp:1096) [29] GDScriptFunction::call (c:\users\dpaulic\desktop\godot\godot\modules\gdscript\gdscript_function.cpp:1082) [30] GDScriptInstance::call_multilevel (c:\users\dpaulic\desktop\godot\godot\modules\gdscript\gdscript.cpp:1180) [31] Node::_notification (c:\users\dpaulic\desktop\godot\godot\scene\main\node.cpp:60) [32] Object::notification (c:\users\dpaulic\desktop\godot\godot\core\object.cpp:933) [33] SceneTree::_notify_group_pause (c:\users\dpaulic\desktop\godot\godot\scene\main\scene_tree.cpp:969) [34] SceneTree::idle (c:\users\dpaulic\desktop\godot\godot\scene\main\scene_tree.cpp:526) [35] Main::iteration (c:\users\dpaulic\desktop\godot\godot\main\main.cpp:1976) [36] OS_Windows::run (c:\users\dpaulic\desktop\godot\godot\platform\windows\os_windows.cpp:3015) [37] widechar_main (c:\users\dpaulic\desktop\godot\godot\platform\windows\godot_windows.cpp:162) [38] _main (c:\users\dpaulic\desktop\godot\godot\platform\windows\godot_windows.cpp:186) [39] main (c:\users\dpaulic\desktop\godot\godot\platform\windows\godot_windows.cpp:196) [40] __scrt_common_main_seh (d:\agent_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288) [41] BaseThreadInitThunk -- END OF BACKTRACE -- ERROR: NetSocketPosix::_get_socket_error: Socket error: 10054 At: drivers\unix\net_socket_posix.cpp:202`

This was tested using the bomber-rtc demo project. Removing "iceServers" and exposing the inner dictionary causes the program to run but it appears TURN servers do not function.

If a TURN server is required for testing, I can arrange credentials for mine!

dryw commented 4 years ago

It appears this is just a documentation error!

{ "iceServers": [ { "urls": [ "stun:stun.example.com:3478" ], # One or more STUN servers. }, { "urls": [ "turn:turn.example.com:3478" ], # One or more TURN servers. "username": "a_username", # Optional username for the TURN server. "credentials": "a_password", # Optional password for the TURN server. } ] } https://docs.godotengine.org/en/latest/classes/class_webrtcpeerconnection.html

Where "credentials" should be "credential" according to WebRTCLibPeerConnection.cpp. I will submit a documentation update PR when I have a some time.

Faless commented 4 years ago

Thanks for spotting it, yes, the key should be credential not credentials. Anyway, it still shouldn't crash... I'll investigate that...