Open Bug 1766545 Opened 2 years ago Updated 1 year ago

All app audio cuts out on Oculus Quest when a GeckoSession is closed or a MediaSession is paused or deactivated

Categories

(GeckoView :: Media, defect, P3)

Firefox 99
Unspecified
All
defect

Tracking

(Not tracked)

People

(Reporter: nate, Unassigned)

Details

Attachments

(1 file)

Steps to reproduce:

Hello! I've tried many approaches to try to resolve this issue (mentioned later), so I'm reaching out to ask if you have any ideas for other approaches I can pursue or if you can help.

The following attachments reproduce the issue:
• GeckoViewOculusAudioRepro: A minimal Android Studio project that reproduces the issue.
• demo.apk: A build of the repro project
• demo.mp4: A video of running the demo app on Oculus Quest.

On Oculus Quest headset, run an app that:

  1. Plays audio with an Android MediaPlayer instance (or any other approach).
  2. Instantiates a GeckoSession.
  3. Close the GeckoSession with GeckoSession.close().

Actual results:

When the GeckoSession is closed, all app audio (the audio from the Android MediaPlayer) cuts out. This also occurs if a web page plays audio and then the web audio is either paused or stopped (i.e. the Gecko MediaSession is paused or deactivated).

Expected results:

Closing the GeckoSession shouldn't cause the app's audio to cut out, and neither should pausing or stopping audio in a web page.

Additional context:
• I develop a popular library for embedding GeckoView in Unity, and this is a common issue that developers encounter. Currently, there are 41 devs on my waitlist for this issue.
• I opened a support issue with Oculus regarding this issue, but they recently closed it without providing any information or help.
• Based on my research, it seems that Gecko's cubeb audio library may be doing something that isn't working correctly on the Quest.
• Back when my Unity library used GeckoView 82, this issue still existed, but I found a workaround to prevent it from occurring was to create an unused GeckoSession in the background that the app always kept open. However, when I upgraded the library from GeckoView 82 to 95, I discovered that the workaround no longer worked.
• Now, the only way I've found to get the app's audio to be audible again after the issue occurs is to load a page in a GeckoSession that plays audio. When I do this, the app's background audio becomes audible again. The position where the app audio resumes indicates that it had continued to play silently in the background but was inaudible (i.e. the audio clip had not paused).

Here are some of the things I tried to resolve the issue but that made no impact:

  • Set the following Gecko preferences (each separately in its own test):
    • media.cubeb.logging_level: 'verbose'
    • media.cubeb.output_voice_routing: false
    • media.cubeb.sandbox: false
    • media.audioFocus.management: true
    • media.cubeb.sandbox_v2: true
  • Requested audio focus at the start of the app and attached a focus listener (like this: https://stackoverflow.com/a/32321459/4104582).
  • Tried to detect the issue through the Android MediaPlayer's events.
    • MediaPlayer.OnErrorListener isn't invoked
    • MediaPlayer.OnRoutingChanged is invoked, but only when playback starts and not when audio cuts out
  • Observed that after audio cuts out, MediaPlayer.isPlaying() still returns true, and calling MediaPlayer.start() has no effect.
  • Seached for other instances of this issue on the web (no luck).
  • Removed Exoplayer from GeckoView.
  • Called audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, AudioManager.FLAG_SHOW_UI);

Links to the other attachments (too large to attach):

Component: General → Audio/Video: cubeb
Product: GeckoView → Core

Agi, do you have any idea what's up, or any lead for me to start tracing? I don't have a Quest, I have no idea how to start with this but it looks real annoying.

Flags: needinfo?(agi)
Status: UNCONFIRMED → NEW
Component: Audio/Video: cubeb → General
Ever confirmed: true
Product: Core → GeckoView

I have a Quest at home, I can try to reproduce, keeping the ni so I don't forget.

(In reply to Agi Sferro | :agi | [slow ni? rn sorry] | ⏰ PST | he/him from comment #3)

I have a Quest at home, I can try to reproduce, keeping the ni so I don't forget.

Thank you!

Severity: -- → S3
Priority: -- → P3

OK So I can reproduce this, and I tried to upgrade on the latest nightly and the behavior is pretty much the same. Paul, do you know of any extra logging that I can enable that might help us here? Do we ever mute all audio for some reason in Gecko?

Flags: needinfo?(agi) → needinfo?(padenot)

I don't think we do.

You can check with logging (MOZ_LOG=cubeb:5) or the Firefox Profiler (media preset) whether we're running audio callbacks. Look for (respectively) a large amount of similar lines taking about output buffers, or lots of periodic markers in a thread called NativeAudioCallback.

I suspect this to be an Audio Focus 0 issue in GV, we could be tracing those calls.

Flags: needinfo?(padenot)

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

Component: General → Media

We're hitting hard this in Wolvic. There are several bugs that somehow suggest that all the sessions share some common state of media playback, for example this scenario

  1. Open a tab and play some video (in YouTube for example)
  2. Open another tab that plays some audio in the background
  3. Close any of the two previous tabs -> Audio stops
  4. Open a new tab with some page with no media -> Audio resumes in the tab that was not closed in 3

Hi, we are experience this same issue. Are there any updates? We would love to upgrade to the latest Gecko version, but we are stuck due to this issue.

I am having the same issue, and even lose audio on pages without any audio playback (such as google searches).

Are there any updates on this? Thank you for the information

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: