🐛 Low performance when using AdWidget
See original GitHub issueBug report
After adding AdWidget to widget tree overall app performance is low.
Steps to reproduce
Steps to reproduce the behavior:
I’ve building BannerAd and AdWidget in follow way:
BannerAd getBannerAd() {
BannerAd bannerAd = BannerAd(
size: AdSize.fullBanner,
adUnitId: Config.adMobBannerIdTest,
listener: AdListener(
onAdFailedToLoad: (ad, error) {
ad.dispose();
},
),
request: AdRequest(
nonPersonalizedAds: _sharedPrefs.isPersonalizedAds() == false,),
);
bannerAd.load();
return bannerAd;
}
Widget buildAdWidget(BannerAd? bannerAd){
if(bannerAd != null){
AdWidget adWidget = AdWidget(ad: bannerAd);
return Container(
alignment: Alignment.center,
child: adWidget,
width: bannerAd.size.width.toDouble(),
height: bannerAd.size.height.toDouble(),
);
}else
return SizedBox();
}
Then in when I add AdWidget to screen performance is low. I’ve added simple check to determine if its fault of AdWidget and it seems its the problem:
Widget adContainer = false ? SizedBox() : _adMobHelper!.buildAdWidget(bannerAd);
return Scaffold(
body: Column(
children: [
Expanded(
child: IndexedStack(
index: _currentIndex,
children: _children,
),
),
adContainer
],
),
...rest of code, rather not important
Expected behavior
None to low impact on performance
Additional context
While I was using firebase_admob everything worked smooth
Flutter doctor
Run flutter doctor
and paste the output below:
Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, 2.0.1, on Microsoft Windows [Version 10.0.18363.1440], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] Connected device (3 available)
• No issues found!
Flutter dependencies
Run flutter pub deps -- --style=compact
and paste the output below:
Click To Expand
Dart SDK 2.12.0
Flutter SDK 2.0.1
bmi_calculator 1.0.2+5
dependencies:
- android_alarm_manager 0.4.5+20 [flutter]
- catex 0.0.1+6 [flutter meta]
- clip_shadow 0.2.1 [flutter]
- cupertino_icons 1.0.2
- devicelocale 0.3.3 [flutter]
- firebase_analytics 7.1.1 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta]
- firebase_core 1.0.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 1.0.0 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_remote_config 0.9.0-dev.0 [flutter firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface]
- fl_chart 0.20.1 [flutter path_drawing equatable pedantic]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_html 2.0.0-nullsafety.0 [html csslib css_colors flutter_layout_grid video_player chewie webview_flutter chewie_audio flutter_svg flutter]
- flutter_local_notifications 5.0.0-nullsafety.1 [flutter flutter_local_notifications_platform_interface platform timezone]
- flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math]
- flutter_settings_screens 0.2.1+1 [flutter flutter_material_color_picker path_provider provider shared_preferences]
- flutter_speed_dial 1.2.5 [flutter]
- fluttertoast 3.1.3 [flutter]
- freezed 0.12.7 [analyzer build build_config meta source_gen freezed_annotation]
- google_fonts 1.1.2 [flutter http path_provider crypto]
- google_mobile_ads 0.11.0+3 [meta flutter]
- google_sign_in 5.0.0 [google_sign_in_platform_interface google_sign_in_web flutter meta]
- googleapis 0.56.1 [_discoveryapis_commons http]
- in_app_purchase 0.5.1 [flutter json_annotation meta collection]
- intl 0.17.0 [clock path]
- json_annotation 4.0.0
- mockito 4.1.4 [analyzer build code_builder collection dart_style matcher meta source_gen test_api]
- package_info 0.4.3+2 [flutter]
- path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- provider 5.0.0 [collection flutter nested]
- rate_my_app 1.0.0+2 [shared_preferences pedantic flutter]
- rxdart 0.22.2
- sembast 2.1.0 [meta path synchronized]
- shared_preferences 2.0.4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- simple_tooltip 0.1.14 [flutter]
- url_launcher 6.0.2 [flutter url_launcher_platform_interface url_launcher_linux url_launcher_macos url_launcher_windows url_launcher_web]
- workmanager 0.2.3 [flutter]
dev dependencies:
- build_runner 1.11.0 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspe
c_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]
- json_serializable 4.0.2 [analyzer build build_config json_annotation meta path source_gen]
transitive dependencies:
- _discoveryapis_commons 0.2.0 [http]
- _fe_analyzer_shared 14.0.0 [meta]
- analyzer 0.41.2 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- args 1.6.0
- async 2.5.0 [collection]
- boolean_selector 2.1.0 [source_span string_scanner]
- build 1.6.2 [analyzer async convert crypto glob logging meta path]
- build_config 0.4.5 [checked_yaml json_annotation meta path pubspec_parse yaml]
- build_daemon 2.1.9 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 1.5.3 [analyzer build crypto graphs logging meta path package_config pool pub_semver]
- build_runner_core 6.1.7 [async build build_config build_resolvers collection convert crypto glob graphs logging meta path package_config pedantic pool timing watcher yaml]
- built_collection 5.0.0
- built_value 8.0.2 [built_collection collection fixnum]
- characters 1.1.0
- charcode 1.2.0
- checked_yaml 1.0.4 [json_annotation source_span yaml]
- chewie 1.0.0 [cupertino_icons flutter video_player wakelock]
- chewie_audio 1.2.0 [cupertino_icons flutter video_player]
- cli_util 0.2.0 [path]
- clock 1.1.0
- code_builder 3.7.0 [built_collection built_value collection matcher meta]
- collection 1.15.0
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- css_colors 1.1.0 [flutter]
- csslib 0.17.0 [source_span]
- dart_style 1.3.10 [analyzer args path source_span]
- equatable 2.0.0 [collection meta]
- fake_async 1.2.0 [clock collection]
- ffi 1.0.0
- file 6.1.0 [meta path]
- firebase 7.3.3 [http http_parser js]
- firebase_analytics_platform_interface 1.1.0 [flutter meta]
- firebase_analytics_web 0.2.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta]
- firebase_core_platform_interface 4.0.0 [flutter meta plugin_platform_interface]
- firebase_core_web 1.0.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_crashlytics_platform_interface 2.0.0 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_remote_config_platform_interface 0.2.0-dev.0 [flutter meta firebase_core plugin_platform_interface]
- fixnum 1.0.0
- flutter_layout_grid 1.0.0-nullsafety.6 [flutter collection meta quiver]
- flutter_local_notifications_platform_interface 3.0.0-nullsafety.4 [flutter plugin_platform_interface]
- flutter_material_color_picker 1.0.5 [flutter]
- flutter_svg 0.21.0-nullsafety.0 [flutter meta path_drawing vector_math xml]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- freezed_annotation 0.14.0 [collection json_annotation meta]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- google_sign_in_platform_interface 2.0.1 [flutter meta quiver]
- google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- graphs 0.2.0
- html 0.15.0 [csslib source_span]
- http 0.12.2 [http_parser path pedantic]
- http_multi_server 2.2.0 [async]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- io 0.3.4 [charcode meta path string_scanner]
- js 0.6.3
- logging 0.11.4
- matcher 0.12.10 [stack_trace]
- meta 1.3.0
- mime 0.9.7
- nested 1.0.0 [flutter]
- node_interop 1.1.1 [js]
- node_io 1.1.1 [node_interop path]
- package_config 1.9.3 [path charcode]
- path 1.8.0
- path_drawing 0.5.0-nullsafety.0 [vector_math meta path_parsing flutter]
- path_parsing 0.2.0-nullsafety.0 [vector_math meta]
- path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 2.0.0 [flutter]
- path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface]
- path_provider_windows 2.0.0 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.11.0
- petitparser 4.0.2 [meta]
- platform 3.0.0
- plugin_platform_interface 2.0.0 [meta]
- pool 1.4.0 [async stack_trace]
- process 4.1.0 [file path platform]
- pub_semver 1.4.4 [collection]
- pubspec_parse 0.1.8 [checked_yaml json_annotation pub_semver yaml]
- quiver 3.0.0 [matcher]
- shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows]
- shelf 0.7.9 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel]
- sky_engine 0.0.99
- source_gen 0.9.10+3 [analyzer async build dart_style glob meta path pedantic source_span]
- source_span 1.8.0 [charcode collection path term_glyph]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- stream_transform 1.2.0
- string_scanner 1.1.0 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0
- test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timezone 0.7.0-nullsafety.0 [path]
- timing 0.1.1+3 [json_annotation]
- typed_data 1.3.0 [collection]
- url_launcher_linux 2.0.0 [flutter]
- url_launcher_macos 2.0.0 [flutter]
- url_launcher_platform_interface 2.0.2 [flutter plugin_platform_interface]
- url_launcher_web 2.0.0 [url_launcher_platform_interface meta flutter flutter_web_plugins]
- url_launcher_windows 2.0.0 [flutter]
- vector_math 2.1.0
- video_player 2.0.2 [meta video_player_platform_interface video_player_web flutter flutter_test]
- video_player_platform_interface 4.0.0 [flutter meta flutter_test]
- video_player_web 2.0.0 [flutter flutter_web_plugins meta video_player_platform_interface]
- wakelock 0.4.0 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web]
- wakelock_macos 0.1.0 [flutter flutter_web_plugins wakelock_platform_interface]
- wakelock_platform_interface 0.2.0 [flutter meta]
- wakelock_web 0.2.0 [flutter flutter_web_plugins js wakelock_platform_interface]
- watcher 0.9.7+15 [async path pedantic]
- web_socket_channel 1.1.0 [async crypto stream_channel]
- webview_flutter 2.0.2 [flutter]
- win32 2.0.0 [ffi]
- xdg_directories 0.2.0 [meta path process]
- xml 5.0.2 [collection meta petitparser]
- yaml 2.2.1 [charcode collection string_scanner source_span]
Issue Analytics
- State:
- Created 3 years ago
- Reactions:36
- Comments:39 (6 by maintainers)
Top Results From Across the Web
Flutter :- This AdWidget is already in the Widget tree. How to ...
So I insert admob ads inside the List. And I added the functionality of infinity scroll inside the list view. So when the...
Read more >Banner | Flutter - Google Developers
Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen...
Read more >Add widget indicators - ServiceNow Docs
You can open a widget either from Performance Analytics > Widgets or from the dashboard. For more information, see Edit a responsive dashboard....
Read more >"Add widget" option not appearing on home screen
Your phone Motorola Moto E6i is running Android 10 Go. On Android Go the default launcher has no widget support.
Read more >Widgets Basic Overview (EX) - Qualtrics
... Brand Awareness Survey · Brand Performance Solution ... Email Distribution Error Messages · Avoid Being Marked as Spam · Using a Custom...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kuba91 Which Android is S8+ Running?
Can you try same code but with my git version?
Let me know if performance gets any better.
I use this plugin for banner ads: https://pub.dev/packages/native_admob_flutter
It automatically does the checking of the android version for you, so you don’t need to worry about it. It uses hybrid composition only on Android 19, because its performance is really slow on other versions and it has several rendering issues when in a ListView.
It also supports Rewarded, Interstitial, Native (android only), App Open and Rewarded Interstitial Ads if you want