App crashes in background when processing push notification with SecurityException
See original GitHub issue[REQUIRED] Step 2: Describe your environment
- Android Studio version: Android Studio 4.1 Build #AI-201.8743.12.41.6858069, built on September 23, 2020 Runtime version: 1.8.0_242-release-1644-b3-6222593 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.14.6 GC: ParNew, ConcurrentMarkSweep Memory: 2988M Cores: 12 Registry: ide.new.welcome.screen.force=true, debugger.watches.in.variables=false Non-Bundled Plugins: siosio.kodkod, com.phraseapp.androidstudio, wu.seal.tool.jsontokotlin
- Firebase Component: firebase-messaging
- Component version: 21.0.0
[REQUIRED] Step 3: Describe the problem
We have a top crash which is majorly (85%) noticed on Huawei devices. The crash report is attached below. This crash happens on post Oreo Android version while the app is in background (100% times). In all the crash traces two threads : Firebase-Messaging-Topics-Io
and Firebase-Messaging-Init
are in park state. So our guess, is that the crash happens when application is in background and a push notification is received by our app. It seems like Firebase messaging uses JobIntentService to execute some task in background thread, which crashes.
This seems to be a know issue with the usage of JobIntentService => https://issuetracker.google.com/issues/63622293, and google dev propose to migrate to using WorkManager instead.
This crash only has decimated our crash stats and it is seen by 100-120 users per day. If we measure it monthly the numbers are in thousands 😭 .
Steps to reproduce:
What happened?
- Huawei devices(Oreo and above) and App running in background
- App crashes in background when receiving push
Relevant Code:
I don’t have a code to reproduce the problem. However, I can share the entire trace that we receive on FirebaseCrashlytics
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:365)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:784)
Caused by java.lang.SecurityException: Caller no longer running, last stopped +3m45s218ms because: cancelled due to doze
at android.os.Parcel.readException(Parcel.java:2016)
at android.os.Parcel.readException(Parcel.java:1962)
at android.app.job.IJobCallback$Stub$Proxy.completeWork(IJobCallback.java:218)
at android.app.job.JobParameters.completeWork(JobParameters.java:232)
at androidx.core.app.JobIntentService$JobServiceEngineImpl$WrapperWorkItem.complete(JobIntentService.java:268)
at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:394)
at androidx.core.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:383)
at android.os.AsyncTask$2.call(AsyncTask.java:345)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:784)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:18 (6 by maintainers)
Top GitHub Comments
It was another dependency causing the issue. Not related to firebase
https://github.com/kmansoft/jobintentservicex