firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.25k stars 572 forks source link

Firelog sdk is using JobScheduler which is not recommended now #6147

Open mrober opened 1 month ago

mrober commented 1 month ago

From @ankit92:

com.google.android.datatransport/transport-runtime library is using JobScheduler which is not recommended now as mentioned in android documentation: https://developer.android.com/about/versions/14/behavior-changes-14

_JobScheduler reinforces callback and network behavior Since its introduction, JobScheduler expects your app to return from onStartJob or onStopJob within a few seconds. Prior to Android 14, if a job runs too long, it stops and fails silently. If your app targets Android 14 (API level 34) or higher and exceeds the granted time on the main thread, the app triggers an ANR with the error message "No response to onStartJob" or "No response to onStopJob". Consider migrating to WorkManager, which provides support for asynchronous processing or migrating any heavy work into a background thread._

All ANR's which spiked in our app are on Android 14 , as mentioned in above chat threads, and mostly related JobScheduler.

Strangely 75% of events are on OnePlus devices and rest 25% are on OPPO devices

Here are the logs:

art::ConditionVariable::WaitHoldingLocks ANR triggered by thread waiting for a binder transaction

main (native) tid=1 systid=30996 Triggered ANR Root blocking 0 libc.so syscall + 28 1 libart.so art::ConditionVariable::WaitHoldingLocks + 140 2 libart.so artJniMethodEnd + 336 3 libart.so art_jni_method_end + 12 android.os.BinderProxy.transactNative (Native method) This Binder call may be taking too long, causing the main thread to wait, and triggering the ANR. android.os.BinderProxy.transact (BinderProxy.java:685) android.app.job.IJobCallback$Stub$Proxy.acknowledgeStartMessage (IJobCallback.java:434) android.app.job.JobServiceEngine$JobHandler.ackStartMessage (JobServiceEngine.java:384) android.app.job.JobServiceEngine$JobHandler.handleMessage (JobServiceEngine.java:196) android.os.Handler.dispatchMessage (Handler.java:106) android.os.Looper.loopOnce (Looper.java:257) android.os.Looper.loop (Looper.java:368) android.app.ActivityThread.main (ActivityThread.java:8839) java.lang.reflect.Method.invoke (Native method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:572) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1049)

This is becoming more critical now and shaken all our app's performance metrics in terms of ANR's

Raised this to help you so that you can get more insights and request you to please provide us with the fix as soon as possible . Thanks

Originally posted by @ankit92 in https://github.com/firebase/firebase-android-sdk/issues/4345#issuecomment-2262159437

davidmotson commented 1 month ago

This is being worked on along with other improvements for API level 34 (android 14), and it should be rolled out across all Firebase Android SDKs soon.

stepushchik commented 3 weeks ago

The same:

         main (native):tid=1 systid=20068 
#00 pc 0x99ccc libc.so (syscall + 28) (BuildId: a87e89fc2c0a5753053f536add4d7ae1)
#01 pc 0x232670 libart.so (art::ConditionVariable::WaitHoldingLocks + 140) (BuildId: 2452917c4ff69cbb6e75e5512260946b)
#02 pc 0x45a5e4 libart.so (artJniMethodEnd + 336) (BuildId: 2452917c4ff69cbb6e75e5512260946b)
#03 pc 0x5be67c libart.so (art_jni_method_end + 12) (BuildId: 2452917c4ff69cbb6e75e5512260946b)
       at android.os.BinderProxy.transactNative(Native method)
       at android.os.BinderProxy.transact(BinderProxy.java:685)
       at android.app.job.IJobCallback$Stub$Proxy.acknowledgeStartMessage(IJobCallback.java:434)
       at android.app.job.JobServiceEngine$JobHandler.ackStartMessage(JobServiceEngine.java:384)
       at android.app.job.JobServiceEngine$JobHandler.handleMessage(JobServiceEngine.java:196)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:257)
       at android.os.Looper.loop(Looper.java:368)
Screenshot 2024-08-20 at 13 50 31
ankit92 commented 3 weeks ago

This is being worked on along with other improvements for API level 34 (android 14), and it should be rolled out across all Firebase Android SDKs soon.

@davidmotson Is there any schedule or planned date for next Firebase Android BOM release which includes these fixes? These ANR's are becoming critical now for our app.

ankit92 commented 3 weeks ago

@davidmotson @mrober Does this issue got fixed in BOM version 33.2.0?

mandeep1999 commented 2 weeks ago

Is there any timeline when the fix for this will be released?

RelappsStudio commented 1 week ago

Same issue here:

art::ConditionVariable::WaitHoldingLocks
ANR triggered by thread waiting for a binder transaction

          main (native):tid=1 systid=17264 
#00 pc 0x99ccc libc.so (syscall + 28) (BuildId: a87e89fc2c0a5753053f536add4d7ae1)
#01 pc 0x23247c libart.so (art::ConditionVariable::WaitHoldingLocks + 140) (BuildId: 4801adadf1dae7e020ba05f3204efc9c)
#02 pc 0x45b218 libart.so (artJniMethodEnd + 336) (BuildId: 4801adadf1dae7e020ba05f3204efc9c)
#03 pc 0x5bef7c libart.so (art_jni_method_end + 12) (BuildId: 4801adadf1dae7e020ba05f3204efc9c)
       at android.os.BinderProxy.transactNative(Native method)
       at android.os.BinderProxy.transact(BinderProxy.java:685)
       at android.app.job.IJobCallback$Stub$Proxy.acknowledgeStartMessage(IJobCallback.java:434)
       at android.app.job.JobServiceEngine$JobHandler.ackStartMessage(JobServiceEngine.java:384)
       at android.app.job.JobServiceEngine$JobHandler.handleMessage(JobServiceEngine.java:196)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:257)
       at android.os.Looper.loop(Looper.java:368)
       at android.app.ActivityThread.main(ActivityThread.java:8815)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

Surprisingly only on android 14, only ColorOS supported devices

image

Any bypass suggestions before fix? Anyone managed to find some workaround?

stepushchik commented 1 week ago

Relates to https://developer.android.com/jetpack/androidx/releases/work#2.10.0-alpha03

  • Fix foreground workers of type ‘short service’ and ‘data sync’ timing out and causing an ANR when WorkManager didn’t call stopSelf(). This fix only applies to devices with API 34 and 35 where foreground service types were introduced. (ca06b2, b/364508145)
Krishnasony commented 6 days ago

Relates to https://developer.android.com/jetpack/androidx/releases/work#2.10.0-alpha03

  • Fix foreground workers of type ‘short service’ and ‘data sync’ timing out and causing an ANR when WorkManager didn’t call stopSelf(). This fix only applies to devices with API 34 and 35 where foreground service types were introduced. (ca06b2, b/364508145)

Is this Fixed The background ANR coming on Android 14?

davidmotson commented 4 days ago

@stepushchik @RelappsStudio @mandeep1999

Can you provide more details on the error you're experiencing? For example:

Are there other, similar ANRs being reported for your app? (same error, binder transaction, but a different stack trace) Have you been able to reproduce these personally? If so, under what conditions? Are you also seeing this mainly/exclusively on oppo/one+ devices?