Environment
- RNTP: 5.6.0
- Expo SDK: 54
- React Native: 0.81.5
- React: 19.1.0
- Android targetSdkVersion: 36
- Android versions affected: Android 12+ (reported through Crashlytics)
Description
We're seeing recurring crashes in production caused by:
android.app.BackgroundServiceStartNotAllowedException
The exception is thrown while RNTP emits playback-related events from native code.
The crash does not occur during player setup or when explicitly calling play(), pause(), stop() or clear() from our application code.
Instead, it occurs while RNTP internally emits playback events after the application has already been backgrounded.
Crash paths
We've observed two different native paths leading to the exact same exception.
Path 1
TrackPlayerModule.onPlaybackStateChanged()
↓
ReactApplicationContextExtKt.emitEvent()
↓
Context.startService()
↓
TrackPlayerTaskService
↓
BackgroundServiceStartNotAllowedException
Path 2
TrackPlayerPlaybackService.onProgressSyncTick()
↓
ReactApplicationContextExtKt.emitEvent()
↓
Context.startService()
↓
TrackPlayerTaskService
↓
BackgroundServiceStartNotAllowedException
The second path suggests the crash can also occur during RNTP's progress synchronization.
What we've already investigated
We spent several days investigating this before opening this issue.
Things we've already ruled out:
- component lifecycle
- duplicate player initialization
- explicit calls to
TrackPlayer.clear()
- explicit calls to
TrackPlayer.stop()
- player setup timing
- JS handling mode (
handling: 'js' was removed)
The application now uses:
TrackPlayer.setCommands({
capabilities: [PlayerCommand.PlayPause],
});
instead of
TrackPlayer.setCommands({
capabilities: [PlayerCommand.PlayPause],
handling: "js",
});
The crashes continue to occur after this change.
Playback configuration
Player setup:
TrackPlayer.setupPlayer({
contentType: "speech",
progressSync: {
intervalSeconds: 5,
},
android: {
wakeMode: "network",
taskRemovedBehavior: "stop",
},
});
We also register:
- PlaybackStateChanged
- PlaybackProgressUpdated
- IsPlayingChanged
to keep an application timer synchronized.
However, according to the stack traces, the crash happens before our application handlers execute, while RNTP is still inside:
ReactApplicationContextExtKt.emitEvent()
Production behavior
The issue is difficult to reproduce manually.
Crashlytics shows users experiencing this while the application is already in the background.
Many affected users listen to long sleep music sessions, so the application often remains backgrounded for several hours.
However, one captured crash occurred after only about one minute in the background, so the issue does not appear to depend exclusively on long playback sessions.
We also received at least one user report of playback stopping unexpectedly during a meditation.
Unfortunately we cannot directly correlate that report with one of the Crashlytics sessions.
Stack traces
We'll attach four sanitized Crashlytics reports.
Three reports originate from:
TrackPlayerModule.onPlaybackStateChanged()
One originates from:
TrackPlayerPlaybackService.onProgressSyncTick()
Both end with the same:
BackgroundServiceStartNotAllowedException
Question
Is this a known issue on Android 12+ / Android 13+ / Android 14+?
Specifically:
-
Is ReactApplicationContextExtKt.emitEvent() expected to start TrackPlayerTaskService while the app is already backgrounded?
-
Is there a recommended configuration that avoids this?
-
Has this already been fixed in a newer version?
-
Should applications avoid using PlaybackProgressUpdated together with progressSync on Android?
We're happy to test patches or provide additional information if needed.
Thanks!
crash_1_sanitized.txt
crash_2_sanitized.txt
crash_3_sanitized.txt
crash_4_sanitized.txt
Environment
Description
We're seeing recurring crashes in production caused by:
The exception is thrown while RNTP emits playback-related events from native code.
The crash does not occur during player setup or when explicitly calling play(), pause(), stop() or clear() from our application code.
Instead, it occurs while RNTP internally emits playback events after the application has already been backgrounded.
Crash paths
We've observed two different native paths leading to the exact same exception.
Path 1
Path 2
The second path suggests the crash can also occur during RNTP's progress synchronization.
What we've already investigated
We spent several days investigating this before opening this issue.
Things we've already ruled out:
TrackPlayer.clear()TrackPlayer.stop()handling: 'js'was removed)The application now uses:
instead of
The crashes continue to occur after this change.
Playback configuration
Player setup:
We also register:
to keep an application timer synchronized.
However, according to the stack traces, the crash happens before our application handlers execute, while RNTP is still inside:
Production behavior
The issue is difficult to reproduce manually.
Crashlytics shows users experiencing this while the application is already in the background.
Many affected users listen to long sleep music sessions, so the application often remains backgrounded for several hours.
However, one captured crash occurred after only about one minute in the background, so the issue does not appear to depend exclusively on long playback sessions.
We also received at least one user report of playback stopping unexpectedly during a meditation.
Unfortunately we cannot directly correlate that report with one of the Crashlytics sessions.
Stack traces
We'll attach four sanitized Crashlytics reports.
Three reports originate from:
One originates from:
Both end with the same:
Question
Is this a known issue on Android 12+ / Android 13+ / Android 14+?
Specifically:
Is
ReactApplicationContextExtKt.emitEvent()expected to startTrackPlayerTaskServicewhile the app is already backgrounded?Is there a recommended configuration that avoids this?
Has this already been fixed in a newer version?
Should applications avoid using
PlaybackProgressUpdatedtogether withprogressSyncon Android?We're happy to test patches or provide additional information if needed.
Thanks!
crash_1_sanitized.txt
crash_2_sanitized.txt
crash_3_sanitized.txt
crash_4_sanitized.txt