Fix deadlock issue in WebRtcMediaStreamTrackAdapterMap.
The fix is to reduce the scope of the |lock_| during track adapter creation because Create[Local/Remote]TrackAdapter() may synchronize with another thread that is busy waiting for the |lock_|. There is no reason to hold the |lock_| while creating the adapter; we are ensured no other adapters of the same kind (=local/remote) are created concurrently because they may only be created on the appropriate thread (local = main thread, remote = signaling thread) which is the thread currently running the operation. In other words, at most 1 GetOrCreateLocalTrackAdapter() on the main thread and at most 1 GetOrCreateRemoteTrackAdapter() on the signaling thread can run at the same time. This is the equivalent of the WebRtcMediaStreamAdapterMap fix (https://chromium-review.googlesource.com/c/868656/) but for the track adapter map. The deadlock is quite rare, but due to recent unrelated changes it has become frequent enough that it is easily reproducible on some platforms and applications, see bug. Bug: 813574 Change-Id: I2e7ba605db973221f80443267fd099c5973ab818 Reviewed-on: https://chromium-review.googlesource.com/980949 Commit-Queue: Henrik Boström <hbos@chromium.org> Reviewed-by:Guido Urdaneta <guidou@chromium.org> Cr-Commit-Position: refs/heads/master@{#546102}
Showing
Please register or sign in to comment