7

I've seen a few questions already answered about this but they are all very outdated (like they talk about very old WebView versions).

My app does use the WebView as it is a browser and it also has ads and they typically use the WebView as well. It also uses ExoPlayer and I think some ads are shown with ExoPlayer as well. Unfortunately I don't have any details of when these ANRs are happening but I do know they are happening a lot more since switching ad mediation to a different company.

I've seen suggestions for disabling hardware acceleration but I don't understand why or when to do that? To me it feels like hardware acceleration would be a good thing?

This is the stacktrace for the ANR:

main (native): tid=1 systid=7983
#00 pc 0x7590c libc.so 
#01 pc 0x795f8 libc.so 
#02 pc 0xda55c libc.so 
#03 pc 0x327d54 libhwui.so 
#04 pc 0x30a2dc libhwui.so 
       at android.graphics.HardwareRenderer.nSyncAndDrawFrame(HardwareRenderer.java)
       at android.graphics.HardwareRenderer.syncAndDrawFrame(HardwareRenderer.java:436)
       at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:658)
       at android.view.ViewRootImpl.draw(ViewRootImpl.java:4664)
       at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4375)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3585)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2340)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9057)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1040)
       at android.view.Choreographer.doCallbacks(Choreographer.java:864)
       at android.view.Choreographer.doFrame(Choreographer.java:791)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1025)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:255)
       at android.app.ActivityThread.main(ActivityThread.java:8212)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
casolorz
  • 8,486
  • 19
  • 93
  • 200
  • I think it is about threading. Make sure you are loading your data in a background thread. Maybe try using Coroutines if your app is in Kotlin. – Tahir Ferli Feb 23 '22 at 23:35
  • think it's google ads – SteelBytes Aug 15 '22 at 22:58
  • None of the code on this stack trace is mine though. If it was about other threads I would think it would show up in many other places, not just this stack trace. – casolorz Aug 16 '22 at 20:44
  • No, never did. These ANRs that have stack traces that have nothing to do with your own are super hard to figure out. – casolorz Oct 10 '22 at 19:37

2 Answers2

0

My app also find this anr. It happens in the page which has google ads and audio player. Maybe caused by the interaction between video ads of google ads and audio player.

0

I have faced that too. You can do 2 things.

Step # 1

<application>
    ...
    <meta-data
        android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION"
        android:value="true"/>
    <meta-data
        android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
        android:value="true"/>
</application>

Step # 2

Call your Native Ads on Background thread, you can use some Coroutines/Threads for calling, while showing you can update your thread to main thread.

Sohaib Ahmed
  • 1,990
  • 1
  • 5
  • 23