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

Fix: CreateOffer race condition #1414

Merged
merged 1 commit into from
Sep 11, 2020
Merged

Fix: CreateOffer race condition #1414

merged 1 commit into from
Sep 11, 2020

Conversation

tarrencev
Copy link
Contributor

Fixes a race condition that occurs when the local media (transceivers) are mutated during the offer generation process.

Resolves an issue where an offer is created with no mid causing the error below:
image

The test is not great, since it depends on the performance of the executor. I was able to consistently reproduce locally with it though.

@tarrencev tarrencev requested a review from Sean-Der September 11, 2020 17:24
}

// Wait for async to complete otherwise dangling renegotation
// will occur on closed connection and throw InvalidStateError: connection closed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is #1401. I will fix it in a separate PR.

@codecov
Copy link

codecov bot commented Sep 11, 2020

Codecov Report

Merging #1414 into master will increase coverage by 0.29%.
The diff coverage is 79.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1414      +/-   ##
==========================================
+ Coverage   75.75%   76.04%   +0.29%     
==========================================
  Files          73       73              
  Lines        5948     5962      +14     
==========================================
+ Hits         4506     4534      +28     
+ Misses       1095     1078      -17     
- Partials      347      350       +3     
Flag Coverage Δ
#go 77.75% <79.66%> (+0.32%) ⬆️
#wasm 71.45% <ø> (ø)

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

Impacted Files Coverage Δ
peerconnection.go 77.24% <79.66%> (+0.51%) ⬆️
sdp.go 83.74% <0.00%> (+0.82%) ⬆️
operations.go 95.34% <0.00%> (+2.32%) ⬆️
sctptransport.go 81.40% <0.00%> (+3.51%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc11e7c...6a1b906. Read the comment docs.


// in-parallel steps to create an offer
// https://w3c.github.io/webrtc-pc/#dfn-in-parallel-steps-to-create-an-offer
isPlanB := pc.configuration.SDPSemantics == SDPSemanticsPlanB
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the only modification between here and line 653 is to use currentTransceivers rather than pc.GetTransceivers()

Fixes a race condition that occurs when the local media (transceivers)
are mutated during the offer generation process.
@@ -348,7 +348,7 @@ func (pc *PeerConnection) checkNegotiationNeeded() bool {
for _, t := range pc.GetTransceivers() {
// https://www.w3.org/TR/webrtc/#dfn-update-the-negotiation-needed-flag
// Step 5.1
// if t.stoping && !t.stopped {
Copy link
Member

Choose a reason for hiding this comment

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

Should these be commented out? They were in the original PR, maybe we should just delete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

according to the spec we should have a stopping property on a transceiver but we dont right now. so this was added prematurely. i'll leave for now and we can remove it separately

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.

2 participants