Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WebTransport #3899

Open
mrakh opened this issue Jan 31, 2022 · 5 comments
Open

Add support for WebTransport #3899

mrakh opened this issue Jan 31, 2022 · 5 comments

Comments

@mrakh
Copy link

mrakh commented Jan 31, 2022

Describe the project you are working on

A real-time multiplayer browser game with an authoritative server.

Describe the problem or limitation you are having in your project

A client-server multiplayer game requires a network transport that minimizes latency. For a natively installed game, this would traditionally be accomplished using a bespoke "netcode" sent over UDP, and any additional requirements like reliability or ordering were handled at the application layer. But within a browser, the only options for real-time full-duplex communication is via WebSockets or WebRTC.

WebSockets are ill suited for multiplayer games because the enforced ordering/reliability of the underlying TCP transport causes unacceptable latency spikes and degrades gameplay experience, particularly in the case of FPS games, MOBAs, and other such "twitch gameplay".

WebRTC has an option to use an unreliable/unordered transport mechanism, but it is designed with peer-to-peer in mind. Using it in a server is very clunky and difficult because there are no easy-to-use, stable, performant WebRTC implementations beyond what is in the Chrome/Firefox browser, and the handshaking process is fraught with complexities like STUN/TURN that are meant to address issues that don't exist for a public server.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

With the release of Google Chrome v97, The long-awaited WebTransport API is here at last. Like WebSockets, WebTransport offers a way to perform bidirectional client-server messaging. However, unlike WebSockets, a WebTransport connection can be configured to use an unreliable/unordered transport for low-latency real-time communications, where packet loss is tolerable.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

  • A base class WebTransportMultiplayerPeer which inherits from NetworkedMultiplayerPeer.
  • Two new classes, WebTransportClient and WebTransportServer, which inherit from WebTransportMultiplayerPeer.
  • Functions to:
    • Create/retrieve a SendStream and ReceiveStream for reliable/ordered transport
    • Create/retrieve WebTransportDatagramDuplexStream for unreliable/unordered transport

Here you can find some examples of how to use the JavaScript API for WebTransport.

If this enhancement will not be used often, can it be worked around with a few lines of script?

When building for HTML5, one could wrap the WebTransport object with Godot's own JavaScriptObject. However, a headless server build would need a fairly extensive module/plugin to use an external WebTransport server library.

Is there a reason why this should be core and not an add-on in the asset library?

WebSocket, HTTP and WebRTC support are all core, so it makes sense to add WebTransport support to that as well.

@Faless
Copy link

Faless commented Jan 31, 2022

My take on this is that it's way too soon to implement something like this.
The "standard" is still a very early draft, support for it is basically chrome-only (as the implementation), it's based on QUIC and HTTP/3 which is going to be a pain to implement, and moreover its advantages are still to be determined.

@mrakh
Copy link
Author

mrakh commented Jan 31, 2022

My take on this is that it's way too soon to implement something like this.
The "standard" is still a very early draft, support for it is basically chrome-only (as the implementation), it's based on QUIC and HTTP/3 which is going to be a pain to implement, and moreover its advantages are still to be determined.

I agree that an attempt at a functional implementation at this time would be quite unproductive. The selection of available C/C++ libraries to implement a QUIC server is rather sparse. I nonetheless believe the feature proposal is worth keeping in mind - I anticipate that WebTransport adoption will be quite significant as it stabilizes, particularly within the niche of multiplayer browser games.

@Tiedye
Copy link

Tiedye commented Dec 23, 2023

The spec is stable and available in multiple browsers now, is it a good time to look at this again?

@Calinou
Copy link
Member

Calinou commented Dec 23, 2023

The spec is stable and available in multiple browsers now, is it a good time to look at this again?

Safari support is still missing as of December 2023: https://caniuse.com/webtransport

@Anutrix
Copy link

Anutrix commented May 10, 2024

This ticket requires #8770 and then HTTP/3 and QUIC.

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

No branches or pull requests

5 participants