Closed Bug 1506957 Opened 6 years ago Closed 3 years ago

Audio from video still plays after closing GeckoView_example

Categories

(GeckoView :: GeckoViewExample, defect, P2)

Unspecified
Android

Tracking

(geckoview64 wontfix, geckoview65 wontfix, geckoview66 wontfix, firefox63 wontfix, firefox64 wontfix, firefox65 wontfix, firefox66 wontfix, firefox67 wontfix, firefox68 affected)

RESOLVED INVALID
Tracking Status
geckoview64 --- wontfix
geckoview65 --- wontfix
geckoview66 --- wontfix
firefox63 --- wontfix
firefox64 --- wontfix
firefox65 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- affected

People

(Reporter: squib, Unassigned)

References

Details

After opening this page <https://clips.twitch.tv/PoliteSpinelessStarlingPipeHype> in GeckoView example, I left the video playing (with audio on) and closed the app via the app list. The audio continues to play, and even keeps looping back around to the beginning of the video! The only way I know of to stop this is to fully rebooting the phone (a Moto G5 in this case).

This may be related to bug 1482185...
Happens with any twitch stream. Even after closing the app. Starting another Geckoview example app and closing that, the audio keeps playing. Killing the wifi stops the audio stream but when you enable it again the stream continues so it's definitely using data in the background.
Worth noting that on Focus Nightly when I background the app or erase the page, the audio stops.
Jim, you can 'force stop' the example app. That will kill the process.

> Worth noting that on Focus Nightly when I background the app or erase the page, the audio stops.

Focus sets something that causes us to pause media when backgrounded. We could set that for the example app too, but it's not the default.
We talked about this a little bit on Slack, and I think it's reasonable to expect us to close any sessions that are attached to a GeckoView instance when the containing task for that activity is removed (which is what happens when you swipe in the app switcher). However, I'm not really sure if it's possible for GV to know if this is the case. The only notification you get when an app is swiped from the recents list is Service.onTaskRemoved[0]. It gives you the Intent that started the task, but no more. It's not clear to me at all if we can deduce from there which sessions should be closed.

[0] https://developer.android.com/reference/android/app/Service#onTaskRemoved(android.content.Intent)
And of course to receive even that notification, you need to have a service running continuously in the first place. I'm not really a fan of creating a new service just for that when you didn't need one before, because even if it's not a foreground service, it can still mess around with Android's memory management and unnecessarily keep us alive under memory pressure, even though we don't have anything important to do.
(In reply to Jan Henning [:JanH] from comment #5)
> I'm not really a fan of creating a new service
> just for that when you didn't need one before, [...]

... although as this bug was about audio playback - of course when playing back audio, you'll want to create a foreground service anyway so that Android doesn't accidentally kill you. So you could utilise *that* service's onTaskRemoved interface, at least as long as that service is running, i.e. while the app is actually playing back media, respectively as long as a corresponding notification is shown. Still wouldn't help in the general case, though...
Agi, what does WebView do? James says Chrome does not appear to use onTaskRemoved. 

Dylan has been investigating a similar issue in Fennec.
Assignee: nobody → agi
Priority: -- → P1
For easier testing (and because the performance of https://clips.twitch.tv/PoliteSpinelessStarlingPipeHype seems horrible, at least on my phone), I used a plain mp3 file. I think I could reproduce this once, but on subsequent attempts, swiping away geckoview_example stopped the audio playback as well (with multi-process enabled all the time).
64=wontfix because this bug only affects geckoview_example and thus doesn't need to block Focus 8.0.
See Also: → 1482185
Not looking at this currently.
Assignee: agi → nobody
Vicky is this something your team could investigate?
Flags: needinfo?(vchin)
I don't think there's any performance issue here, we just have some lifetime issues to figure out.
Product: Firefox for Android → GeckoView

FWIW I tried this on Fenix and I swiped away the app the audio stopped.

Flags: needinfo?(vchin)

(In reply to Vicky Chin [:vchin] from comment #15)

FWIW I tried this on Fenix and I swiped away the app the audio stopped.

We can defer this bug until after Fenix MVP. We can then determine whether this is a GV bug that has been fixed or is a bug in the geckoview_example app itself.

Summary: Audio from video still plays after closing GeckoView example → Audio from video still plays after closing GeckoView_example
Whiteboard: [geckoview:fenix:p1]

Will Bug 1537964 and Bug 1537931 have an impact here?

(In reply to csheany from comment #17)

Will Bug 1537964 and Bug 1537931 have an impact here?

Probably not. This is probably a geckoview_example-specific bug. This bug affects geckoview_example but not Fenix even though both apps use the same GeckoView version (without the BIND_IMPORTANT fix).

What about the Reference Browser?

This is not geckoview_example specific. I just reproduced this on Fenix while working on a similar bug. Audio plays even though no Fenix app is visible in the "recent apps" the only way that made it stop was to "Force Stop" the app from the App settings.

I don't think it's quite a dupe, but it's fair to say that this is closely related to the same issue in Fennec (bug 1382637).

See Also: → 1382637

I realize they are built differently which may be a factor but is GVE similar to a private tab in Fennec?

(In reply to Agi | :agi | ⏰ EST | he/him from comment #20)

This is not geckoview_example specific. I just reproduced this on Fenix while working on a similar bug. Audio plays even though no Fenix app is visible in the "recent apps" the only way that made it stop was to "Force Stop" the app from the App settings.

Adding the [geckoview:fenix:m5] whiteboard tag because it sounds ;) like we should fix this for Fenix MVP. The audio playing is annoying but might also mean that GV is still burning up power in the background.

OS: Unspecified → Android
Summary: Audio from video still plays after closing GeckoView_example → Audio from video still plays after closing Fenix or GeckoView_example
Whiteboard: [geckoview:fenix:m5]

Just wondering, is Firefox Reality affected?

James said today this bug should be fixed in the app. mozilla-mobile/fenix#1679 and mozilla-mobile/fenix#1117 are Fenix issues for Fenix's lingering audio playback, so I will morph this bug to be just about fixing geckoview_example.

Will Eugen's lifecycle bug 1544076 be helpful here?

Depends on: 1544076
Priority: P1 → P2
Summary: Audio from video still plays after closing Fenix or GeckoView_example → Audio from video still plays after closing GeckoView_example
Whiteboard: [geckoview:fenix:m5]
Rank: 45
Component: General → GeckoViewExample

We now have a much better story around this with MediaSession, so we can close this.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.