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

fix(android): app crash in the background when the notification of th… #2286

Closed

Conversation

kyo-torstar
Copy link

Describe the Bug
There are lots of reports about the crash log

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)

Steps To Reproduce

  1. start the app with the library initialized
  2. put the app to background
  3. go to settings of the app and turn the notification off
  4. wait for 5-10 seconds
  5. the app crashes in the background

Related Issues
it should fix the issue #2244

@rafaelDevloft
Copy link

Any news on this? 🙏

@humbroll
Copy link

humbroll commented Jun 6, 2024

has anyone tried to patch this PR?

@andordavoti
Copy link

andordavoti commented Jun 22, 2024

Having the same issue, any plans to merge this soon @dcvz?

@Gregoirevda
Copy link

Is this also supposed to be executed when no audio is playing?

@andordavoti
Copy link

I rolled this out to production a couple days ago, seems to have tamed the issue a bit, but got one crash event in Crashlytics still:

Fatal Exception: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service rhyme.dictionary.mobileapp/com.doublesymmetry.trackplayer.service.MusicService
       at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
       at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
       at android.os.Parcel.readParcelableInternal(Parcel.java:4833)
       at android.os.Parcel.readParcelable(Parcel.java:4795)
       at android.os.Parcel.createExceptionOrNull(Parcel.java:3023)
       at android.os.Parcel.createException(Parcel.java:3012)
       at android.os.Parcel.readException(Parcel.java:2995)
       at android.os.Parcel.readException(Parcel.java:2937)
       at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:5945)
       at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1914)
       at android.app.ContextImpl.startForegroundService(ContextImpl.java:1890)
       at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:822)
       at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:822)
       at com.horcrux.svg.TSpanView$$ExternalSyntheticApiModelOutline0.m()
       at com.doublesymmetry.trackplayer.module.MusicModule.setupPlayer(MusicModule.kt:239)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:146)
       at com.facebook.jni.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:984)
       at android.os.Handler.dispatchMessage(Handler.java:104)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
       at android.os.Looper.loopOnce(Looper.java:238)
       at android.os.Looper.loop(Looper.java:357)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:233)
       at java.lang.Thread.run(Thread.java:1012)

ngort01 pushed a commit to ngort01/react-native-track-player that referenced this pull request Aug 12, 2024
Copy link
Contributor

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 13, 2024
Copy link
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants