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

Audio playback interruption on Android devices #1363

Open
yelkamel opened this issue Nov 14, 2024 · 8 comments
Open

Audio playback interruption on Android devices #1363

yelkamel opened this issue Nov 14, 2024 · 8 comments
Assignees
Labels
1 backlog bug Something isn't working

Comments

@yelkamel
Copy link

Which API doesn't behave as documented, and how does it misbehave?
The just_audio package for Flutter is not behaving as expected on Android devices. Specifically, the audio playback is unexpectedly stopping for some users, even though the progress bar continues to move. This behavior is not documented and appears to be a bug.

Minimal reproduction project
Unfortunately, we cannot provide a minimal reproduction project at this time as the issue is not consistently reproducible in development or release environments. It only occurs for some users in production.

To Reproduce (i.e. user steps, not code)
Steps to reproduce the behavior:

  1. Start playing an audio file (meditation or sleep music) using the just_audio package
  2. Let the audio play for an indeterminate amount of time
  3. Audio playback stops unexpectedly, but the progress bar continues to move
  4. Attempting to restart playback results in the progress bar moving without audio

Error messages
We don't have any error in crashanalytics.

Expected behavior
The audio should play continuously without interruption for the entire duration of the audio file.

Screenshots
No screenshots are available at this time as the issue occurs randomly for users.

Desktop (please complete the following information):
N/A - This issue is specific to Android devices.

Smartphone (please complete the following information):

  • Device: Various Android devices
  • OS: Various Android versions

Flutter SDK version

  • Flutter version: (sdk: '>=3.0.0 <4.0.0')
  • just_audio: ^0.9.35
  • audio_service: ^0.18.15

Additional context

  • This issue only affects some Android users and is not reproducible in our development or release environments.
  • The problem started occurring recently, but the app was working fine before.
  • We've verified it's not a memory leak issue.
  • Affected users seem to have sufficient RAM available (based on crash analytics data).
  • No crashes are reported in our crash analytics related to this issue.
  • The problem occurs for both short and long audio files.
  • The issue persists whether the screen is locked or unlocked.
  • It happens both when the app is in the foreground and background.
  • Some users report that restarting the audio from the beginning after the interruption allows it to play normally.

We're seeking assistance in identifying potential causes or additional debugging steps we can take to resolve this issue.

@yelkamel yelkamel added 1 backlog bug Something isn't working labels Nov 14, 2024
@Chaphasilor
Copy link

We are seeing similar reports for Finamp. Related issue: jmshrv/finamp#956
Users report playback stopping a few seconds or minutes after leaving the app or locking the screen (which could be exactly the buffer duration).

@srihariash999
Copy link

This happened to me a few times recently and two times out of those the audio cut off suspiciously soon after I recieved a notification. Not sure if that really is something or just a coincidence but leaving this comment here anyway in case somebody else also observes it.

@mklepaczko
Copy link

Same here, player is not stopped, progress continues but there is no sound. Some users reported it happens after 5 - 6 mins. Perhaps a new energy saving feature on Android.

@srihariash999
Copy link

@mklepaczko Now that you mentioned it, I am only seeing this on my pixel 8 after android 15 update and latest patch and the timing almost seems correct too.

Can you mention which android version you are seeing this issue in? Also it'll be great if someone can test and verify if this issue is present for older package version or android versions or combo of both.

@ryanheise
Copy link
Owner

Is anyone able to submit a minimal reproduction project to allow me to investigate?

I have a Pixel 8, so I ought to be able to reproduce it if someone can provide a reproduction project. Before you do so, of course please make sure your issue either happens in the foreground, or alternatively if this is a background thing, ensure that background audio is properly configured to keep it alive.

@marianperca
Copy link

Hi, I had the ~ same issue, streaming stopped when the device display was closed and nothing was shown in the notification tray. The fix for me was adding the new foreground service type declaration required starting with android 14: https://developer.android.com/about/versions/14/changes/fgs-types-required

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

@Chaphasilor
Copy link

@marianperca good catch! We only have the issue on the stable version, not the beta version, and there really is a difference in permissions. Didn't see that in previous diffs since the branches have diverged a lot in our case.
We'll push a fix with the new permissions soon and report back!

@umbertogrimaldi
Copy link

@marianperca Unfortunately for me it's not the solution. I have these 2 permissions in the manifest implemented since 10 months. My attempt to fix this was to set androidStopForegroundOnPause to false in the AudioService configuration, but I'm not sure if that's the solution or not.

Screenshot 2024-12-27 at 09 34 42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants