AudioSession COM Cleanup
Categories
(Core :: Widget: Win32, task, P3)
Tracking
()
People
(Reporter: bugzilla, Assigned: ssummar)
References
Details
Attachments
(2 files)
I see a few COMy things in AudioSession
that we should clean up:
- Remove
CoInitialize
andCoUninitialize
calls; sincemscom::ProcessRuntime
is instantiated during startup, COM is always available by the time this code runs. - Since the thread started by
SpawnASCReleaseThread
does not declare its apartment, it implicitly lives inside the multi-threaded apartment. Unfortunately theIAudioSessionControl
interface came from the main thread's single-threaded apartment, so callingRelease
on it from the multi-threaded apartment actually violates the rules of COM. At the very least the interface should be wrapped in amscom::AgileReference
while passing between threads. - We're using
PR_CreateThread
here; perhapsNS_DispatchBackgroundTask
is better suited to this? I guess that depends on whether it is possible to block shutdown by using the latter...
Reporter | ||
Comment 1•6 years ago
|
||
Note that CLSID_MMDeviceEnumerator
has a threading model of Both
, which means that its objects are safe to use in either an STA or the MTA, but not simultaneously. Passing between apartments requires either marshaling or an agile reference.
Comment 2•6 years ago
|
||
Thanks Aaron. I believe we can remove the use of AudioSession entirely from content processes entirely because of audio remoting -- I'm trying that out in bug 1430907 comment 27. But AudioSession also runs in the plugin and main processes. Does what you're saying apply there as well? I don't know if you know how the plugin COM setup is done but I'm wondering about your first 2 points there and in main (where I assume the Co(Un)Initialize calls are redundant but I don't know about the STA/MTA of it all).
Reporter | ||
Comment 3•6 years ago
•
|
||
The good news is that I did some further investigation and found out that the MMDeviceEnumerator
aggregates the free-threaded marshaler, which in plain English means that the STA/MTA threading stuff isn't an issue after all.
As helpful as audio remoting is, I think we should still take care of the first and third points. But which ever background thread we run the cleanup on, the runnable should be wrapped within a mscom::MTARegion
Assignee | ||
Comment 5•4 years ago
|
||
Updated•4 years ago
|
Updated•4 years ago
|
Comment 7•4 years ago
|
||
Backed out for causing bustages complaining about Unified_cpp_widget_windows0.obj.
Backout link: https://hg.mozilla.org/integration/autoland/rev/b0b7509ee7a0db5bb617a1a4dc6e345be2ec9385
Failure log: https://treeherder.mozilla.org/logviewer?job_id=366889094&repo=autoland&lineNumber=31670
Assignee | ||
Comment 8•4 years ago
|
||
Sorry about the backout. It's a very trivial issue. I'm working on it.
![]() |
||
Comment 10•4 years ago
|
||
bugherder |
Updated•4 years ago
|
Comment 11•4 years ago
|
||
Backed out for audio related crashes and hangs (bug 1755700, bug 1755717)
Backout link: https://hg.mozilla.org/mozilla-central/rev/1f245c0744d051d4382f2ee21dc6acadf04152d7
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Comment 12•4 years ago
|
||
Pointer to AudioSession object is made std::atomic to resolve crashes (bug 1755700) by atomically modifying/reading the pointer as an effort to make sure any update to the pointer is seen across other threads immediately while not using locks to maintain such concurrency and avoiding dataraces.
This patch is built upon the work done in D136377.
Comment 13•4 years ago
|
||
Comment 14•4 years ago
|
||
Backed out for dt failure on browser_dbg-backgroundtask-debugging.js
Backout link: https://hg.mozilla.org/integration/autoland/rev/57045ad64fb48792be9e513c55520b0a052bac22
Log link: https://treeherder.mozilla.org/logviewer?job_id=371198472&repo=autoland&lineNumber=2035
Assignee | ||
Comment 15•4 years ago
|
||
Thanks for notifying. I'm looking into it.
Comment 16•4 years ago
|
||
Comment 17•4 years ago
|
||
bugherder |
Comment 18•4 years ago
|
||
Since the status are different for nightly and release, what's the status for beta?
For more information, please visit auto_nag documentation.
Updated•3 years ago
|
Description
•