Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audiofocus Broken after AUDIOFOCUS_LOSS_TRANSIENT #7182

Closed
PaulWoitaschek opened this issue Apr 3, 2020 · 8 comments
Closed

Audiofocus Broken after AUDIOFOCUS_LOSS_TRANSIENT #7182

PaulWoitaschek opened this issue Apr 3, 2020 · 8 comments
Assignees
Labels

Comments

@PaulWoitaschek
Copy link

On ExoPlayer 2.11.3, audiofocus is broken when receiving a AUDIOFOCUS_LOSS_TRANSIENT.
In that case the AudioFocusManager receives no furhter events and exoplayer is unable to play any longer.
This can be reproduced using the following steps:

Now after the call the UI still shows playing but isn't. This can only be fixed by using another media player and let it request audio focus.

@PaulWoitaschek
Copy link
Author

It would be great if a fix went already into the next release as this bug renders exoplayer completely unusable.

@ojw28
Copy link
Contributor

ojw28 commented Apr 3, 2020

I can't reproduce this using normal phone calls (which should be the same in terms of how audio focus works). Are you sure this isn't a Due issue?

@ojw28
Copy link
Contributor

ojw28 commented Apr 3, 2020

I think it's a Duo bug where they should be releasing audio focus but aren't. If you kill the Duo process after the call then playback does resume.

That said, the state ExoPlayer ends up in is definitely non-ideal (it's waiting indefinitely for Duo to release audio focus, which it's not doing). If the user toggles to pause and back to play, we should be more aggressive at trying to take audio focus back.

this bug renders exoplayer completely unusable

Has it also been "completely unusable" for the past 18 months, because the current behaviour appears to have existed ever since we added audio focus management in 2.9.0 :)...

@ojw28 ojw28 self-assigned this Apr 3, 2020
@ojw28 ojw28 removed the needs triage label Apr 3, 2020
@PaulWoitaschek
Copy link
Author

Ah very interesting.

In my testing it was working with UAMP and exoplayer 2.10.0
But it only appeared to be working in 2.10.0 because the time displayed in the player was advancing, but there is no actual audio being played.

So there definitely is a behavior change anywhere. Maybe introduced to the change with the event handler introduced between these releases.

If the user toggles to pause and back to play, we should be more aggressive at trying to take audio focus back.

Yes that's a very good idea.
I still think there is something different in how exoplayer handles this. Because when you use Google Music and then receive a duo call, after the call the player is in the paused state. And when you press play the playback continues.
When you use my appication (voice), after the call the player is still shown as playing yet it's not advancing. I wonder where that comes from.

@ojw28
Copy link
Contributor

ojw28 commented Apr 5, 2020

I reported the Duo issue to the relevant team [Internal ref: 153249585]

ojw28 added a commit that referenced this issue Apr 7, 2020
This avoids cases where audio focus is never successfully acquired
because another app is holding on to transient audio focus indefinitely.

Issue: #7182
PiperOrigin-RevId: 305108528
ojw28 added a commit that referenced this issue Apr 7, 2020
If we're in the ducked state and updateAudioFocus is called with a
new state for which focus is no longer required, we should restore
the player back to full volume.

Issue: #7182
PiperOrigin-RevId: 305232155
@ojw28
Copy link
Contributor

ojw28 commented Apr 7, 2020

User recovery should be possible with the first of the two patches referenced above. The second patch fixes an additional edge case we discovered, but is unlikely to occur in practice.

@ojw28 ojw28 closed this as completed Apr 7, 2020
ojw28 added a commit that referenced this issue Apr 7, 2020
This avoids cases where audio focus is never successfully acquired
because another app is holding on to transient audio focus indefinitely.

Issue: #7182
PiperOrigin-RevId: 305108528
ojw28 added a commit that referenced this issue Apr 7, 2020
If we're in the ducked state and updateAudioFocus is called with a
new state for which focus is no longer required, we should restore
the player back to full volume.

Issue: #7182
PiperOrigin-RevId: 305232155
@ojw28
Copy link
Contributor

ojw28 commented Apr 7, 2020

Please verify with dev-v2-r2.11.4 if possible, prior to us cutting the release. The cherry-pick wasn't totally straightforward, so verification would be appreciated.

@PaulWoitaschek
Copy link
Author

I couldn't verify it before the release.
However it works fine, thanks a lot!

@google google locked and limited conversation to collaborators Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants