question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
shaileshmotacommented, May 9, 2022

@shaileshmota do you mean Firebase has this 3rd party library as a dependency? (Firebase -> 3rd party library -> JobIntentService)

It was another dependency causing the issue. Not related to firebase

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android app crashes when receiving a new FCM message ...
Android app crashes when receiving a new FCM message (foreground and background) ... I am working on implementing FCM in my app. I'm...
Read more >
Core data inaccessible when app la… - Apple Developer
If an iOS app crashes in the background, silent push notifications are supposed to be able to relaunch the app, and I've seen...
Read more >
How to Diagnose App Issues Using Crash Logs - Papertrail
First, let's walk through the four steps you need to follow to get the crash log after the app crashes. I'll use Android...
Read more >
JobIntentService is crashing in an AsyncTask on Android O
are you cancelling your background process when you get on onDestroy? ... flg=0x1000010 pkg=com.ninegag.android.app cmp=com.ninegag.android.app/.push.gcm.
Read more >
Help! Pixel 6 Pro notifications are not working : r/GooglePixel
Push notifications across all apps straight up do not work. ... which I saw Scheduling restart of crashed service com.google.android.gms/.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found