Atmosphere
just_audio: ^0.9.42
riverpod: ^2.6.1
flutter_riverpod: ^2.4.10
riverpod_annotation: ^2.3.4
Dev:
riverpod_generator: ^2.3.11
Platform: iOS
Flutter model: 3.27.2
Gadget: iPhone 12 Professional Max - 18.1.1
Supplier Setup
@Riverpod(keepAlive: true)
AudioPlayer audioPlayer(AudioPlayerRef ref) {
remaining audioPlayer = AudioPlayer(
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0',
);
ref.onDispose(() async => await audioPlayer.dispose());
return audioPlayer;
}
Steps to Reproduce
- Open app and play audio efficiently
- Press residence button to place app in background (not killing the app)
- Use different apps, lock display screen, depart machine idle
- After a number of hours (e.g. in a single day)
- Return to app from background
- Attempt to play audio
Present Habits
- Audio will not play after returning to app
- No error messages
- Solely mounted by utterly killing and reopening the app
Anticipated Habits
- Audio ought to proceed to work when returning to app from background
- Since supplier is marked with
keepAlive: true
, the occasion ought to persist
Speculation
There are two potential eventualities:
-
Riverpod Supplier Challenge:
- Regardless of
keepAlive: true
, the supplier is likely to be disposing the occasion - Nonetheless, this appears unlikely as Riverpod documentation states keepAlive suppliers ought to solely dispose when app is killed
- Regardless of
-
just_audio Challenge:
- The AudioPlayer occasion is likely to be self-disposing or releasing sources after lengthy intervals in background
- The supplier stays alive however holds an invalid AudioPlayer occasion
Questions
- Is it potential for just_audio to launch sources routinely when app is in background for lengthy intervals?
- Are there any identified points with keepAlive suppliers in comparable eventualities?
- What can be the really useful strategy to deal with audio playback that should survive lengthy background intervals?
Extra Context
- Challenge solely happens after prolonged background intervals (hours)
- Quick background intervals (half-hour) work tremendous