Skip to content

Reject candidates from old generation #3113

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

JoeTurki
Copy link
Member

Description

Return an error if a candidate with a username fragment that does not match the username fragment in the remote description is added. This usually indicates that the candidate was generated before the renegotiation.

Last time I tested Chrome silently drops such candidates, firefox returns an error.

Maybe we should also handle "generation" extension.

Reference issue

Fixes #2993
Fixes #2511

@JoeTurki JoeTurki force-pushed the reject-candidates-from-old-generation branch from c603752 to da2580d Compare April 27, 2025 02:50
@JoeTurki JoeTurki marked this pull request as draft April 27, 2025 02:55
@Sean-Der
Copy link
Member

I bet some users have code that tears down the PeerConnection entirely on error. This change could trigger that :/

I agree with rejecting candidates and doing a logger.Error I just don't want to negatively impact anyone who is just auto upgrading.

Or is it doing wrong by users to not return an error?

@JoeTurki JoeTurki force-pushed the reject-candidates-from-old-generation branch from da2580d to 210fef7 Compare April 27, 2025 03:55
@JoeTurki
Copy link
Member Author

I agree with rejecting candidates and doing a logger.Error I just don't want to negatively impact anyone who is just auto upgrading.
Or is it doing wrong by users to not return an error?

This makes sense, firefox implementation around generations seems extreme, and returning errors already broke few of the tests :)

@JoeTurki JoeTurki force-pushed the reject-candidates-from-old-generation branch 2 times, most recently from 1ba737b to 4771727 Compare April 27, 2025 04:00
Copy link

codecov bot commented Apr 27, 2025

Codecov Report

Attention: Patch coverage is 78.12500% with 7 lines in your changes missing coverage. Please review.

Project coverage is 78.74%. Comparing base (d6154f6) to head (465d8bd).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
peerconnection.go 78.12% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3113      +/-   ##
==========================================
- Coverage   78.77%   78.74%   -0.03%     
==========================================
  Files          91       91              
  Lines       11383    11401      +18     
==========================================
+ Hits         8967     8978      +11     
- Misses       1932     1936       +4     
- Partials      484      487       +3     
Flag Coverage Δ
go 80.64% <78.12%> (-0.04%) ⬇️
wasm 63.84% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JoeTurki JoeTurki force-pushed the reject-candidates-from-old-generation branch 4 times, most recently from 98c1407 to 537b29f Compare April 27, 2025 04:28
@JoeTurki JoeTurki marked this pull request as ready for review April 27, 2025 04:33
@JoeTurki
Copy link
Member Author

Okay the error is gone, we still test it, I had to do a refactor to make the linter happy. However I don't know how I feel about this change overall, It aligns with other clients, and it shouldn't break any other client but I'm still not confident.

@Sean-Der
Copy link
Member

Does accepting candidates before the first setRemoteDescription still have the same behavior. I have seen people on that behavior.

I think you should merge :) if it breaks things we will hear and fix. I think you have done more than your due diligence

@JoeTurki
Copy link
Member Author

JoeTurki commented Apr 27, 2025

Does accepting candidates before the first setRemoteDescription still have the same behavior. I have seen people on that behavior.

  • First setRemoteDescription call: The behavior remains the same: we return &rtcerr.InvalidStateError{Err: ErrNoRemoteDescription}.

  • Second setRemoteDescription call: Here the behavior changes, but in a way that should prevent more problems than it might cause. we avoid accidentally applying late ICE candidates, like with @jech issue

Return an error if a candidate with a username fragment that does
not match the username fragment in the remote description is added.
This usually indicates that the candidate was generated before the
renegotiation.
@JoeTurki JoeTurki force-pushed the reject-candidates-from-old-generation branch from 537b29f to 465d8bd Compare April 27, 2025 15:35
@JoeTurki JoeTurki added this to the V4.1.0 milestone Apr 28, 2025
@JoeTurki JoeTurki merged commit 465d8bd into master Apr 28, 2025
22 of 23 checks passed
@JoeTurki JoeTurki deleted the reject-candidates-from-old-generation branch April 28, 2025 00:25
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.

Pion ignores the ice-ufrag of candidates AddICECandidate might not verify ufrag
2 participants