godotengine / webrtc-native

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

Calling WebRTCPeerConnection.CreateDataChannel in C# throws External component has thrown an exception. #71

Closed JonathanPicques closed 10 months ago

JonathanPicques commented 1 year ago

Godot version

4.0.beta.5

Plugin version

for beta5

System information

Windows 10 64bits

Issue description

Calling WebRTCPeerConnection.CreateDataChannel in C# throws External component has thrown an exception.

Steps to reproduce

Simply writing this in _Ready will cause a crash:

var peerConnection = new WebRTCPeerConnection();
var peerDataChannel = peerConnection.CreateDataChannel("chat", new Godot.Collections.Dictionary {
    {"id", 1},
    {"negotiated", true},
});

Minimal reproduction project

WebRTCBug.zip

JonathanPicques commented 1 year ago

Still happens in beta8, but with a more verbose output:

Godot Engine v4.0.beta8.mono.official.45cac42c0 - https://godotengine.org
Vulkan API 1.3.224 - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 2080

2022-12-15 22:32:33.456 DEBUG [21292] [rtc::impl::Init::doInit@120] Global initialization
2022-12-15 22:32:33.460 DEBUG [16256] [rtc::impl::Certificate::Generate@223] Generating certificate (OpenSSL)
ERROR: Condition "_instance_bindings != nullptr" is true.
   at: set_instance_binding (core/object/object.cpp:1706)
ERROR: Parameter "strong_gchandle.value" is null.
   at: setup_csharp_script_binding (modules/mono/csharp_script.cpp:1218)
ERROR: Condition "!script_binding.inited" is true. Returning: { nullptr }
   at: godotsharp_internal_unmanaged_get_instance_binding_managed (modules/mono/glue/runtime_interop.cpp:231)
ERROR: Parameter "strong_gchandle.value" is null.
   at: setup_csharp_script_binding (modules/mono/csharp_script.cpp:1218)
ERROR: Condition "!script_binding.inited" is true. Returning: { nullptr }
   at: godotsharp_internal_unmanaged_instance_binding_create_managed (modules/mono/glue/runtime_interop.cpp:244)
ERROR: FATAL: Condition "!rc_owner" is true.
   at: _instance_binding_reference_callback (modules/mono/csharp_script.cpp:1304)
Fatal error. System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at Godot.NativeInterop.NativeFuncs.godotsharp_ref_destroy(Godot.NativeInterop.godot_ref ByRef)
   at Godot.NativeInterop.godot_ref.Dispose()
   at Godot.NativeCalls.godot_icall_2_1142(IntPtr, IntPtr, System.String, Godot.NativeInterop.godot_dictionary)
   at Godot.WebRTCPeerConnection.CreateDataChannel(System.String, Godot.Collections.Dictionary)
   at Bug._Ready()
   at Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name ByRef, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant ByRef)
   at Godot.CanvasItem.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name ByRef, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant ByRef)
   at Godot.Node2D.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name ByRef, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant ByRef)
   at Bug.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name ByRef, Godot.NativeInterop.NativeVariantPtrArgs, Godot.NativeInterop.godot_variant ByRef)
   at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr, Godot.NativeInterop.godot_string_name*, Godot.NativeInterop.godot_variant**, Int32, Godot.NativeInterop.godot_variant_call_error*, Godot.NativeInterop.godot_variant*)
Faless commented 10 months ago

Same as #116 , closing in favor of that issue which has more info. Possibly fixed by https://github.com/godotengine/godot/pull/84947