Skip to content

Conversation

@v1rtl
Copy link

@v1rtl v1rtl commented May 4, 2025

Makes go-libp2p compile by omitting pion/webrtc which explicitly does not support WASM for certain APIs.

Fixes #3277

Additionally

  • all builtin transports are disabled for WASM in default settings, as they are not supported by browsers
  • Some utilities that are still used elsewhere are moved into *_shared.go files

I locally tested and verified that both linux and wasm targets build properly

This is a more basic approach to #3280, whose goal is to bring WASM support to WebRTC, but it's blocked by upstream dependencies

@v1rtl v1rtl marked this pull request as ready for review May 4, 2025 17:29
@MarcoPolo
Copy link
Collaborator

Thank you! I think this would be great to merge. For reference, did you see #2191?

I'll try to review this this week.

@MarcoPolo MarcoPolo self-requested a review May 5, 2025 18:02
@MarcoPolo
Copy link
Collaborator

As a rough guideline, I think this would be a good way to merge Wasm support:

  1. Make changes to be able to compile go-libp2 without any transport.
  2. Add transports support in one by one.
    2a. Extend libp2p's transport interop tests to test the transport. (I can help with the specifics here)

@v1rtl
Copy link
Author

v1rtl commented May 5, 2025

Thank you! I think this would be great to merge. For reference, did you see #2191?

I'll try to review this this week.

I didn't know about this PR, neat! Since then a lot of things have progressed, browsers support WebTransport much better now and Go has better WASM interop

@v1rtl
Copy link
Author

v1rtl commented May 5, 2025

As a rough guideline, I think this would be a good way to merge Wasm support:

1. Make changes to be able to compile go-libp2 without any transport.

Do you mean to not include any transports by default for wasm target?

@MarcoPolo
Copy link
Collaborator

As a rough guideline, I think this would be a good way to merge Wasm support:

1. Make changes to be able to compile go-libp2 without any transport.

Do you mean to not include any transports by default for wasm target?

Yep. Just to get everything else to compile.

@v1rtl
Copy link
Author

v1rtl commented May 7, 2025

As a rough guideline, I think this would be a good way to merge Wasm support:

1. Make changes to be able to compile go-libp2 without any transport.

Do you mean to not include any transports by default for wasm target?

Yep. Just to get everything else to compile.

well this PR already makes it compile, despite those transports not working in WASM yet

do you still prefer if I remove all transports from a default config anyway?

Copy link
Author

@v1rtl v1rtl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly disabling wasm compilation for some unsupported APIs managed to remove 6 megabytes from the binary, mainly due to exclusion of quic-go

@v1rtl v1rtl mentioned this pull request May 12, 2025
4 tasks
@p-shahi p-shahi mentioned this pull request Jun 17, 2025
26 tasks
@v1rtl v1rtl requested a review from MarcoPolo August 4, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebRTC transport fails to compile with WebAssembly

2 participants