iOS 14 Crash on using banner ad with google admob on Flutter

Viewed 342

I imagine it can be hard to impossible to say anything about this but I wanted to give it a go anyway. I've just changed to using the google_mobile_ads library in my Flutter application to show banner ads. It works alright although I do see some performance issues in showing these in list. I reckon it is to do with the banner rendering as a webview which I can imagine is pretty slow.

Anyhow, on iOS I get crashes after having scrolled the list up and down quite a lot and it looks from the log as though it might have to do with the ad library.

I'm running on iPhone OS 14.4.2 (18D70) on a iPhone8,1. This is the log I get:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Application Specific Information:
abort() called

Last Exception Backtrace:
0   CoreFoundation                  0x1a08b19d8 __exceptionPreprocess + 216
1   libobjc.A.dylib                 0x1b4c34b54 objc_exception_throw + 55
2   CoreFoundation                  0x1a091bd98 _CFThrowFormattedException + 111
3   CoreFoundation                  0x1a09271f4 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.4 + 47
4   CoreFoundation                  0x1a07ac8a8 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 239
5   CoreFoundation                  0x1a079fc04 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 55
6   Runner                          0x1006d7688 -[FLTAdInstanceManager onAdLoaded:responseInfo:] + 2340488 (FLTAdInstanceManager_Internal.m:82)
7   Runner                          0x1006d5268 -[FLTBannerAd bannerViewDidReceiveAd:] + 2331240 (FLTAd_Internal.m:207)
8   Runner                          0x1005ef224 GAD_GADBannerView_arm64_8_5_0 + 5139
9   Runner                          0x1006433f8 __destroy_helper_block_e8_32s40s48s56s64s72w + 159

Not sure if it could have to do with how I load the ad, but I've pretty much followed the example on the official codelabs. It looks like this:


void initState() {
  super.initState();

  final adUnit = DebugPlaceholder.isDebugMode
    ? debugAdUnit
    : liveAdUnit;

  _ad = BannerAd(
      adUnitId: adUnit,
      size: AdSize.largeBanner,
      request: AdRequest(),
      listener: BannerAdListener(
        onAdLoaded: (_) {
          setState(() {
            _adLoaded = true;
          });
        },
        onAdFailedToLoad: (ad, error) {
          _ad.dispose();
          print('Ad load failed (code=${error.code} message=${error.message})');
        }
      )
  );

  _ad.load();
}

@override
void dispose() {
  _ad.dispose();
  super.dispose();
}

@override
Widget build(BuildContext context) {
  if (!_adLoaded) return Container();

  return Container(
      color: Colors.white,
      alignment: Alignment.center,
      height: _ad.size.height.toDouble(),
      width: _ad.size.width.toDouble(),
      child: AdWidget(ad: _ad)
  );
}

Any tips, even if not on the actual problem but on how to troubleshoot it greatly appreciated!

0 Answers
Related