Issue metadata
Sign in to add a comment
|
Chrome freezes when using WebRTC on macOS
Reported by
t...@guzz.io,
Jan 25 2018
|
||||||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 Steps to reproduce the problem: We've implemented our own WebRTC app based on the standard APIs under guzz.io. Until recently (and in other browsers), our video chat functionality worked fine. But since recently, we're experiencing heavy problems with WebRTC on Chrome. As soon as we start the video chat, the Chrome tab becomes unresponsive. It is not even possible to open the developer tools to check what the actual problem might be. Eventually, we have to "kill" the whole browser to be able to close the frozen Chrome tab. A connection to the remote peer cannot be established at all. Sometimes, our own video (from our webcam) shows up, but its very tiny in the upper left of the screen. What is the expected behavior? WebRTC works, just in Firefox and earlier Chrome versions. What went wrong? See "Steps to reproduce the problem". As soon as our app tries to establish a WebRTC connection, the whole browser frame freezes. Did this work before? Yes We don't actually know since we just received the first complaints from users. Probably it's the most recent Chrome version that caused the bug. Does this work in other browsers? Yes Chrome version: 63.0.3239.132 Channel: n/a OS Version: OS X 10.12.6 Flash Version: Since the whole tab becomes unresponsive, it's very hard to debug and provide a better bug report.
,
Jan 25 2018
Something I forgot: When the freeze happens, it is not even possible to click on any user interface element inside the frozen tab. Another important thing to note is that the problem only exists if Chrome is the browser that joins an existing WebRTC session, i.e. if the peer is already streaming. If Chrome initiates the hand-shake, everything works fine. In all cases, there are no error messages in the Inspector.
,
Jan 25 2018
Tested with iOS as peer. Same problem. If iOS initiates the session and Chrome on macOS joins, the tab freezes. If Chrome starts the session, it works.
,
Jan 25 2018
After some debugging, I found out that the problem occurs when Chrome receives a remote offer and I then try to add the local stream to the peer connection via an RTCPeerConnection#addStream call, e.g. peerConnection.addStream(myStream); As soon as this is called inside the remote offer handler, the tab freezes immediately. Funnily, if I place a debugger; line right before the call and then execute the addStream() call right after the debugger stops, everything works as expected. But as soon as I remove the debugger call and let the code run immediately, the tab freezes. It looks as if the browser runs into a timing problem / racing condition inside the addStream() method.
,
Jan 25 2018
The call also works if I place it inside a setTimeout() to run it async.
,
Jan 25 2018
can you provide a fiddle to reproduce the problem? https://jsfiddle.net/ug5tugnL/ seems to work fine but there might be differences from what you do.
,
Jan 26 2018
hbos@, can you take a look since this apparently concerns addStream()?
,
Jan 26 2018
What is the "remote offer handler"? What event are you listening to?
,
Jan 26 2018
addStream blocks the main thread ("javascript and tab thread") until the webrtc signaling thread as performed addStream in lower layers. Sounds like there might be a deadlock, but I don't know of anything on the webrtc signaling thread that would wait for the main thread.
How easy is it to repro this?
,
Jan 26 2018
Is it possible to construct a repro jsfiddle?
,
Jan 26 2018
,
Jan 26 2018
Also, have you tried if this can be reproduced on latest Canary?
,
Jan 26 2018
I'm experiencing the exact same problem around the addStream command. Tested on Windows 7, 10 and Linux Mint. I also noticed that it only seems to occur starting with Chrome version 63 (tested with 63.0.3239.132). Beta (64.0.3282.119) seems to have the same problem. 58.0.3029.96, 62.0.3202.75 and Dev (65.0.3325.18), however, are not freezing. As noted before, timing seems to be a relevant factor. Setting a breakpoint or putting the addStream into a setTimeout prevents the freeze.
,
Jan 26 2018
When do you call addStream? I don't have enough information to reproduce and fippo's jsfiddle is working.
,
Jan 26 2018
It sounds like the webrtc signaling thread is blocked on doing something which has been posted to the main thread and is in-queue, but calling addStream blocks the main thread. When you setTimeout that allows the main thread to execute all queued tasks before it does the addStream call, which no longer is blocked because the webrtc signaling thread was unblocked.
,
Jan 26 2018
it would also be interesting to hear if moving addStream before setRemoteDescription (and ignoring any negotiationneeded if that is used) is a valid workaround. chrome://webrtc-internals logs might be useful too, even though less than a reproduction fiddle.
,
Jan 26 2018
Moving addStream before setRemoteDescription seems to actually have done the trick! Thank you! I have not yet been able to create a fiddle but have attached a WebRTC internals dump if that helps. The flow on my side used to be as follows: - Got offer from remote - Get local stream - Create RTCPeerConnection - Register callback handlers - set remote description - addStream -> Freeze
,
Jan 27 2018
I was able to reproduce the freeze with this fiddle, which quite well resembles the way I'm handling an incoming offer in my client: https://jsfiddle.net/mbhjkevx/1/
,
Jan 27 2018
hbos: taylor said it might be https://bugs.chromium.org/p/chromium/issues/detail?id=736725#c6
,
Jan 29 2018
Yes, sounds likely to be a duplicate of issue 736725 . hbos - looks like the fix made it to M65 but not to M64 that's being pushed to stable now. Would it make sense to ask for a merge to M64 assuming there will be further updates?
,
Jan 29 2018
,
Jan 29 2018
I've verified that this is indeed a duplicate and fixed by https://chromium-review.googlesource.com/c/chromium/src/+/868656. Thanks for the repro fiddle! Tip of tree: Not reproducible. 64.0.3282.99: Reproducible. 64.0.3282.99 with patch applied: Not reproducible. Discussing merge into stable at issue 736725 .
,
Jan 29 2018
Thanks a lot for that very quick problem solution. Highly appreciated! |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by t...@guzz.io
, Jan 25 2018