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

DRAFT: Don't immediately renegotiate for initial streams #671

Closed
wants to merge 3 commits into from

Conversation

feross
Copy link
Owner

@feross feross commented Jun 2, 2020

Fixes #670

This is a draft because I don't want to change the public API in order to fix this bug.

@feross feross requested review from t-mullen and nazar-pc June 2, 2020 03:32
@@ -146,7 +146,7 @@ class Peer extends stream.Duplex {

if (this.streams) {
this.streams.forEach(stream => {
this.addStream(stream)
this.addStream(stream, false)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This parameter tells addTrack that it should not trigger a renegotiation.

@@ -270,11 +270,11 @@ class Peer extends stream.Duplex {
* Add a MediaStream to the connection.
* @param {MediaStream} stream
*/
addStream (stream) {
addStream (stream, triggerNegotiate = true) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't actually want to add this to the public API, but this PR is just to demonstrate a fix to the problem

Comment on lines +376 to +377
this._debug('negotiate')
this.emit('negotiate')
Copy link
Owner Author

Choose a reason for hiding this comment

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

Unrelated fix here: I moved this debug log and the undocumented 'negotiate' event to fire when negotiate happens. Before, it was firing when the connection becomes stable, which seemed like a bug

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's meant to fire when negotiation completes, which coincides with stable without a queued renegotiation.

It's only used in some tests.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think it'd be better to name the event something other than 'negotiate' since the convention is to emit debug logs and events named after methods when they're first called. Maybe it should be called 'negotiated' then?

@@ -882,6 +885,7 @@ class Peer extends stream.Duplex {
if (this.destroyed) return

if (this._pc.signalingState === 'stable' && !this._firstStable) {
this._firstStable = false
Copy link
Owner Author

@feross feross Jun 2, 2020

Choose a reason for hiding this comment

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

This boolean seemed to be set in the wrong place. Before it was being set after any signalingStateChange instead of after the first stable state. I moved it inside the if statement so it is only set after first stable.

@daxfrost
Copy link

Just tested this, it's working great! Looking forward to a release with this in.

@t-mullen t-mullen closed this Aug 8, 2020
@feross feross deleted the no-immediate-renegotiate branch October 28, 2020 00:11
@feross
Copy link
Owner Author

feross commented Oct 28, 2020

Superceded by #722

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.

Two peers sending video/audio leads to immediate renegotiation
3 participants