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

[bug] Unable to start service TrackPlayer from background #222

Open
sampie777 opened this issue Jan 24, 2024 · 4 comments
Open

[bug] Unable to start service TrackPlayer from background #222

sampie777 opened this issue Jan 24, 2024 · 4 comments

Comments

@sampie777
Copy link
Owner

sampie777 commented Jan 24, 2024

View details in Rollbar: https://app.rollbar.com/a/sa.jansen1/fix/item/hymnbook/236


android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service nl.sajansen.hymnbook2/com.doublesymmetry.trackplayer.service.MusicService
  android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
  android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:50)
  android.os.Parcel.readParcelableInternal (Parcel.java:4882)
  android.os.Parcel.readParcelable (Parcel.java:4864)
  android.os.Parcel.createExceptionOrNull (Parcel.java:3064)
  android.os.Parcel.createException (Parcel.java:3053)
  android.os.Parcel.readException (Parcel.java:3036)
  android.os.Parcel.readException (Parcel.java:2978)
  android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:7214)
  android.app.Service.startForeground (Service.java:775)
  com.doublesymmetry.trackplayer.service.MusicService.startAndStopEmptyNotificationToAvoidANR (MusicService.kt:123)
  com.doublesymmetry.trackplayer.service.MusicService.onStartCommand (MusicService.kt:98)
  android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5268)
  android.app.ActivityThread.-$$Nest$mhandleServiceArgs (Unknown source)
  android.app.ActivityThread$H.handleMessage (ActivityThread.java:2531)
  android.os.Handler.dispatchMessage (Handler.java:106)
  android.os.Looper.loopOnce (Looper.java:230)
  android.os.Looper.loop (Looper.java:319)
  android.app.ActivityThread.main (ActivityThread.java:8893)
  java.lang.reflect.Method.invoke (Method.java:-2)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:608)
  com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)
java.lang.RuntimeException: Unable to start service com.doublesymmetry.trackplayer.service.MusicService@7af617a with null: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service nl.sajansen.hymnbook2/com.doublesymmetry.trackplayer.service.MusicService
  android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5286)
  android.app.ActivityThread.-$$Nest$mhandleServiceArgs (Unknown source)
  android.app.ActivityThread$H.handleMessage (ActivityThread.java:2531)
  android.os.Handler.dispatchMessage (Handler.java:106)
  android.os.Looper.loopOnce (Looper.java:230)
  android.os.Looper.loop (Looper.java:319)
  android.app.ActivityThread.main (ActivityThread.java:8893)
  java.lang.reflect.Method.invoke (Method.java:-2)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:608)
  com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)

Another stack trace:
View details in Rollbar: https://app.rollbar.com/a/sa.jansen1/fix/item/hymnbook/238


android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service nl.sajansen.hymnbook2/com.doublesymmetry.trackplayer.service.MusicService
  android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
  android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:50)
  android.os.Parcel.readParcelableInternal (Parcel.java:4787)
  android.os.Parcel.readParcelable (Parcel.java:4755)
  android.os.Parcel.createExceptionOrNull (Parcel.java:3018)
  android.os.Parcel.createException (Parcel.java:3007)
  android.os.Parcel.readException (Parcel.java:2990)
  android.os.Parcel.readException (Parcel.java:2932)
  android.app.IActivityManager$Stub$Proxy.startService (IActivityManager.java:6214)
  android.app.ContextImpl.startServiceCommon (ContextImpl.java:1967)
  android.app.ContextImpl.startForegroundService (ContextImpl.java:1933)
  android.content.ContextWrapper.startForegroundService (ContextWrapper.java:839)
  android.content.ContextWrapper.startForegroundService (ContextWrapper.java:839)
  com.doublesymmetry.trackplayer.module.MusicModule.setupPlayer (MusicModule.kt:239)
  java.lang.reflect.Method.invoke (Method.java:-2)
  com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
  com.facebook.jni.NativeRunnable.run (NativeRunnable.java:-2)
  android.os.Handler.handleCallback (Handler.java:942)
  android.os.Handler.dispatchMessage (Handler.java:99)
  com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  android.os.Looper.loopOnce (Looper.java:226)
  android.os.Looper.loop (Looper.java:313)
  com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
  java.lang.Thread.run (Thread.java:1012)

Possible solution:
doublesymmetry/react-native-track-player#1986 (comment)

@sampie777 sampie777 moved this to 🆕 New in Hymnbook Jan 24, 2024
@sampie777 sampie777 changed the title java.lang.RuntimeException: Unable to start service com.doublesymmetry.trackplayer.service.MusicService@9372982 with null: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: ser [bug] Unable to start service TrackPlayer from background Jan 24, 2024
@bradfloodx
Copy link

I'm also getting this error a lot in PROD on latest RNTP

@sampie777
Copy link
Owner Author

Appears to only happen on an Android SM-A235F device. Android 13 & 14.

@sampie777 sampie777 moved this from 🆕 New to 📋 Backlog in Hymnbook Feb 13, 2024
@sampie777 sampie777 moved this from 📋 Backlog to 🔖 Now in Hymnbook Mar 11, 2024
@sampie777
Copy link
Owner Author

The proposed solution is for an older version of react-native-track-player. 4.0.1 already has this solution implemented (https://github.com/doublesymmetry/react-native-track-player/blob/9aded62a405e75b0940d3556e1517447363f5153/android/src/main/java/com/doublesymmetry/trackplayer/service/MusicService.kt#L103)

I've posted a comment to one of the open issues: doublesymmetry/react-native-track-player#2244 (comment)

So now we wait until someone finds a fix.

@sampie777 sampie777 moved this from 🔖 Now to On hold in Hymnbook Mar 11, 2024
@sampie777
Copy link
Owner Author

Applied fix from doublesymmetry/react-native-track-player#2244 (comment) in commit 5dfc0f0. Let's see how that goes.

@sampie777 sampie777 moved this from On hold to ✅ Done in Hymnbook May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants