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 partial incompatibility with wrtc 0.0.63 #215

Merged
merged 5 commits into from
Nov 29, 2017
Merged

Fix partial incompatibility with wrtc 0.0.63 #215

merged 5 commits into from
Nov 29, 2017

Conversation

nazar-pc
Copy link
Collaborator

Fix partial incompatibility with wrtc 0.0.63 that doesn't guarantee to have candidate pair with active connection when RTCDataChannel is opened (see node-webrtc/node-webrtc#339 for details)

Test is added in order to reproduce the issue and confirm the fix. Easier to review with ?w=1 is URL in order to hide code indentation changes.

cc @markandrus

…o have candidate pair with active connection when RTCDataChannel is opened (see node-webrtc/node-webrtc#339 for details)
@markandrus
Copy link
Contributor

@nazar-pc this looks like it would work to me; however, I guess you had to introduce the withinIntervalCallback because there is no guarantee that a getStats request will resolve before the next interval. Is that right? If so, would it be simpler to eliminate withinIntervalCallback and to use setTimeout instead of setInterval to re-queue a getStats request if we haven't found the candidate pair yet?

@nazar-pc
Copy link
Collaborator Author

Great suggestion, I've made it even simpler now

@markandrus
Copy link
Contributor

Nice! 👍 LGTM

.gitignore Outdated
@@ -0,0 +1 @@
node_modules
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't commit this file (git exclude).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed, but why? It will be present in literally any clone and node_modules definitely shouldn't appear in repository.

index.js Outdated
if (item.type === 'remotecandidate' || item.type === 'remote-candidate') {
remoteCandidates[item.id] = item
function setSelectedCandidatePair (selectedCandidatePair) {
self._connecting = false
Copy link
Collaborator

@t-mullen t-mullen Nov 29, 2017

Choose a reason for hiding this comment

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

The use of self._connecting and self.connected like this means that self.connected will be false on a getStats error, even though the event fires. These should be left where it is, and a different variable can be used .

self.remoteAddress = remote[0]
self.remotePort = Number(remote[1])
self._debug('connect')
self.emit('connect')
Copy link
Collaborator

Choose a reason for hiding this comment

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

This event can fire without self.connected being set to true if items is empty.

@nazar-pc
Copy link
Collaborator Author

Applied some tweaks, does it look better now?

@t-mullen
Copy link
Collaborator

Seems okay to me. It's unfortunate wrtc requires this hack, but I don't see it getting fixed any time soon.

@nazar-pc
Copy link
Collaborator Author

I don't think it will ever be fixed at all. As mentioned in linked issue latest Chrome also seems to have the same behavior and spec doesn't guarantee anything in this regard anyway.

@t-mullen t-mullen merged commit 1650fef into feross:master Nov 29, 2017
@nazar-pc
Copy link
Collaborator Author

When to expect new release containing this fix?

@feross
Copy link
Owner

feross commented Dec 3, 2017

8.2.0

@nazar-pc nazar-pc deleted the wrtc-upgrade-and-fix branch December 4, 2017 00:41
FredZeng pushed a commit to FredZeng/simple-peer that referenced this pull request Oct 14, 2023
Fix partial incompatibility with wrtc 0.0.63
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.

5 participants