googleads / googleads-mobile-flutter

A Flutter plugin for the Google Mobile Ads SDK
Apache License 2.0
340 stars 283 forks source link

🐛 Low performance when using AdWidget #80

Closed kuba91 closed 3 years ago

kuba91 commented 3 years ago

Bug 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] ```

MrAndrixx commented 3 years ago

I have the same problem, I have tried to optimize my application, decreasing the number of Widgets, but I have not achieved much.

I did tests with the Profile mode and this I was able to rescue: Homepage without ads (image 1) without ads

Homepage with ads (image 2) with ads

And the funny thing is that in image 2, the ads did not load, the console appeared "Ad failed to load: 3", but anyway the performance decreased by almost 30 frames 🤔.

atrope commented 3 years ago

Which devices are you testing?

kuba91 commented 3 years ago

I was testing on Samsung S8+ (SM G955F)

atrope commented 3 years ago

@kuba91 Which Android is S8+ Running?

Can you try same code but with my git version?

  google_mobile_ads:
    git:
      url: https://github.com/SuaMusica/googleads-mobile-flutter.git
      path: packages/google_mobile_ads
      ref: feature/suamusica

Let me know if performance gets any better.

kuba91 commented 3 years ago

I've Android 9 on On S8+. As for quick test it's much better from Your version.

image

It seems it works with and without ads same

nickJLm commented 3 years ago

We see the same issue with performance, especially in a list view on a tablet. When testing on a Galaxy Tab S2 device scrolling through items with banners, we see a significant performance drop.

Screen Shot 2021-03-12 at 11 32 44 AM

atrope commented 3 years ago

@nickJLm which OS? can you try my version?

atrope commented 3 years ago

The Only diference from my version is that it is using AndroidView.

as per this:

https://flutter.dev/docs/development/platform-integration/platform-views#performance

Prior to Android 10 AndroidView Should have better performance. if this is the case, maybe we can check the device OS and use AndroidView Instead of PlatformViewLink.

We need more data but in theory this should be better.

@blasten You are more experienced than i Am with platformviews, does this makes sense?

MrAndrixx commented 3 years ago

Can you try same code but with my git version?

  google_mobile_ads:
    git:
      url: https://github.com/SuaMusica/googleads-mobile-flutter.git
      path: packages/google_mobile_ads
      ref: feature/suamusica

Let me know if performance gets any better.

@atrope I tested with your repository and the performance improved a lot. By the way, the tests I do are on an Galaxy s20 with Android 11.

Captura de pantalla 2021-03-12 125015

nickJLm commented 3 years ago

@atrope I am using an Android tablet (Android 7.0), I have profiled with your version it seems to be performing better but not as well as we would like. Unless it is something that we are doing.

With Banners: Screen Shot 2021-03-12 at 12 26 28 PM

Without: Screen Shot 2021-03-12 at 12 36 46 PM

In the list we are using we have images throughout the infinite list as well as banners so even testing with just a list of text widgets and banners we see a drop in frames for every banner drawing on screen:

Screen Shot 2021-03-12 at 12 59 55 PM

atrope commented 3 years ago

I Will also do some tests here and wait for More experient guys to comment here, but feel free to use this version in production. It is battle tested and won't do you any harm. It is performing better you can continue using it :)

DFelten commented 3 years ago

During beta testing of the admob package, we noticed the performance issues and reported them. Unfortunately, the recommendation was simply that we shouldn't display ads within lists below Android 10. Thereupon I've created a workaround, but there seem to be problems with the correct measurement of clicks. It was also said that the account could be flagged with this solution.

For the sake of completeness, here is the workaround with an AndroidView for older Android versions. We've created our own CustomAdWidget with the additional parameter useVirtualDisplay. With the package device_info it would be possible to detect the current Android version and send the bool flag to the CustomAdWidget.

// ignore: implementation_imports
import 'package:google_mobile_ads/src/ad_instance_manager.dart';

class CustomAdWidget extends StatefulWidget {
  const CustomAdWidget({Key key, @required this.ad, this.useVirtualDisplay = false})
      : assert(ad != null),
        super(key: key);

  final AdWithView ad;
  final bool useVirtualDisplay;

  @override
  _CustomAdWidgetState createState() => _CustomAdWidgetState();
}

class _CustomAdWidgetState extends State<CustomAdWidget> {
  bool _adIdAlreadyMounted = false;

  @override
  void initState() {
    super.initState();
    final int adId = instanceManager.adIdFor(widget.ad);
    if (instanceManager.isWidgetAdIdMounted(adId)) {
      _adIdAlreadyMounted = true;
    }
    instanceManager.mountWidgetAdId(adId);
  }

  @override
  void dispose() {
    super.dispose();
    final int adId = instanceManager.adIdFor(widget.ad);
    instanceManager.unmountWidgetAdId(adId);
  }

  @override
  Widget build(BuildContext context) {
    if (_adIdAlreadyMounted) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('This AdWidget is already in the Widget tree'),
        ErrorHint(
            'If you placed this AdWidget in a list, make sure you create a new instance '
            'in the builder function with a unique ad object.'),
        ErrorHint(
            'Make sure you are not using the same ad object in more than one AdWidget.'),
      ]);
    }
    if (defaultTargetPlatform == TargetPlatform.android) {
      if (widget.useVirtualDisplay) {
        return AndroidView(
          viewType: '${instanceManager.channel.name}/ad_widget',
          creationParamsCodec: const StandardMessageCodec(),
          creationParams: instanceManager.adIdFor(widget.ad),
          gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
        );
      } else {
        return PlatformViewLink(
          viewType: '${instanceManager.channel.name}/ad_widget',
          surfaceFactory:
              (BuildContext context, PlatformViewController controller) {
            return AndroidViewSurface(
              controller: controller,
              gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
              hitTestBehavior: PlatformViewHitTestBehavior.opaque,
            );
          },
          onCreatePlatformView: (PlatformViewCreationParams params) {
            return PlatformViewsService.initSurfaceAndroidView(
              id: params.id,
              viewType: '${instanceManager.channel.name}/ad_widget',
              layoutDirection: TextDirection.ltr,
              creationParams: instanceManager.adIdFor(widget.ad),
              creationParamsCodec: StandardMessageCodec(),
            )
              ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
              ..create();
          },
        );
       }
    }

    return UiKitView(
      viewType: '${instanceManager.channel.name}/ad_widget',
      creationParams: instanceManager.adIdFor(widget.ad),
      creationParamsCodec: StandardMessageCodec(),
    );
  }
}
bdlukaa commented 3 years ago

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

Pilaba commented 3 years ago

I'm also experience this, my app performs so bad even on release mode. from normal 50 ~ 45 fps (without the banner) to 20 ~ 14 fps (using AdWidget).

blasten commented 3 years ago

Prior to Android 10, performance can be an issue. We have tested on a range of devices running Android 9 or lower, and found that it really depends. In some cases, 40-50fps.

However, due to technical requirements, we are unable to offer virtual displays for this plugin.

If this is not acceptable, I suggest to load the inlined ad on Android >=10. You can use the device_info plugin to do detection.

adrienbaron commented 3 years ago

@bdlukaa than you so much for the suggestion! Switched to native_admob_flutter and performance is miles better! Also general usage and API is simpler, great find!

Mighty683 commented 3 years ago

I think there should be information in documentation that below Android 10 inline ads are unusable, in my application any try to place such ad is causing performance issues and crashes.

Native_admob_flutter solves problem

adrienbaron commented 3 years ago

@Mighty683 Even on Android 10 (which my Android test phone is using) performance was terrible (adding any Banner Ad slashed FPS from 60 to 30). Switching to native_admob_flutter solved the issue 🤷 .

ehsnaskri commented 3 years ago

Switching to native_admob_flutter

kkorgol commented 3 years ago

Can you try same code but with my git version?

  google_mobile_ads:
    git:
      url: https://github.com/SuaMusica/googleads-mobile-flutter.git
      path: packages/google_mobile_ads
      ref: feature/suamusica

Let me know if performance gets any better.

@atrope With your code performance is a lot better. Checked on Galaxy S9 Android 10 and Emulator API 29, 30. However with your code is also strange issue which doesn't occurs in 'original' package - there is a quick blink of black background in place where ad will show. That occurs shortly before show ad. Any solution? Even after better performance, something like that can broke user experience of the app

bdlukaa commented 3 years ago

@KoNd2i0 That's not an issue with @atrope 's package, but with AndroidView. See https://github.com/flutter/flutter/issues/26771 and https://github.com/flutter/flutter/issues/39797

jangruenwaldt commented 3 years ago

+1 this is really sad for Flutter again - we are since a long time really dissatisified with the performance of all available packages for ads. We were hoping google mobile ads would improve this, but no. The performance is so bad on Android 7, that the app goes from perfectly smooth to unusable. Sad 😢.

sgissinger commented 3 years ago

+1 Any news about merging @atrope upgrades in official repository ? I tested it on Huawei P9 Lite with Android 7.0 and its night and day. UI is smooth again using AdWidget.

CalvinTp commented 3 years ago

I have just integrated version 0.13.0, and the scrolling performance is still bad. Frames dropped when Ads are showing while scrolling in the ListView.

svprdga commented 3 years ago

@atrope I tested your version and the performance has improved a lot. I am going to use your version for now, did you consider to submit it via PR? Your solution should be the official one.

alexismoret commented 3 years ago

I’m using native ads in a listview builder with the 0.13 version of the package, and on an Iphone 12 pro, IOS 14.5, and in release mode, it’s very slow, with a lot of lag when we scroll to an AdWidget, so sadly it’s really not better on last version of ios…

ShashankSMayya commented 3 years ago

Its the same issue with me. When I use AdWidget the app gets crazily slow and lags so much. I tried this in Android 11 in Galaxy S21 Plus in release mode and the results are same. I remove the ads completely and run, it runs smoothly (120Hz screen) so I can see the smoothness. When Ads are active so much of lag. Ill try native_admob_flutter package and see if performance improves.

2shrestha22 commented 3 years ago

It has been a feature since 6 years. 😅 https://stackoverflow.com/questions/31636299/android-ads-slow-performance-very-much

MrAndrixx commented 3 years ago

Its the same issue with me. When I use AdWidget the app gets crazily slow and lags so much. I tried this in Android 11 in Galaxy S21 Plus in release mode and the results are same. I remove the ads completely and run, it runs smoothly (120Hz screen) so I can see the smoothness. When Ads are active so much of lag. Ill try native_admob_flutter package and see if performance improves.

what would be your conclusion? Is that package better?

ShashankSMayya commented 3 years ago

Its the same issue with me. When I use AdWidget the app gets crazily slow and lags so much. I tried this in Android 11 in Galaxy S21 Plus in release mode and the results are same. I remove the ads completely and run, it runs smoothly (120Hz screen) so I can see the smoothness. When Ads are active so much of lag. Ill try native_admob_flutter package and see if performance improves.

what would be your conclusion? Is that package better?

I used the native_admob_flutter and it's definitely better than the google_mobile_ads. My phone is smooth and no lag at all when the ads are placed in the screen or widget tree.

blasten commented 3 years ago

We have added a flag to the Flutter master channel that helps improve the performance.

It's not a perfect fix since the Ad may be a few frames behind the Flutter frame, but depending on the layout you use, it could be useful.

Please try it out, and let us know if the performance is improved.

To use this flag, set PlatformViewsService.synchronizeToNativeViewHierarchy(false). For example:

import 'package:flutter/services.dart';

void main() {
   PlatformViewsService.synchronizeToNativeViewHierarchy(false);
   runApp(MyApp());
}

I'm closing this issue, and moving the conversation to: https://github.com/googleads/googleads-mobile-flutter/issues/269

chitgoks commented 3 years ago

@atrope i can confirm performance is way better. but the issue now is with the ads. it does not resize correctly in tablet mode on orientation change.

plus in phones, ads shown are wide.

bdlukaa commented 3 years ago

@chitgoks you must load a new ad when the orientation changes

chitgoks commented 3 years ago

@chitgoks you must load a new ad when the orientation changes

@bdlukaa call banner.load() right?

the other issue happens tho. the ad shown looks like its for tablet since i have to scroll right to see more of the content. and this is when app is first run. so no orientation happens

yswtrue commented 3 years ago

Can you try same code but with my git version?

  google_mobile_ads:
    git:
      url: https://github.com/SuaMusica/googleads-mobile-flutter.git
      path: packages/google_mobile_ads
      ref: feature/suamusica

Let me know if performance gets any better.

@atrope With your code performance is a lot better. Checked on Galaxy S9 Android 10 and Emulator API 29, 30. However with your code is also strange issue which doesn't occurs in 'original' package - there is a quick blink of black background in place where ad will show. That occurs shortly before show ad. Any solution? Even after better performance, something like that can broke user experience of the app

It works for me

ZotInfo commented 3 years ago

@kuba91 Which Android is S8+ Running?

Can you try same code but with my git version?

  google_mobile_ads:
    git:
      url: https://github.com/SuaMusica/googleads-mobile-flutter.git
      path: packages/google_mobile_ads
      ref: feature/suamusica

Let me know if performance gets any better.

This work full beutiful, thanks.

DanielTerbl commented 3 years ago

@blasten Is there any update on this? Is anyone working on a fix or at least considering one?

atrope commented 3 years ago

@DanielTerbl check #269, the discussion continues there

prateekgupta-fin commented 2 years ago

google_mobile_ads: git: url: https://github.com/SuaMusica/googleads-mobile-flutter.git path: packages/google_mobile_ads ref: feature/suamusica

I tried your package and seems fps is quite good but I faced some scrolling issue with view pager. But kudos to you man, great finding!

RamseyWaverley commented 1 year ago

Have you solved this problem?I have the same problem. 1.request native ad success 2.When displaying the Ad, there will be a delay of 1-2 seconds before the display is successful

Mryuksel101 commented 1 year ago

@DanielTerbl check #269, the discussion continues there

Hey Alan,IHey Alan, I am also experiencing low performance when using AdWidget. That's why I wanted to use your package. I added this package(https://github.com/SuaMusica/googleads-mobile-flutter) to pubspec.yamel. When I start my application I get an error like this; error_screen

pubspec

TiesPol commented 9 months ago

Still facing this issue on Flutter 3.16.5, Dart 3.2.3 and google_mobile_ads 4.0.0. Especially on 120hz iPhone. Only having the scrolling jank when an ad is visible.

onursahindur commented 9 months ago

Still facing this issue on Flutter 3.16.5, Dart 3.2.3 and google_mobile_ads 4.0.0. Especially on 120hz iPhone. Only having the scrolling jank when an ad is visible.

This is such a face palm. Flutter is supported by Google, AdMob is owned by Google, but there is performance issues with using both of them.

I am trying to make a non-lag version of admob banner working with flutter for at least 2 years. I get excited always when a new update comes, but nothing changes.

I just want to show banners inside a SingleChildScrollView after some widgets but even if I am on a iPhone 14 Pro Max the app gets laggy.

I always think that am I doing something wrong?

TiesPol commented 9 months ago

@kuba91 Since people are still experiencing performance issues, I suggest we reopen this issue or create a new one