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.

ANR on Android when using Native ads in ListView.builder

See original GitHub issue

Plugin Version

google_mobile_ads: ^1.0.1

Steps to Reproduce

Add few (2,3) AdWidget with NativeAds in a ListView.builder along with real photos / videos and scroll / tweak around a bit to see the ANR on Android.

Expected results:

The app should not receive ANR and keep a fluent scrolling.

Actual results:

The app is non responding (freeze of the UI) sometimes while scrolling.

Logs
E/ANR_LOG (16970): >>> msg's executing time is too long
E/ANR_LOG (16970): Blocked msg = { when=-2s883ms what=0 target=android.view.Choreographer$FrameHandler callback=android.view.Choreographer$FrameDisplayEventReceiver } , cost  = 1672 ms
E/ANR_LOG (16970): >>>Current msg List is:
E/ANR_LOG (16970): Current msg <1> = { when=-2s809ms what=0 target=android.os.Handler callback=io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0 }
E/ANR_LOG (16970): Current msg <2> = { when=-2s806ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): Current msg <3> = { when=-2s763ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): Current msg <4> = { when=-2s600ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): Current msg <5> = { when=-2s560ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): Current msg <6> = { when=-2s395ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): Current msg <7> = { when=-2s356ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): Current msg <8> = { when=-2s305ms what=0 target=android.os.Handler callback=io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0 }
E/ANR_LOG (16970): Current msg <9> = { when=-2s178ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): Current msg <10> = { when=-2s153ms what=0 target=com.google.android.gms.ads.internal.util.f callback=com.google.android.gms.ads.internal.webview.ai }
E/ANR_LOG (16970): >>>CURRENT MSG DUMP OVER<<<
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale fr-FR)
    • Flutter version 2.8.1 at /Users/foxtom/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/foxtom/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.63.2)
    • VS Code at /Users/foxtom/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.32.0

[✓] Connected device (3 available)
    • CPH1931 (mobile) • ee9b32b5 • android-arm64  • Android 10 (API 29)
    • macOS (desktop)  • macos    • darwin-x64     • macOS 12.1 21C52 darwin-x64
    • Chrome (web)     • chrome   • web-javascript • Google Chrome 97.0.4692.71

• No issues found!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:12

github_iconTop GitHub Comments

3reactions
Nico3652commented, Feb 3, 2022

I can confirm this is unreleasable for me. My app is freezing on android and lag on iOS with native ads inside a grid view with multiple photos and videos in auto play.

I think something is wrong during the ad loading because once it’s loaded I’m able to scroll more or less normally until the next ad display inside the grid.

2reactions
Tom3652commented, Jul 9, 2022

The real issue is with PlatformViews that have very poor overall performances on both Platforms (android and iOS).

The only way to solve this issue is that Native ads would not use PlatformViews in their implementation or wait for Flutter to release stable PlatformViews widgets.

There were apparently some changes in flutter 3.0.0 but performances have only increased a bit on Android, on iOS it remains unusable… And the PlatformViews are drawn above all others so the UI is completely broken.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to display native ads in listView.builder in flutter?
I am try to display google native ads using google_mobile_ads sdk and I want show n number of ads in between the list...
Read more >
[Solved]-How to Show native ads in listview.builder in flutter ...
Instead of ListView.builder , use ListView.separated . Then, in separatorBuilder property you can add the Ads. For example: ListView.separated( physics: ...
Read more >
showing admob banner ads randomly in listview builder
Was this Tutorial helpful? Spread Motivation on me by supporting https://paypal.me/RajatPalankar Hi, if this video was helpful to you, ...
Read more >
Implement Banner Ad between Listview items in a flutter.
flutter #flutterTutorial # listview #listviewseparated #bannerAds #AdmobAds#interstitialAds Show Ads between listview items in a flutter.
Read more >
Work with long lists - Flutter documentation
The standard ListView constructor works well for small lists. To work with lists that contain a large number of items, it's best to...
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