Android app crashes immediately due to certain phone having some App wakeup blocking feature

Steps to reproduce

  1. Having an Android phone that have such App Blocking feature. This kind of App blocking feature usually blocking app chaining startup for multiple other Apps. My phone is Uniheertz Titan 2, this kind of feature also presents in many other MTK SoC based phones.
  2. Install Obsidian from Google Play store.
  3. Open Obsidian and see it crashes immediately.

Did you follow the troubleshooting guide? [Y/N]

Yes.

Expected result

Obsidian startups normally.

Actual result

It just crashes.

Environment

Phone: Unihertz Titan 2

AppBlocker feature enabled and in default state.


Additional information

I have digged a little deeper and found the App Blocker is the reason. Here is the logcat related to the crash:


11-30 23:22:29.202 20536 20536 W WindowOnBackDispatcher: OnBackInvokedCallback is not enabled for the application.
11-30 23:22:29.202 20536 20536 W WindowOnBackDispatcher: Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
11-30 23:22:29.204  1584  3747 V Appblock: 应用限制--阻止关联启动, caller: md.obsidian, receiver: org.mozilla.firefox, Component: ComponentInfo{org.mozilla.firefox/org.mozilla.fenix.customtabs.CustomTabsService}
11-30 23:22:29.204  1584  3747 I IntentFirewall: IntentFirewall : End >>>>> block=true originBlock=false
11-30 23:22:29.204 20569 20596 I cr_LibraryLoader: Successfully loaded native library
11-30 23:22:29.205 20536 20536 E TransactionExecutor: Failed to execute the transaction: tId:2140026474 ClientTransaction{
11-30 23:22:29.205 20536 20536 E TransactionExecutor: tId:2140026474   transactionItems=[
11-30 23:22:29.205 20536 20536 E TransactionExecutor: tId:2140026474     LaunchActivityItem{activityToken=android.os.BinderProxy@41a7fc5,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 pkg=md.obsidian cmp=md.obsidian/.MainActivity bnds=[700,532][898,765] (has extras) },ident=119577058,info=ActivityInfo{7342a5d md.obsidian.MainActivity},curConfig={1.1 460mcc11mnc [zh_CN_#Hans] ldltr sw574dp w574dp h576dp 400dpi nrml port night finger qwerty/v/v -nav/h winConfig={ mBounds=Rect(0, 0 - 1436, 1440) mAppBounds=Rect(0, 0 - 1436, 1440) mMaxBounds=Rect(0, 0 - 1436, 1440) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.8 s.2890 fontWeightAdjustment=0},overrideConfig={1.1 460mcc11mnc [zh_CN_#Hans] ldltr sw574dp w574dp h576dp 400dpi nrml port night finger qwerty/v/v -nav/h winConfig={ mBounds=Rect(0, 0 - 1436, 1440) mAppBounds=Rect(0, 0 - 1436, 1440) mMaxBounds=Rect(0, 0 - 1436, 1440) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.8 s.2 fontWeightAdjustment=0},deviceId=0,referrer=null,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@ccf6546,shareableActivityToken=android.os.BinderProxy@f4da307,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1436, 1440), taskFragmentBounds=Rect(0, 0 - 1436, 1440)}}
11-30 23:22:29.205 20536 20536 E TransactionExecutor: tId:2140026474     ResumeActivityItem{mActivityToken=android.os.BinderProxy@41a7fc5,procState=-1,updateProcState=false,isForward=true,shouldSendCompatFakeFocus=false}
11-30 23:22:29.205 20536 20536 E TransactionExecutor: tId:2140026474     Target activity: md.obsidian.MainActivity
11-30 23:22:29.205 20536 20536 E TransactionExecutor: tId:2140026474   ]
11-30 23:22:29.205 20536 20536 E TransactionExecutor: tId:2140026474 }
11-30 23:22:29.205 20536 20536 D AndroidRuntime: Shutting down VM
11-30 23:22:29.205 20536 20536 E AndroidRuntime: FATAL EXCEPTION: main
11-30 23:22:29.205 20536 20536 E AndroidRuntime: Process: md.obsidian, PID: 20536
11-30 23:22:29.205 20536 20536 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {md.obsidian/md.obsidian.MainActivity}: java.lang.SecurityException: Not allowed to bind to service Intent { act=android.support.customtabs.action.CustomTabsService pkg=org.mozilla.firefox }
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5352)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5385)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:60)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeLifecycleItem(TransactionExecutor.java:225)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:107)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2678)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:107)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.os.Looper.loopOnce(Looper.java:232)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:317)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:8758)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:962)
11-30 23:22:29.205 20536 20536 E AndroidRuntime: Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { act=android.support.customtabs.action.CustomTabsService pkg=org.mozilla.firefox }
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:2188)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.ContextImpl.bindService(ContextImpl.java:2045)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.content.ContextWrapper.bindService(ContextWrapper.java:884)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.content.ContextWrapper.bindService(ContextWrapper.java:884)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at androidx.browser.customtabs.c.a(SourceFile:26)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at com.capacitorjs.plugins.browser.b.d(SourceFile:16)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at com.capacitorjs.plugins.browser.BrowserPlugin.handleOnResume(SourceFile:3)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at com.getcapacitor.h.h0(SourceFile:27)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at com.getcapacitor.j.onResume(SourceFile:16)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1722)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.Activity.performResume(Activity.java:9180)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5341)
11-30 23:22:29.205 20536 20536 E AndroidRuntime:        ... 14 more

Looks like Obsidian want to wake up my default browser Firefox, but the firmware App Blocking feature denied this request, and Obsidian didn’t handle this exception, so Obsidian just crashed alright.

Later I turned off the chaining startup restriction for Firefox, and now Obsidian started successfully.

I would recommend to try to catch this kind of exception and notify user there is something wrong in user’s phone and ask user to configure the App Blocker settings properly.