godotengine / webrtc-native

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

Problem with Higl Level Multiplayer Api #64

Closed maxim-sheronov closed 1 year ago

maxim-sheronov commented 1 year ago

Godot version

4.0 beta2

Plugin version

latest for 4.0 beta2

System information

Windows 11

Issue description

WebRtc is working strange, and maybe there are bugs in case of high level multiplayer api.

I tried to check bomber-rpc demo, but it has lobby stage and starts the game only after lobby sealing. But I want to make a game, when clients can connect and disconnect any time. I have working project based on Enet peers, and now want to migrate to WebRTC.

First issue that I see - rpc() call is trying to use peer, that is not connected. I tried to send rpc call only to peers, that has connection status - connected, and it worked. But only for first two clients. I think, that something is happening when new client is connecting and there is going some offer-candidate-ice magic.

Steps to reproduce

I added repro project, based on signalling demo. Just launch exported project at least 3 times. Choose one server - it will have signalling server) and other clients. And you will see errors like:

E 0:00:14:0718 _send_rpc: DataChannel is closed <C++ Source> src/WebRTCLibDataChannel.cpp:211 @ _put_packet()

client.gd:23 @ _send_rpc() E 0:00:14:0719 _send_rpc: Method/function failed. Returning: FAILED src/WebRTCLibDataChannel.cpp:212 @ _put_packet() client.gd:23 @ _send_rpc() ### Minimal reproduction project _No response_
maxim-sheronov commented 1 year ago

webrtc-bug.zip

Faless commented 1 year ago

WebRtc is working strange, and maybe there are bugs in case of high level multiplayer api.

The WebRTC multiplayer peer used to behave in a slightly different manner in previous versions of Godot (see https://github.com/godotengine/godot-proposals/issues/3208). The behaviors have been normalized in godotengine/godot#67094 (beta4 and newer), and the WebRTC demos have been updated ( https://github.com/godotengine/godot-demo-projects/pull/789 ).

I have tested that the issue is fixed after updating the reproduction project to the latest (beta5) Godot changes (webrtc-bug-updated.zip, I mostly replaced ws_webrtc_client.gd and ws_webrtc_server.gd with the updated versions).

Closing as fixed, please let us know if you can also confirm the fix with beta5, or we can reopen the issue in case.

maxim-sheronov commented 1 year ago

Hi there! Just checked it in my project (on beta 5) and it seems to work. So thanks a lot!