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

The service will be killed several minutes after pausing on background #83

Closed
itog opened this issue Sep 20, 2019 · 2 comments
Closed
Assignees

Comments

@itog
Copy link
Contributor

itog commented Sep 20, 2019

Describe the bug
When a click a pause button, notification should be remain on the system tray.
But several minutes after calling the pause, the service will be killed and the notification icon will be disappeared.

Once this happened, it is not possible to restart the service.

Minimal reproduction project
This issue is reproducible with the example app.

To Reproduce
Steps to reproduce the behavior:

  1. Launch the example app
  2. Click either 'AudioPlayer' or 'TextToSpeech' then click 'play' button
  3. Click 'pause' button
  4. Click home button for the app to go background
  5. Wait for a several minutes
  6. The notification icon will be disappered. You can see the log
W ActivityManager: Stopping service due to app idle: u0a130 -2m11s986ms com.ryanheise.audioserviceexample/com.ryanheise.audioservice.AudioService
  1. Launch the app again. Then you will find that clicking neither 'AudioPlayer' nor 'TextToSpeed' works

Expected behavior
The service should keep on working while pausing on background.

@ryanheise ryanheise self-assigned this Sep 20, 2019
@ryanheise
Copy link
Owner

This is a good find. Although it will need to be weighed against the requirements from #72 and #74 . Ultimately, the behaviour of the plugin on pause will need to be configurable by options. One option could be to keep the stopForeground call but to listen for when the service is destroyed and handle that case appropriately.

One other thing I've been meaning to reconsider is whether or not to keep the background isolate running on pause. There are a couple of options here:

  1. The background isolate runs exactly during the time that the service runs. And for those users who want pause to stop the service, that will also shut down the background isolate. The downside is that firing up the background isolate has a lot of overhead so playing and pausing will not be as fast as the user might like. For users who are happy for the service to keep running during pause (like myself), you simply keep the background isolate running, and then of course play and pause will be very snappy for the user since you don't need to respawn a new background isolate.
  2. The background isolate is always shut down on pause, but use an option to allow the service to keep running. In this case, we can let the app release all resources but also allow the Android platform to bring our app back to life it the user uses a media control to resume playback, and that will trigger the background isolate to start up again. Of course, the overheads won't give you great response times in play/pause.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants