Timeout trigger _iceComplete if candidates seen. #353
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On some networks the
iceStateChange=complete
event will not fire until the browser times out, even though all valid and useful offer/answer candidates have already been gathered in the first milliseconds.Examples of this occurring:
According to a Chromium developer here:
In other words, on these networks there are valid routes to the internet but also invalid routes. Those invalid routes are confusing the offer gathering process into thinking it must keep trying.
This means that people on such networks can have 10s of seconds of delay in WebRTC offer creation time (consistently ~40s on my own network which experiences this issue) even though all valid candidates they are going to receive have been received in the first milliseconds of the offer process. The log in the bittorrent-tracker issue has a detailed example of this happening.
In the thread above Chromium developers suggest a JS time-out:
Similar patches have been suggested and implemented in other WebRTC projects:
This patch follows the same pattern and makes _iceComplete fire early and return the valid offers that have been gathered after some timeout. This only happens once the first valid candidate has been received. The timeout defaults to 5 seconds and can be modified by the user using
opts.iceCompleteTimeout
.Let me know if you need any further information or if there are any changes required to this patch. Thanks for your consideration!
Side note which may be of interest. On the network where I see the 45s delay the following simple-peer tests also fail: