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

[flatbuffers] Fix missing options in router.createWebRtcTransport() #1185

Merged

Conversation

ibc
Copy link
Member

@ibc ibc commented Oct 19, 2023

Fixes #1184

Details

  • No idea how, but flatbuffers branch misses enableUdp, enableTcp, and preferUdp and preferTcp options when creating a WebRtcTransport with a WebRtcServer. This was implemented in v3.

Fixes #1184

### Details

- No idea how, but flatbuffers branch misses `enableUdp`, `enableTcp`, and `preferUdp` and `preferTcp` options when creating a `WebRtcTransport` with a `WebRtcServer`. This was implemented in v3.

### TODO

Rust side, but I prefer to have the Node + C++ sides approved first.

### NOTE

I'm extremely worried that something else may have been lost, specially in `WebRtcServer` cpp and hpp files.
Copy link
Member

@jmillan jmillan left a comment

Choose a reason for hiding this comment

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

I'm extremely worried that something else may have been lost, specially in WebRtcServer cpp and hpp files.

It was you in this commit. One of those in which most of changes are unrelated to the initial intent :-).

@ibc
Copy link
Member Author

ibc commented Oct 19, 2023

Can you please recheck that commit link? It doesn't work for me.

@jmillan
Copy link
Member

jmillan commented Oct 19, 2023

Can you please recheck that commit link? It doesn't work for me.

Edited the link.

ibc added 2 commits October 19, 2023 18:39
So for whatever reason, setting `webrtc_transport_options.enable_udp = false` is ignored. Such a `enable_udp: false` value is not sent through the channel but instead the worker receives `true`. Why?
@ibc
Copy link
Member Author

ibc commented Oct 19, 2023

@nazar-pc @jmillan I desperately need help with this: 1e46e35

@nazar-pc
Copy link
Collaborator

We have to/from_fbs methods, have you updated them all?

Copy link
Member Author

@ibc ibc left a comment

Choose a reason for hiding this comment

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

Here I have updated the to_fbs method:

#1185 (comment)

@ibc
Copy link
Member Author

ibc commented Oct 19, 2023

Rust done and test modified to use the new stuff. PR ready.

@nazar-pc can you please press the "Approve" button?

Comment on lines +133 to 137
assert_eq!(ice_candidates.len(), 1);
assert_eq!(ice_candidates[0].ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert_eq!(ice_candidates[0].protocol, Protocol::Udp);
assert_eq!(ice_candidates[0].port, port1);
assert_eq!(ice_candidates[0].protocol, Protocol::Tcp);
assert_eq!(ice_candidates[0].port, port2);
assert_eq!(ice_candidates[0].r#type, IceCandidateType::Host);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We had UDP and TCP before, why removing UDP?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I am testing enable_udp: false as I said. Just a few lines above:

let transport = router
            .create_webrtc_transport({
                let mut webrtc_transport_options = WebRtcTransportOptions::new_with_server(
                    webrtc_server.clone()
                );
                // Let's disable UDP so resulting ICE candidates should only contain TCP.
                webrtc_transport_options.enable_udp = false;

                webrtc_transport_options
            })
            .await
            .expect("Failed to create WebRTC transport");

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is TCP testing no longer necessary here then?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • That test creates a WebRtcServer that listens in UDP and TCP.
  • Then it creates a transport with webrtc_server and enable_udp: false, meaning that the resulting transport should only use the TCP ICE candidates of the given webrtc_server.
  • So the test asserts that there is only a ICE candidate (assert_eq!(ice_candidates.len(), 1);) and it's TCP.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand what test is doing with these changes, but I don't understand what was wrong with the old test that you needed to change it.

Should you maybe add another test case instead? Also why no such change in TS, did TS test contain different conditions? (tests are usually symmetrical).

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair. I've done same change in Node test: cf0b033

Should you maybe add another test case instead?

There is little value in just asserting that a transport created with webRtcServer has the same ICE candidates than webRtcServer. So IMHO in those tests we can also test those enable_udp etc fields.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean if it should do that, why not test it? 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

Because:

  • Jose and me have lot of work these days. I'm exhausted working on 3 different mediasoup PRs in parallel and doing things at work.
  • The current API sucks. It got way worse after adding webRtcServer since then we allow listenIps OR webRtcServer but not both, and some other options only make sense for one of them, etc etc. I know it and I'd love to refactor it in v4, but we have to keep backwards compatibility.

But all those are excuses and you are right.

Comment on lines +133 to 137
assert_eq!(ice_candidates.len(), 1);
assert_eq!(ice_candidates[0].ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
assert_eq!(ice_candidates[0].protocol, Protocol::Udp);
assert_eq!(ice_candidates[0].port, port1);
assert_eq!(ice_candidates[0].protocol, Protocol::Tcp);
assert_eq!(ice_candidates[0].port, port2);
assert_eq!(ice_candidates[0].r#type, IceCandidateType::Host);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean if it should do that, why not test it? 🙂

@ibc ibc merged commit b706ae7 into flatbuffers Oct 19, 2023
30 checks passed
@ibc ibc deleted the flatbuffer-fix-missing-create-webrtc-transport-options branch October 19, 2023 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[flatbuffers] enableUdp/Tcp and forceUdp/Tcp in createWebRtcTransport() are completely missing
3 participants