godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.58k stars 21.27k forks source link

Godot Webrtc is too slow #84645

Open tlloancy opened 1 year ago

tlloancy commented 1 year ago

Godot version

4.1.3

System information

Any

Issue description

I think my question couldn't be more accurate than :
https://stackoverflow.com/questions/56327783/webrtc-datachannel-for-high-bandwidth-application

TLDR with transfert fonctions already using the max packet size allowed of 256k, my transfert speed on both applications on same network barely reaches 6-7 MB wheres as on remote connection with bandwith equivalent to 20MB , the data transfert will drop somewhere between 300-600 KB ps when it's not almost zero using mobile data with bandwith of 1MB.

As when connected we dont know if we're on turn or real p2p, i tried usine another turn server and the result is the same. Is there optimizations or a way of troubleshootings that i am missing ?

Steps to reproduce

Remotely connect webrtc peer, send packets.

[Edit] my point is, for exemple, why is a ssh copy ten times faster ?

Minimal reproduction project

N/A

Calinou commented 1 year ago

Which platform did you do your testing on? WebRTC can be used both natively and in a web browser. This is an important nuance because the implementation is entirely different.

Please test both native-to-native and native-to-web scenarios to make sure this isn't specific to a single platform.

Also, please upload a minimal reproduction project[^1] to make this easier to troubleshoot.

[^1]: A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the .godot folder in the archive (but keep project.godot).

Drag and drop a ZIP archive to upload it. Do not select another field until the project is done uploading.

Note for C# users: If your issue is not Mono-specific, please upload a minimal reproduction project written in GDScript or VisualScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a Mono setup available.

[Edit] my point is, for exemple, why is a ssh copy ten times faster ?

WebRTC is designed for real-time communication (it's in the name), while SSH is a TCP-based protocol. TCP can do high throughput very well, but struggles at low-latency communication. By contrast, WebRTC is designed for low-latency communication but struggles with delivering high throughput.

If you want to prioritize throughput over latency, use WebSocket or (ideally) HTTP requests. You can keep using both protocols at the same time: WebRTC for real-time needs, HTTP requests to download/upload large files.

As when connected we dont know if we're on turn or real p2p, i tried usine another turn server and the result is the same. Is there optimizations or a way of troubleshootings that i am missing ?

Test on a local network with both machines connected over Ethernet to remove any external conditions.

tlloancy commented 1 year ago

If by native you mean from app to app yes I don't use any web browser, it's nice If I can keep webrtc and use other protocol but I would like to keep it P2P.

What is the maximum file size I can push

Calinou commented 1 year ago

What is the maximum file size I can push

The maximum size for GitHub attachments is 25 MB (remember to remove the .godot/ folder within the ZIP to make it smaller). If you need to upload something larger, create a public GitHub repository and link it here.

tlloancy commented 1 year ago

godot-test-webrtc.zip

tlloancy commented 8 months ago

Hi folks ! any news ?

tlloancy commented 8 months ago

I'd like to be able to catch webrtc errors in godot , like when ice url is invalid etc ...

Calinou commented 8 months ago

I'd like to be able to catch webrtc errors in godot , like when ice url is invalid etc ...

Please open a proposal for this, as this isn't strictly related to this issue.

tlloancy commented 7 months ago

just put my proposal here https://github.com/godotengine/webrtc-native/issues/145 as i think it might be a good place to start w/

tlloancy commented 7 months ago

(Because it can be both USer and DEv useful usage after all)