googleads / googleads-mobile-flutter

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

Crash on specific ads when scolling (iOS) #885

Closed Navil closed 1 year ago

Navil commented 1 year ago

[REQUIRED] Step 1: Describe your environment

Plugin Version

3.0.0, but also happened before

Platform

It only happens on iOS

[REQUIRED] Step 2: Describe the problem

Steps to Reproduce

  1. Have Ads in a Carousel on iOS
  2. Scroll very fast
  3. Crash

It does only happen with specific ads and when scrolling to the ad fast.

Crash: https://github.com/googleads/googleads-mobile-flutter/assets/3436399/a551eb58-9221-4ac4-8839-5ff2a1e60427

No Crash: https://github.com/googleads/googleads-mobile-flutter/assets/3436399/25d363f2-1011-4e34-ae50-e6f9e3a51c43

Expected results: The app should not crash

Actual results: The app crashes

Sentry output

As I cannot reproduce it locally and it only happens with specific ads, here the information I found on sentry: image

The loaded ad: (I dont know what data I can show here publicy so I replaced ca-app-pub and my App name)

GET https://googleads.g.doubleclick.net/mads/gma?os_version=16.2.0&ms=0vqgtZvOsjtfWEaGuKj2nSJyNA9JJ-u6W8wYCXivrdDa64baKKTq8Vue8hhewQKuoh8R_nnb4i-A0MUoIx__tBuA3hB7C96FwFMEvO4zx9p5nZj2LYd6DWDJcYN21pm-iAT860NSrSeqYSE8K_CCrZf0nXBrnQE7k7ABe6CURRgW1Hu3ijIARsBWcmxAomil-xfUbahEWn-p8wqvOtDp4M2Pk6irG6C5REFeKqdyorbcYloZIXCpIMoWC0jMsnA0E4_GlTSCCSyggN6pqN2K_uIFxKXl60QbwQTJdTrdnX4z9NykiRvXFwPBkwpmwfQ1O36UBMvinOK65qLZBhmaJA&u_so=p&omid_v=1.3.37-google_20220829&submodel=iPhone14%2C3&request_agent=Flutter-GMA-3.0.0&eid=318502621%2C318508243%2C318500618%2C318494274%2C318507075%2C318508442%2C44766145&net=ed&u_sd=3&js=afma-sdk-i-v10.4.0&fbs_aiid=98183EDA9E9F4BA39408C2BFB56E651C&u_h=926&fbs_aeid=-2172664942540844694&u_w=428&guci=0.0.0.0.0.0.0.0&attmas=denied&sdk_apis=7%2C8&omid_p=Google%2Fafma-sdk-i-v10.4.0&format=308x926_mb&rafmt=103&an=1.7.5.iphone.at.navil.myApp&u_audio=1&swipeable=1&isv=16.2&skan=cstr6suwn9%2C4fzdc2evr5%2C4pfyvq9l8r%2C2fnua5tdw4%2Cydx93a7ass%2C5a6flpkh64%2Cp78axxw29g%2Cv72qych5uu%2Cludvb6z3bs%2Ccp8zw746q7%2Cc6k4g5qg8m%2Cs39g8k73mm%2C3qy4746246%2C3sh42y64q3%2Cf38h382jlk%2Chs6bdukanm%2Cprcb7njmu6%2Cv4nxqhlyqp%2Cwzmmz9fp6w%2Cyclnxrl5pm%2Ct38b2kh725%2C7ug5zh24hu%2C9rd848q2bz%2Cy5ghdn5j9k%2Cn6fk4nfna4%2Cv9wttpbfk9%2Cn38lu8286q%2C47vhws6wlr%2Ckbd757ywx3%2C9t245vhmpl%2Ca2p9lx4jpn%2C22mmun2rn5%2C4468km3ulz%2C2u9pt9hc89%2C8s468mfl3y%2Cav6w8kgt66%2Cklf5c3l5u5%2Cppxm28t8ap%2C424m5254lk%2Cecpz2srf59%2Cuw77j35x4d%2Cmlmmfzh3r3%2C578prtvx9j%2C4dzt52r2t5%2Cgta9lk7p23%2Ce5fvkxwrpn%2C8c4e2ghe7u%2Czq492l623r%2C3rd42ekr43%2C3qcr597p9d&loeid=44766145&preqs=32&seq_num=34&time_in_session=7050&preqs_in_session=32&pcc=0&sst=1689493200000&output=html&region=mobile_app&u_tz=480&content_url=https%3A%2F%myApp.com&client=ca-app-pub-XXXXXXXX&slotname=4942428503&hl=en&gsb=4g&ogsb=4g&apm_app_id=1%3A247129465780%3Aios%3A67a503429cb484491848e1&gmp_app_id=1%3A247129465780%3Aios%3A67a503429cb484491848e1&apm_app_type=1&app_wp_code=ca-app-pub-XXXXX&app_code=4521957808&caps=interactiveVideo_inlineVid... [200]
{
reason: no error, 
request_body_size: 0, 
response_body_size: 0
}

As mentioned, it does not happen with all ads. The ad above is one where is crashes and we can consistently reproduce it on production when those apps are offered.

I can send the full Sentry event if needed.

``` ``` Resolving dependencies... _fe_analyzer_shared 61.0.0 (62.0.0 available) analyzer 5.13.0 (6.0.0 available) cancellation_token 1.6.1 (2.0.1 available) collection 1.17.1 (1.17.2 available) dots_indicator 2.1.2 (3.0.0 available) dropdown_button2 2.1.4 (2.3.5 available) file 6.1.4 (7.0.0 available) injector 2.0.0 (3.0.0 available) intl 0.18.0 (0.18.1 available) matcher 0.12.15 (0.12.16 available) material_color_utilities 0.2.0 (0.8.0 available) objectid 2.1.0 (3.0.0 available) source_span 1.9.1 (1.10.0 available) stack_trace 1.11.0 (1.11.1 available) stream_channel 2.1.1 (2.1.2 available) stylish_bottom_bar 1.0.0 (1.0.3 available) test_api 0.5.1 (0.6.1 available) visibility_detector 0.3.3 (0.4.0+2 available) ! webview_flutter_wkwebview 3.5.0 (overridden) (3.7.0 available) ``` ``` Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.19045.3208], locale de-AT) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1) [√] Android Studio (version 2021.2) [√] IntelliJ IDEA Ultimate Edition (version 2020.3) [√] VS Code (version 1.80.0) [!] Connected device ! No devices available [√] Network resources ! Doctor found issues in 1 category. ``` ```
huycozy commented 1 year ago

Hi @Navil Are you implementing native ads in the carousel?

You should narrow down the issue by removing the usage of 3rd party plugins/packages one by one, unrelated/unaffected pages, and isolating the affected page/widget that can be run independently. If the issue's still reproducible, please provide that main.dart file.

But if it can't be reproducible locally, please try to get the complete crash stack trace in text format and share it here so that we can verify the issue properly. Thank you!

Navil commented 1 year ago

Thank you for your input @huycozy , I am not using native ads. Once I disabled "Video" ads, the crash disappeared. image And we are able to reproduce it with specific ads once we enable it again. The video on top shows such an ad. Also quite interesting is, that is only happens on iOS.

Is there a way I can forward you the entire sentry event (with stack traces) somewhere as I am not sure if it contains any sensitive data?

huycozy commented 1 year ago

What kind of ads are you implementing there in the carousel? (banner ad, native ad).

I guess this issue is not reproducible with test ad id, right? In this case, can you please try running project in release mode (--release) to see if the crash can be reproducible? If it appears, please share the crash stack trace here or you can share it to my email (in my GH profile) so that we have more information to investigate the issue. Thank you!

Navil commented 1 year ago

It is a banner ad. I will sent you the sentry event.

I will try to reproduce it in release mode.

huycozy commented 1 year ago

Does the crash occur in release mode?

Spotlighted log (received log via email) ```console ..... "environment": "production", "exception": { "values": [ { "type": "NSInvalidArgumentException", "value": "*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil", "stacktrace": { "frames": [ { "function": "", "in_app": false, "data": { "symbolicator_status": "unknown_image" }, "image_addr": "0x0", "instruction_addr": "0x1046fc4d0", "symbol_addr": "0x0" }, { "function": "main", "symbol": "main", "package": "/private/var/containers/Bundle/Application/230D9BF8-A046-4566-930E-40EA893E8E8A/Runner.app/Runner", "filename": "AppDelegate.swift", "abs_path": "/Users/runner/work/aupair/aupair/ios/Runner/AppDelegate.swift", "lineno": 5, "pre_context": [ "import UIKit", "import Flutter", "", "@UIApplicationMain" ], "context_line": "@objc class AppDelegate: FlutterAppDelegate {", "post_context": [ " override func application(", " _ application: UIApplication,", " didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?", " ) -> Bool {", " GeneratedPluginRegistrant.register(with: self)" ], .... ```

I received the log you sent to me via email. It seems the crash occurs on AppDelegate.swift file at line 5th. Do you implement any other code there? Can you please also share the code in ios/Runner/AppDelegate.swift? (You should remove any sensitive code if any)

Navil commented 1 year ago

Hey the code in there looks like this:

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
huycozy commented 1 year ago

The code looks normal and nothing seems to cause the crash here. Please check this in release mode. If it's reproducible, please provide the complete output of flutter run --release -v. Thank you!

Navil commented 1 year ago

I do not have an iOS device and the emulator tells me: Release mode is not supported by iPhone 14 Pro Max. Any other thing I could do to help in the investigation?

huycozy commented 1 year ago

Yes, you can't run release mode in the emulator/simulator. Unfortunately, it seems there is no other choice. Providing a full stack trace by running locally will help us better investigate the issue.

github-actions[bot] commented 1 year ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.