Investigating if certain plugins cause excessive ANRs

I’m using Firebase analytics. I’m investigating ANRs reported on Google Play, and it appears that the most frequent ones are associated with various receivers added by the Firebase analytics plugin to the Manifest.

Edit: I have various plugin configurations across my portfolio, and I’m trying to pin down why some apps have over 1% ANR rate while others have almost 0% ANR rate. First I thought it was related to Firebase, but that appears untrue. The posts below contain discussion.

Before proceeding, why is this important? As annouced at Google Playtime 2017, Google will start penalizing apps (using reduced ranking) which exhibit “Bad behaviour” as reported in the Android Vitals section of the dev console. For ANRs, the limit is 0.47% ANR rate, and I’m currently at 1.28%.

One of my most frequent ANRs is in executing service se.appfamily.superpuzzlefree/shared.google.play.services.base.PackageStateChangedService

It appears to happen when exiting the app:

“main” prio=5 tid=1 Native | group=“main” sCount=1 dsCount=0 obj=0x76918598 self=0xf4fe4500 | sysTid=21370 nice=-4 cgrp=default sched=0/0 handle=0xf77cad54 | state=S schedstat=( 0 0 0 ) utm=39 stm=41 core=5 HZ=100 | stack=0xff1a1000-0xff1a3000 stackSize=8MB | held mutexes=

native: pc 00000000000176a4 /system/lib/libc.so (syscall+28)
native: pc 00000000000401d5 /system/lib/libc.so (pthread_join+124)
native: pc 0000000000015b58 /data/app/se.appfamily.superpuzzlefree-1/lib/arm/libopenal.so (alcDestroyContext+516)
native: pc 0000000000008ed7 /data/app/se.appfamily.superpuzzlefree-1/lib/arm/libalmixer.so (ALmixer_Quit+230)
native: pc 000000000011d014 /data/app/se.appfamily.superpuzzlefree-1/lib/arm/libcorona.so (???)
native: pc 000000000011f448 /data/app/se.appfamily.superpuzzlefree-1/lib/arm/libcorona.so (???)
native: pc 000000000012f53c /data/app/se.appfamily.superpuzzlefree-1/lib/arm/libcorona.so (???)
native: pc 000000000002b6c4 /data/app/se.appfamily.superpuzzlefree-1/lib/arm/libcorona.so (???)
native: pc 000000000002e9c0 /data/app/se.appfamily.superpuzzlefree-1/lib/arm/libcorona.so (Java_com_ansca_corona_JavaToNativeShim_nativeDone+28)
native: pc 0000000000425af5 /data/app/se.appfamily.superpuzzlefree-1/oat/arm/base.odex (Java_com_ansca_corona_JavaToNativeShim_nativeDone__J+80)
at com.ansca.corona.JavaToNativeShim.nativeDone (Native method)
at com.ansca.corona.JavaToNativeShim.destroy (JavaToNativeShim.java:277)
at com.ansca.corona.Controller.destroy (Controller.java:286)
- locked <0x0a532824> (a com.ansca.corona.Controller)
at com.ansca.corona.CoronaRuntime.dispose (CoronaRuntime.java:88)
at com.ansca.corona.CoronaActivity.onDestroy (CoronaActivity.java:1679)
at android.app.Activity.performDestroy (Activity.java:7130)
at android.app.Instrumentation.callActivityOnDestroy (Instrumentation.java:1171)
at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:5126)
at android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:5171)
at android.app.ActivityThread.access$1700 (ActivityThread.java:230)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1881)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:7409)
at java.lang.reflect.Method.invoke! (Native method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)

Doesn’t seem limited to any particular Android version:

Android 6.0 13,171 57.0% Android 7.0 6,992 30.3% Android 5.1 1,668 7.2% Android 7.1 733 3.2% Android 5.0 529 2.3% Android 8.0 18 0.1%

Afraid I don’t have a reproducible case.

I don’t manage the shared google play libraries corona does https://bitbucket.org/coronalabs/shared-hosted-google-play-services-base

To clarify my plugin uses a shared corona library. That error is from the corona shared library there is nothing I can do, you may want to file a bug report with them.

Thanks, I didn’t intend to cast any blame on the plugin itself, just highlight the consequences it has (for me, at least). There are multiple other ANRs pointing towards stuff related to Firebase, so I prefer to play safe and simply cease using it.

Turns out the offending line in the Manifest is also included if you use Admob (without Firebase). Original post edited, but not sure how to edit the title

You can edit title with full editor

Screen_Shot_2017_10_25_at_1_37_49_PM.png

We are not using Firebase or Admob but we still get a lot of the same ANRs for basically all our apps. 

executing service com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle/shared.google.play.services.base.PackageStateChangedService "main" prio=5 tid=1 Native | group="main" sCount=1 dsCount=0 obj=0x73bc8e98 self=0xf3a05400 | sysTid=26481 nice=-4 cgrp=default sched=0/0 handle=0xf66b9534 | state=S schedstat=( 711107157 668022854 1857 ) utm=59 stm=12 core=2 HZ=100 | stack=0xff5b1000-0xff5b3000 stackSize=8MB | held mutexes= native: pc 0000000000017708 /system/lib/libc.so (syscall+28) native: pc 00000000000473bf /system/lib/libc.so (pthread\_join+146) native: pc 0000000000015b58 /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/lib/arm/libopenal.so (alcDestroyContext+516) native: pc 0000000000008ed7 /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/lib/arm/libalmixer.so (ALmixer\_Quit+230) native: pc 000000000011d48c /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/lib/arm/libcorona.so (???) native: pc 000000000011f8c0 /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/lib/arm/libcorona.so (???) native: pc 000000000012f9b4 /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/lib/arm/libcorona.so (???) native: pc 000000000002b6fc /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/lib/arm/libcorona.so (???) native: pc 000000000002e9f8 /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/lib/arm/libcorona.so (Java\_com\_ansca\_corona\_JavaToNativeShim\_nativeDone+28) native: pc 0000000000052415 /data/app/com.kavrakids.Cats\_Dogs\_Photo\_Jigsaw\_Puzzle-1/oat/arm/base.odex (Java\_com\_ansca\_corona\_JavaToNativeShim\_nativeDone\_\_J+80) at com.ansca.corona.JavaToNativeShim.nativeDone (Native method) at com.ansca.corona.JavaToNativeShim.destroy (JavaToNativeShim.java:277) at com.ansca.corona.Controller.destroy (Controller.java:286) - locked \<0x08356239\> (a com.ansca.corona.Controller) at com.ansca.corona.CoronaRuntime.dispose (CoronaRuntime.java:88) at com.ansca.corona.CoronaActivity.onDestroy (CoronaActivity.java:1732) at android.app.Activity.performDestroy (Activity.java:6907) at android.app.Instrumentation.callActivityOnDestroy (Instrumentation.java:1154) at android.app.ActivityThread.performDestroyActivity (ActivityThread.java:4267) at android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:4298) at android.app.ActivityThread.-wrap6 (ActivityThread.java) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1576) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:241) at android.app.ActivityThread.main (ActivityThread.java:6223) at java.lang.reflect.Method.invoke! (Native method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)

It would be great if Corona could fix this as soon as possible. 

Joakim, what does your manifest look like? Possibly some other plugin (IAP?) also injects that service requirement? Maybe we’ll need to clean this up before filing bug report

How do I check the manifest file?

FYI most native plugins use google play services in their app. Google play games service, any firebase plugin, google analytics, google iap, one signal, etc.

Extracting manifest from APK: https://github.com/ytsutano/axmldec

Using this thread to document findings/thoughts as I go

One app, Balloon Pop, uses Firebase and IAP. It has very few ANRs

Another app, Animal Memory, uses Firebase and IAP and Kidoz. It has around 1% ANRs

The biggest one, Super Puzzle, uses Firebase and IAP and Admob and Kidoz. Lots of ANRs.

For Super Puzzle, removing Firebase made no difference as far as I can tell. Which is in line with expectations, since Balloon Pop uses Firebase and is fine.

Now I’ll publish Super Puzzle without Admob (it isn’t used by default, but included in the build settings in case I want to enable it remotely). I’m keeping Kidoz in, but based on the Animal Memory app above (which has Kidoz but not Admob), the hypothesis is unfortunately that I’ll still see lots of ANRs. 

(Trial and error, but there are plenty of daily installs so I get results quickly)

The APK without Admob seems to have made no difference. Now publishing without Kidoz

It appears that there are fewer of that kind of ANRs when not using Kidoz, but they are not completely gone, Discussing with Kidoz

@perflubron: My ANRs skyrocketed after i started using Kidoz. Thanks to your thought/process of elimination i disabled (stopped using) Kidoz. I know you are discussing the issue with Kidoz. Any updated on this from them? The Kidoz plugin hasn’t been updated recently, so i’m guessing the sdk hasn’t changed either. 

Thanks

Luay

Is it the " executing service se.appfamily.superpuzzlefree/shared.google.play.services.base.PackageStateChangedService"  that you are chasing? Solving that one would in my case get me on the right side of the threshold.

Yes. same ANR. And i ‘fixed’ it by disabling Kidoz. My app is ad free for the time being until this issue is resolved and Kidoz update their SDK. 

By the way, am I correct in assuming that even if we fix ANRs and crashes, the threshold is calculated over a three months period? So, the app will remain ‘penalized’ for at least three months?

Hi All, 

Thank you for this discussion, we would like to inform you that we are working with the Corona team who is responsible for the KIDOZ plugin to monitor and solve the issue asap, some fixes have been made and we hope to have new release of the KIDOZ plugin available in the coming days.

We will make sure to notify our partners directly as well as here in the forum once the new build is available.

In case of any questions, please reach out and contact us at sdk@kidoz.net.

@ran5: That is excellent news.

Are there any news on this issue?

I am also seeing about 1.72% ANR-Rate, mostly because of:

executing service com.mypackagename/shared.google.play.services.base.PackageStateChangedService

I am using AdMob and Firebase, no Kidoz.

Best regards,

Bjoern