invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

ANR, com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService #5726

Closed Sunfocus closed 3 years ago

Sunfocus commented 3 years ago

Issue

From last few days, I am start getting this error. Whenever I opened the app in android OS, app stuck on white screen, after some time I am getting ANR dialog.


Testing device was Android real device with OS: 9

Details from package.json: "react": "16.13.1" "react-native": "^0.64.0" "@react-native-firebase/app": "^10.4.0" "@react-native-firebase/auth": "^10.4.0" "@react-native-firebase/crashlytics": "^10.4.0" "@react-native-firebase/messaging": "^10.4.0"

Log from android studio:

ANR in com.myapp PID: 16867 Reason: executing service com.myapp/com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService Load: 6.2 / 5.71 / 5.98 CPU usage from 1ms to 6266ms later (2021-09-20 12:56:18.307 to 2021-09-20 12:56:24.572): 20% TOTAL: 9.7% user + 9.1% kernel + 1.1% iowait + 0.2% irq + 0.1% softirq 31% 2075/system_server: 17% user + 14% kernel / faults: 7234 minor 17 major 31% 171/kswapd0: 0% user + 31% kernel 12% 2372/com.android.systemui: 9.9% user + 2.2% kernel / faults: 4418 minor 8 major 10% 16832/com.Slack: 7.8% user + 2.2% kernel / faults: 3942 minor 37 major 7% 2917/com.google.android.googlequicksearchbox:interactor: 5.2% user + 1.7% kernel / faults: 3729 minor 65 major 6.3% 2572/com.android.phone: 5.1% user + 1.2% kernel / faults: 3817 minor 21 major 5.7% 27862/com.google.android.inputmethod.latin: 4.4% user + 1.2% kernel / faults: 4098 minor 32 major 0.2% 1275/media.extractor: 0.1% user + 0% kernel / faults: 4232 minor 1 major 0.1% 10449/media.codec: 0.1% user + 0% kernel / faults: 3723 minor 10 major 3.1% 2515/.dataservices: 2.3% user + 0.7% kernel / faults: 3398 minor 2 major 0.1% 2529/com.qualcomm.qti.telephonyservice: 0.1% user + 0% kernel / faults: 3266 minor 1 major 0.1% 2544/com.dolby.daxservice: 0.1% user + 0% kernel / faults: 3180 minor 1 major 0.1% 2935/com.android.se: 0.1% user + 0% kernel / faults: 3186 minor 1 major 2.7% 26943/adbd: 0.6% user + 2% kernel / faults: 24672 minor 2.2% 5889/com.motorola.process.system: 1.5% user + 0.6% kernel / faults: 1740 minor 6 major 1.7% 16867/com.myapp: 1.4% user + 0.3% kernel / faults: 1254 minor 8 major 0.9% 923/android.hardware.sensors@1.0-service: 0.6% user + 0.3% kernel / faults: 41 minor 0.8% 25029/com.motorola.actions: 0.8% user + 0% kernel / faults: 835 minor 1 major 0.6% 337/mmc-cmdqd/0: 0% user + 0.6% kernel 0.6% 838/logd: 0.3% user + 0.3% kernel / faults: 47 minor 0.4% 839/servicemanager: 0% user + 0.4% kernel / faults: 20 minor 0.4% 865/android.hardware.keymaster@3.0-service-qti: 0.1% user + 0.3% kernel 0.4% 4499/kworker/u16:3: 0% user + 0.4% kernel 0.3% 7/rcu_preempt: 0% user + 0.3% kernel 0.3% 967/surfaceflinger: 0% user + 0.3% kernel / faults: 147 minor 0% 1405/tombstoned: 0% user + 0% kernel / faults: 46 minor 0.3% 1453/rild: 0.1% user + 0.1% kernel / faults: 111 minor 0.3% 13598/logcat: 0.1% user + 0.1% kernel / faults: 17 minor 0.3% 13917/kworker/u16:4: 0% user + 0.3% kernel 0.3% 17631/com.instagram.android: 0.1% user + 0.1% kernel / faults: 217 minor 0.1% 1//init: 0% user + 0.1% kernel / faults: 10 minor 0.1% 45/rcuop/4: 0% user + 0.1% kernel 0.1% 53/rcuop/5: 0% user + 0.1% kernel 0.1% 61/rcuop/6: 0% user + 0.1% kernel 0.1% 69/rcuop/7: 0% user + 0.1% kernel 0.1% 255/kgsl_worker_thr: 0% user + 0.1% kernel 0.1% 432/ueventd: 0.1% user + 0% kernel / faults: 1 minor 0.1% 933/android.hardware.graphics.composer@2.1-service: 0% user + 0.1% kernel / faults: 27 minor 0.1% 1246/audioserver: 0% user + 0.1% kernel / faults: 111 minor 0.1% 1253/thermal-engine: 0% user + 0.1% kernel / faults: 16 minor 0.1% 1265/cameraserver: 0% user + 0.1% kernel / faults: 103 minor 0% 1266/drmserver: 0% user + 0% kernel / faults: 102 minor 0.1% 1271/keystore: 0.1% user + 0% kernel 0% 1272/mediadrmserver: 0% user + 0% kernel / faults: 160 minor 0% 1276/media.metrics: 0% user + 0% kernel / faults: 158 minor 0.1% 1282/mediaserver: 0% user + 0.1% kernel / faults: 106 minor 0.1% 2735/irq/54-408000.q: 0% user + 0.1% kernel 0.1% 7250/kworker/u17:3: 0% user + 0.1% kernel 0.1% 8915/com.microsoft.office.outlook: 0% user + 0.1% kernel / faults: 169 minor 0.1% 11793/kworker/u16:2: 0% user + 0.1% kernel 0.1% 13301/kworker/u17:6: 0% user + 0.1% kernel 0.1% 15496/kworker/5:2: 0% user + 0.1% kernel 0.1% 16440/com.facebook.katana: 0% user + 0.1% kernel / faults: 10 minor 0.1% 16812/kworker/7:1: 0% user + 0.1% kernel 0.1% 16845/net.one97.paytm: 0.1% user + 0% kernel / faults: 120 minor 0.1% 16851/c

Sunfocus commented 3 years ago

May be that issue occur because of old version. Updating packages to 10.8.1 working fine. Closing this issue.

pamydev commented 2 years ago

14.11.0 and same issue for me... it's a shame unfortunately

mikehardy commented 2 years ago

@kauesedrez this is not something users report as a general issue, but it is definitely possible for your app to be slow on startup and hang, causing an ANR. It is project-specific in my experience and you'll want to turn on StrictMode and run your app while watching adb logcat in order to properly fix up your app's startup sequence: https://developer.android.com/reference/android/os/StrictMode

pamydev commented 2 years ago

@mikehardy I've tested in strict mode and have no issues on adb logcat. To be sure, I make a mistake on purpose and logcat throw the error. So my code doesnt appear have no statup problems. And if you search on google for issues like this you will see how much users have anrs with rn-firebase.

mikehardy commented 2 years ago

Firebase boots your whole app when it receives a message, so it will be collateral damage for any slow startup issue ever. It's the same as saying 'crashlytics logged a crash so it's crashlytics fault'. I'm not trying to over simplify if you think of it logically it really is the case. The module is fine but sometimes apps boot slowly and boom, you get an anr while app was waking up for an FCM

pamydev commented 2 years ago

Firebase boots your whole app when it receives a message, so it will be collateral damage for any slow startup issue ever

Ok, I understand what you are saying, but ANR is a very important metric in Google Play console and my app is flagged with "bad behaviour" and - obviously - my downloads are cut down. So what is your suggestion, do not use notifications any more because ANR is a "collateral damage"?

pamydev commented 2 years ago

Ok man, let's say I accept the fact that react-native neither have an official 1.0.0 version yet and sh*t happens...

There are a way to try catch this ANRs or something else? Because its acceptable that some users some times don't receive some notifications, but its not acceptable this behavior impact on google console reports and downloads. Do you understand me?

mikehardy commented 2 years ago

Please keep it professional.

Note that react-native just uses "magic zero" versioning, it's stable enough, you can google the versioning style.

You'll need to profile your app start up time, there are tools in Android Studio that help you do that, and Firebase Performance module can also help with it. This is a standard phase of app optimization and if you are experiencing ANRs, doing this (similar to my StrictMode advice, to look for StrictMode violations) is important.

Removing notifications will of course result in your app not booting, and if your app doesn't boot then it can't ANR by definition, so it is one way to lower your ANR count. However, if you don't solve whatever is taking your app boot so long then you will likely still have the same number of ANRs-per-boot, right?

This is not a firebase thing unfortunately, it's a generic "my app boots slowly" thing so look for more general advice. Is it only on some device types? Are some network requests made during boot? Disk access? Is the UI thread blocked some times for some reasons? etc

pamydev commented 2 years ago

Sorry for my lack of knowledge about 0ver, and congrats on your work in this project. For me, I think it's time to left react and react-native behind and move on.

Thanks for your patience.