Open Bug 1682579 Opened 5 years ago Updated 3 years ago

Web Audio API is not working in background

Categories

(GeckoView :: Media, defect, P3)

Unspecified
All
defect

Tracking

(Not tracked)

People

(Reporter: royang, Unassigned)

Details

(Whiteboard: [geckoview:2023?])

Steps to reproduce

  1. open mynoise.net and select any sound generator
  2. try to switch tab or switch application

Expected behavior
Background audio still plays.

Actual behavior
Background audio stops.

Additional information
The site uses Web Audio API.

This is an issue created for https://github.com/mozilla-mobile/fenix/issues/15417. With the new MediaSession API this is reproducible.

@alwu: we don't seem to get any MediaController events on this page, do you see why?

Flags: needinfo?(alwu)

MediaController only controls media element, as MediaSession API doesn't support web audio.

That might be related with nsGlobalWindowInner::Suspend(), you can check if GeckoView calls that method to pause web audio when GeckoView changes tab's visibility.

What I guess is that, as GeckoView suspends tabs very aggressively, which eventually leads to suspend the inner window that would suspend the web audio as well. So we need to consider if a page is running web audio API as well when determining suspending tabs.

Flags: needinfo?(alwu)

Let's split this in two bugs and figure out priority.

Flags: needinfo?(esawin)

Before splitting this bug up, I propose to look into a way to connect web audio playback state events with GV's Media Session API.

As long as the app is not aware of the media playback, it can not display a media control notification.
Without the media notification, the app may (and will) be killed once it's in background. I don't think we have to differentiate between a tab vs. the whole app being in background, for this reason.

In summary: we either support web audio events through the Media Session API or suspending playback when in background (as is the case) is the correct behavior.

Flags: needinfo?(esawin)
Severity: -- → S3
Priority: -- → P2
Priority: P2 → P3
Whiteboard: [geckoview:2023?]

Makoto says this bug is needed for MediaSession API.

Moving some media bugs to the new GeckoView::Media component.

Component: General → Media
You need to log in before you can comment on or make changes to this bug.