stadiamaps / ferrostar

A FOSS navigation SDK built from the ground up for the future
https://stadiamaps.github.io/ferrostar/
Other
184 stars 24 forks source link

Foreground service related crash #352

Open ianthetechie opened 2 weeks ago

ianthetechie commented 2 weeks ago

Got this interesting crash in the demo app... Nothing particularly interesting about the session. I had just started it up in the emulator and was idle (during a trip, but no inputs since location was static at the time).

2024-11-09 01:39:49.123  3755-3755  AndroidRuntime          com.stadiamaps.ferrostar.demo        E  FATAL EXCEPTION: main
                                                                                                    Process: com.stadiamaps.ferrostar.demo, PID: 3755
                                                                                                    android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{9148e2a u0 com.stadiamaps.ferrostar.demo/com.stadiamaps.ferrostar.core.service.FerrostarForegroundService}
                                                                                                        at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2104)
                                                                                                        at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2075)
                                                                                                        at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2369)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                        at android.os.Looper.loop(Looper.java:294)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                                                                                                    Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here
                                                                                                        at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1952)
                                                                                                        at android.app.ContextImpl.startForegroundService(ContextImpl.java:1906)
                                                                                                        at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:830)
                                                                                                        at com.stadiamaps.ferrostar.core.service.FerrostarForegroundServiceManager.startService(ForegroundServiceManager.kt:65)
                                                                                                        at com.stadiamaps.ferrostar.core.FerrostarCore.startNavigation(FerrostarCore.kt:228)
                                                                                                        at com.stadiamaps.ferrostar.core.FerrostarCore.startNavigation$default(FerrostarCore.kt:220)
                                                                                                        at com.stadiamaps.ferrostar.DemoNavigationSceneKt$DemoNavigationScene$4$1$1$1$1$1$1.invokeSuspend(DemoNavigationScene.kt:155)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
                                                                                                        at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
                                                                                                        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:823)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
                                                                                                        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
Archdoog commented 2 weeks ago

I got this once out of 10s of runs w/ the demo app. I haven't troubleshot it, so I'm not sure, but I'm guessing it has to do with the coroutine context the autocomplete search is running on, since that's now auto starting navigation. E.g. running start foreground from an IO thread.