-
-
Notifications
You must be signed in to change notification settings - Fork 984
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
[Android 12+] Loading new track crashes the app after being in background for ~5 mins with locked screen #2159
Comments
https://github.com/kormocicsaba/react-native-track-player I've tested on Xiaomi Poco F3 phone, with Android 13 and the player stops after the 5. chapter/audio, with repeat mode off. If I disable the battery optimisation (inside app settings), then the player won't stop at all. |
Here are the most important logs from starting an audio until the crash happens:
|
You can force the app into Doze mode even if its plugged in with
just need to disable the repeatMode |
@takacskalman Which version of rntp are you using? |
@elliotdickison 4.0.0-rc09 But we tried with different versions and the issue happens with all of them. All the 4.0 RC versions, and the 3.X versions too. |
We should test this again after merging in the following pr: doublesymmetry/KotlinAudio#95 |
For anyone in the future that has a similar issue:
The following PR will remove the need of having to seek to start again when loading a track - for issues with dozing or the service being terminated after track ends, the grace period introduced here should help #2164 |
Going to close this one as complete with #2164 |
I don't know what has been changed in player but with latest version audio player just doesn't work properly when app is background. Tested on |
@Ggayane would you mind testing the latest nightly |
@dcvz I've tested on |
That's great to hear! Regarding the loading audio when queue ends, you'll want to configure the grace period before we set the service out of foreground: https://rntp.dev/docs/api/objects/android-options The default is 5 seconds. |
Describe the Bug
When trying to load a new track when the previous ended (via the PlaybackService callback) the app crashes. It just happens if the screen is locked and the app is in background and it only affects Android 12+ versions. Prior Android 12 it works fine without any issues, also on IOS no issues. It works with local files, just the remote ones cause the problem.
It works if we load all the tracks by calling
TrackPlayer.add([list of tracks])
but it does not work if I we callTrackPlayer.load
and switch the track from the PlaybackService's callback byTrackPlayer.load
.Our problem is that we cant add all the tracks at once, we need to add them 1 by 1 because we have custom logic for preparing a track.
Steps To Reproduce
TrackPlayer.load
methodTrackPlayer.load
)Code To Reproduce
Provided in the next section.
Replicable on Example App?
Can you replicate this bug in the React Native Track Player Example App?
It's replicable in the demo app by changing it's playlist management from queue added to track player to loading 1 track at a time and then changing the track when the actual ended. The screenshots with the chnages:
Environment Info:
Paste the results of
npx react-native info
It was tested by different developers on different platformsPaste the exact
react-native-track-player
version you are using 4.0.0-rc09 but it's the same with other versions tooReal device? Or simulator? Real device
What OS are you running? Android
How I can Help
What can you do to help resolve this? We are 3 devs building an audiobook app and this is the only thing that blocks the release, so basically we can help in anything, this is our first prio now.
Have you investigated the underlying JS or Swift/Android code causing this bug?
Can you create a Pull Request with a fix?
Logs:
The text was updated successfully, but these errors were encountered: