MediaManager holds a lock and synchronously joins another thread at shutdown

NEW
Assigned to

Status

()

Core
WebRTC: Audio/Video
P3
normal
Rank:
25
3 years ago
9 months ago

People

(Reporter: Ben Turner (not reading bugmail, use the needinfo flag!), Assigned: jesup)

Tracking

unspecified
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

MediaManager holds 'mMutex' and then synchronously joins 'mMediaThread' at shutdown.

We shouldn't block there because there are plenty of other components that need to do cleanup and could do so in parallel. Also, holding a lock while blocking there is a recipe for deadlock, since the other thread might try to grab the same lock...
The simplest thing I can think of would be to call StopSoon() and return, and then also observe "xpcom-shutdown-threads" where you could then call Stop(). Hopefully by that time the thread will have done its cleanup and joining will be fast.
Also note that for Bug 1046245 comment 81 I need for mMediaThread to call BackgroundChild::CloseForCurrentThread() when it shuts down, which is not happening since it's not an nsThread. Unless there's a way to have this happen by default, I'll probably need to PostTask to it from main on shutdown in any case, which might impact the approach we take here.
(In reply to Ben Turner [:bent] (use the needinfo flag!) from comment #0)
> Also, holding a lock while blocking there is a recipe for deadlock,
> since the other thread might try to grab the same lock...

Yes, MediaManager::GetBackend() so this seems very real.
(Assignee)

Comment 4

3 years ago
Related to bug 1164463 and likely will be resolved by it
Assignee: nobody → rjesup
Rank: 25
Priority: -- → P2
See Also: → bug 1164463

Updated

3 years ago
backlog: --- → webRTC+
Mass change P2->P3 to align with new Mozilla triage process.
Priority: P2 → P3
You need to log in before you can comment on or make changes to this bug.