Skip to content

Add gathering generation extension to candidates - #874

Merged
Sean-Der merged 1 commit into
pion:mainfrom
boushley:add-gathering-generation
Sep 13, 2026
Merged

Sean-Der merged 1 commit into
pion:mainfrom
boushley:add-gathering-generation

Conversation

@boushley

@boushley boushley commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Description

Populate the generation extension on candidates added to ICE Agent.

Comment thread agent.go Outdated
Comment on lines +1717 to +1719
if prevState == GatheringStateGathering {
a.candidateNotifier.EnqueueCandidate(nil)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a slight departure from the previous behavior that was part of the base patch from @JoTurk

I'm not sure if this behavior (only send nil candidate when transitioning from Gathering to Complete) is more correct, or if we should keep the original behavior (send nil candidate anytime we transition into the Complete state)

@JoTurk JoTurk Jan 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah, the reason i added this is because i just wanted to make the test pass (because the previous pr did close => complete), but sending nil regardless is correct i think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is because we don't go to complete from close, like in the previous pr.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I'm reading this right it looks like the previous behavior of sending the nil candidate anytime we enter Complete as long as the previous state wasn't also Complete is in line with Chrome's behavior.

@boushley
boushley marked this pull request as draft January 9, 2026 20:15
@boushley

boushley commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

Converted to draft since I missed that I should be piping generation through the call stack from Agent#GatherCandidates instead of pulling fresh from agent within the individual gather methods. I'll update that.

@codecov

codecov Bot commented Jan 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.01266% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.31%. Comparing base (aa9aa79) to head (603539f).

Files with missing lines Patch % Lines
gather.go 75.00% 6 Missing and 5 partials ⚠️
agent.go 88.57% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #874      +/-   ##
==========================================
+ Coverage   88.04%   88.31%   +0.27%     
==========================================
  Files          46       46              
  Lines        6507     6498       -9     
==========================================
+ Hits         5729     5739      +10     
+ Misses        532      516      -16     
+ Partials      246      243       -3     
Flag Coverage Δ
go 88.31% <81.01%> (+0.27%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@JoTurk

JoTurk commented Jan 9, 2026

Copy link
Copy Markdown
Member

Thank you I'll check again how chrome and firefox handle generations and review this. this pr is continuation of pion/webrtc#3113

@boushley
boushley force-pushed the add-gathering-generation branch 2 times, most recently from 8b913a0 to 6f163a5 Compare January 9, 2026 21:25
Comment thread gather.go
@boushley
boushley force-pushed the add-gathering-generation branch 2 times, most recently from ecd2263 to d5aaf7d Compare January 11, 2026 04:10
Comment thread agent.go Outdated
@boushley
boushley marked this pull request as ready for review January 12, 2026 18:32
@boushley
boushley force-pushed the add-gathering-generation branch from d5aaf7d to 5dad9ca Compare January 14, 2026 02:15
@JoTurk

JoTurk commented Jan 14, 2026

Copy link
Copy Markdown
Member

@boushley sorry I lost track of this, Will try to get back to you tomorrow.

@boushley

Copy link
Copy Markdown
Contributor Author

Ha! No problem, I only got around to fixing the linter errors today. Thanks for all you do!

@JoTurk

JoTurk commented Feb 8, 2026

Copy link
Copy Markdown
Member

@boushley Is this ready for review? or quick one?

@boushley

boushley commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

I think we need to address the possible dead lock issue with the notification from Agent loop, but I need to find time to get back into the headspace to address that.

@JoTurk

JoTurk commented Feb 8, 2026

Copy link
Copy Markdown
Member

Sounds good :)

@boushley

boushley commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

I'm open to ideas of how we should handle the concurrency issues here. I worry about the current state because it could potentially result in a deadlock where the Agent loop gets hung up trying to acquire the notifier lock, although I don't think there's a place where the notifier lock is dependent on the Agent loop, I haven't confirmed that side.

I also don't see a clean way of getting the notification with the nil candidate pulled out of the agent loop especially since this is done from at least two locations that can set the state to Complete :/

Should I dig in on what exactly the Notifier lock can hang on to gain confidence we're safe on that side? Or can you think of a cleaner way of getting the notification out on a less critical go routine?

@boushley
boushley force-pushed the add-gathering-generation branch from 5bc1d13 to 3405c8f Compare February 18, 2026 01:02
@boushley

Copy link
Copy Markdown
Contributor Author

Alright @JoTurk I got rid of the nested locking.

After a deeper analysis I determined that it was safe in the current configuration since the notifier releases the Mutex before executing any user code. However I didn't want to depend on that so I went with this route. If you'd prefer I move the notification back into the agent loop I can do that and just document the assumptions in the code around the notifier to try and ensure that assumption remains accurate.

@JoTurk

JoTurk commented Apr 6, 2026

Copy link
Copy Markdown
Member

@boushley I'm so sorry i lost this from my todo (again), I think your approach is the correct one, If you don't mind fixing the conflicts and I'll get into reviewing and testing this.
I think we'll just need a few unit tests before we merge this.

@Sean-Der
Sean-Der force-pushed the add-gathering-generation branch 6 times, most recently from 719d682 to a4f638d Compare September 12, 2026 11:56
@Sean-Der
Sean-Der force-pushed the add-gathering-generation branch 2 times, most recently from 3f0ef77 to 9a72213 Compare September 13, 2026 17:12
Populate the generation extension on candidates added to ICE Agent.
@Sean-Der
Sean-Der force-pushed the add-gathering-generation branch from 9a72213 to 603539f Compare September 13, 2026 18:07
@Sean-Der
Sean-Der merged commit 3c37e43 into pion:main Sep 13, 2026
18 checks passed
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.

4 participants