Closed Bug 1670560 Opened 5 years ago Closed 5 years ago

Intermittent deadlock in WebrtcMediaDataDecoder::InitDecode

Categories

(Core :: WebRTC: Audio/Video, defect, P1)

defect

Tracking

()

RESOLVED FIXED
83 Branch
Tracking Status
firefox83 --- fixed

People

(Reporter: jya, Assigned: jya)

References

Details

Attachments

(1 file, 1 obsolete file)

Spawned from https://bugzilla.mozilla.org/show_bug.cgi?id=1631178#c17 as it is likely affecting more tests than this one.

A deadlock could occur when we attempt to start the RDD process if at the same time the JS' main thread is stopping a webrct VideoReceiveStream following a call to PeerConnection::Close()

Starting the RDD process is done via a sync dispatch to the main thread, if the main thread is already waiting for the decoder to shutdown we will deadlock.

The simplest approach would be to unconditionally start the RDD process when we create the WebrtcMediaDataDecoder decoder.
This would prevent the sync dispatch to the main thread as the RDD would already be running.

The 2nd easiest option would be to assume that the MediaDataDecoder initialisation will always succeed, similar to what the GMP decoder is currently doing:
The downside is that we would no longer error if the codec isn't actually supported: not an issue with vp8 and vp9, but for h264 it could be.

But seeing that it's good enough for the GMP initialisation which too could fail it may not be an issue.

The RDD launch is done by dispatching a synchronous task to the main thread and sending to the parent a LaunchRDD() IPC message.

Unfortunately, the VideoConduit is managed on the main thread and it is possible that it's currently blocked waiting for the decoder thread to shutdown.

Ideally, we would want to move the VideoConduit outside the main thread, but this would be a very expansive change.

Unlikely to happen, but we could have exhausted all our thread in the decoder thread pool and be deadlock.

Depends on D93201

Attachment #9180987 - Attachment is obsolete: true

I will be taking a different approach than first thought, moving the launch of the RDD over the PBackground channel rather than PContent which much runs on the main thread.

P2 is still worthy of inclusion as it could also potentially lead to a deadlock if we run out of thread in our thread pool.

Attachment #9180988 - Attachment description: Bug 1670560 - P2. Don't use the same thread pool for both decoding and waiting for the decode to complete. r?mattwoodrow → Bug 1670560 - Don't use the same thread pool for both decoding and waiting for the decode to complete. r?mattwoodrow
Severity: -- → S3
Priority: -- → P1
Pushed by jyavenard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f8fa11cab287 Don't use the same thread pool for both decoding and waiting for the decode to complete. r=mattwoodrow
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 83 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: