Closed harshil-gosquire closed 11 months ago
I'm getting a similar error related to startForegroundService, here's my stacktrace:
Exception java.lang.RuntimeException:
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5261)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2447)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8757)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
Caused by android.app.ForegroundServiceStartNotAllowedException:
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:4787)
at android.os.Parcel.readParcelable (Parcel.java:4755)
at android.os.Parcel.createExceptionOrNull (Parcel.java:3018)
at android.os.Parcel.createException (Parcel.java:3007)
at android.os.Parcel.readException (Parcel.java:2990)
at android.os.Parcel.readException (Parcel.java:2932)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground (IActivityManager.java:6978)
at android.app.Service.startForeground (Service.java:743)
at com.doublesymmetry.trackplayer.service.MusicService.onStartCommand (MusicService.kt:69)
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:5243)
Exact same problem here. Can't reproduce by our side but i can see in Datadog that our users are facing this issue.
Package version:
"react-native-track-player": "3.2.0"
Package initialization:
Player setup in App.jsx:
Here is the stack strace:
android.app.RemoteServiceException.ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{2d8b624 u0 com.companyname.tila/com.doublesymmetry.trackplayer.service.MusicService} android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{2d8b624 u0 com.companyname.tila/com.doublesymmetry.trackplayer.service.MusicService} at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2245) at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2216) at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2508) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8762) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1988) at android.app.ContextImpl.startForegroundService(ContextImpl.java:1933) at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:839) at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:839) at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:1091) at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:749) at androidx.media.session.MediaButtonReceiver.onReceive(MediaButtonReceiver.java:115) at android.app.ActivityThread.handleReceiver(ActivityThread.java:4894) at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2420) ... 7 more
In Datadog, none of the reported errors are being referenced as a RUM session, so i think this is only happening when the app is in background state.
Maybe it's related to this: https://github.com/doublesymmetry/react-native-track-player/issues/2159 We get the same error in background on Android 12+ and the app crashes. Check out the issue linked, we have the reproduction steps listed
It seems like mostly everyone here is on version 3.2.0 - a lot of changes happened in v4 to try to mitigate this class of issues. Please first try on those RC's - full release coming soon, then raise an issue if still present 🙏
Describe the Bug We have app live in playstore with crashlytics implemented and we are keep getting this crash on crashlytics with live users
ActivityThread.throwRemoteServiceException: android.app.ForegroundServiceDidNotStartInTimeException - Context.startForegroundService() did not then call Service.startForeground(
Full log below:
Other crashlytics stats for better understanding
Observed to be happening only on samsung devices + 50% of user are facing when app is in background state
Steps To Reproduce We are not able to reproduce at our end but live users are facing it
Code To Reproduce We are not able to reproduce at our end but live users are facing it
Replicable on Example App? We are not able to reproduce at our end but live users are facing it
Environment Info:
"react-native-track-player": "^3.2.0",
Real device? Or simulator?
What OS are you running?
How I can Help What can you do to help resolve this? We have tried solutions from existing similar issues on here github but still crash log pops up with same error, Please let us know what we can do to resolve this crash.