[meta] Remove AudioChannelService and AudioChannelAgent — replace with MediaController-based mechanisms
| Assignee | |
Description•2 months ago
|
AudioChannelService and AudioChannelAgent were designed for Firefox OS (B2G), a single-process mobile OS where one app owned the audio channel at a time. That architecture has not been valid since Fission shipped. The system is now a source of bugs, a Fission correctness gap, and a barrier to implementing modern web standards.
This meta bug tracks the complete removal of the AudioChannel system and its replacement with MediaController-based mechanisms.
What AudioChannelService currently does
- Tab sound indicator:
AudioChannelWindowaggregatesAudioChannelAgentaudible state per content process, fires the"audio-playback"observer, whichAudioPlaybackChild/AudioPlaybackParentrelay totabbrowser.js. - Tab mute via volume suppression:
RefreshAgentsVolume()pushes mute state down to everyAudioChannelAgentviaWindowVolumeChanged(), which setsMUTED_BY_AUDIO_CHANNELonHTMLMediaElement. - Delayed autoplay for background tabs:
ResumeDelayedPlaybackAgentregisters anAudioChannelAgentand waits for aWindowSuspendChanged(NONE_SUSPENDED)callback when the tab is foregrounded or the user clicks the Play Tab icon. - "Play Tab" icon:
MaybeNotifyMediaBlockStart()fires"activeMediaBlockStart"via the same observer and actor chain, drivingbrowser.activeMediaBlockStarted(). - Audio capture:
SetWindowAudioCaptured()notifiesHTMLMediaElementviaWindowAudioCaptureChanged()to adjust its capture track. - B2G audio focus/competing (
IsEnableAudioCompeting,RefreshAgentsAudioFocusChanged): dead code on desktop, can be deleted immediately.
Why this system must be removed
AudioChannelService is a per-content-process singleton. A Fission tab spans multiple content processes, and the service has no cross-process coordination. Each process fires its own "audio-playback" observer independently, which is the root cause of Bug 1962876: when a cross-origin iframe's process fires Stop, the indicator clears even though a sibling process is still playing. There is no incremental fix—the design assumption of one process per tab is structurally false.
MediaController already solves the cross-process aggregation problem for controllable HTMLMediaElement sources via ContentMediaAgent → IPC → MediaStatusManager. The gap is that the tab sound indicator, tab mute, and autoplay blocking still go through the old system rather than MediaController.
Two potential features are blocked on this work. Both are straightforward to build on top of a completed MediaController migration; neither has a reasonable home in the current architecture.
- The AudioSession API (W3C spec) requires a parent-process authority over per-tab audio state to handle audio competition and interruption.
- The Global Media Controller (show and control all audible tabs from one UI surface) requires a cross-tab registry of
MediaControllerinstances.
