Audio_service: Multiple isolates

Created on 15 Dec 2019  路  5Comments  路  Source: ryanheise/audio_service

If I calling AudioService.stop() isolate created from AudioService.start(backgroundTaskEntrypoint:...) won't kill.

So, after few showing/hiding media notification we have multiple unused isolates
image

Most helpful comment

Thanks for clarifying. I had an open issue on this with the Flutter team when I first created the plugin, although it hasn't been answered yet. But I'll do some digging and see if I can figure out a solution.

All 5 comments

Can you show me your onStop implementation?

@override
  void onStop() {
    AudioServiceBackground.setState(
      controls: [],
      basicState: BasicPlaybackState.stopped,
    );
    _playPauseCompleter?.complete();
  }

_playPauseCompleter used in onStart like in your example

Correct @mrxten
This happens when running the example project.
The call stack gets piled up with multiple isolates if the audioservice is started and then stopped and repeated.
It seems that a brand new isolate is being created for every AudioService.start.
Not sure why this is happening but ideally the AudioService.stop should terminate the background isolate.
Steps to produce this bug:

  1. Run the example.
  2. Play the audioplayer science Friday podcast.
  3. Then stop the player.
  4. Again tap on audioplayer.
  5. Keep repeating the above steps to see the call stack piling up with multiple main running statements.

I have also noticed that this seems to increase the memory in both debug and profile mode.

Thanks for clarifying. I had an open issue on this with the Flutter team when I first created the plugin, although it hasn't been answered yet. But I'll do some digging and see if I can figure out a solution.

This is now fixed in 0.5.7.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Okladnoj picture Okladnoj  路  6Comments

austinbyron picture austinbyron  路  4Comments

AhmadAbdollah picture AhmadAbdollah  路  6Comments

Divyanshu133 picture Divyanshu133  路  5Comments

hemalmoradiya picture hemalmoradiya  路  4Comments