Niddler can crash the whole app when screen turns off
Closed this issue · 4 comments
matejdro commented
java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.myapp/com.icapps.niddler.service.NiddlerService }: app is in background uid UidRecord{8a932cb u0a367 TRNB bg:+1m1s399ms idle change:idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1650)
at android.app.ContextImpl.startService(ContextImpl.java:1605)
at android.content.ContextWrapper.startService(ContextWrapper.java:669)
at com.icapps.niddler.core.NiddlerServiceLifeCycleWatcher.onActivityStarted(NiddlerServiceLifeCycleWatcher.java:75)
at android.app.Application.dispatchActivityStarted(Application.java:440)
at android.app.Activity.dispatchActivityStarted(Activity.java:1234)
at android.app.Activity.onStart(Activity.java:1717)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:535)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1514)
at android.app.Activity.performStart(Activity.java:7843)
at android.app.Activity.performRestart(Activity.java:7932)
at android.app.ActivityThread.handleSleeping(ActivityThread.java:4899)
at android.app.ActivityThread.access$2900(ActivityThread.java:231)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7695)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
NicolaVerbeeck commented
Do you have a reproduction scenario for this?
matejdro commented
Unfortunately bugs like these are pretty hard to reproduce. Android can decide at whim that app is now in background and cannot launch any services.
Solution is either checking for this and not starting the service if app is in background (I assume it would restart anyway when app goes back to foreground) or run Niddler in foreground.
NicolaVerbeeck commented
Will be delivered in next release. Waiting for review on PR #11
kikothemaster commented
@matejdro I reproduced it.
Run app and leave screen turned of, in about minute it will crash.