Skip to content

[iOS] - Ad Click Listener Breaks After Scroll Initiated on Ad (GAM Rich Media in Flutter ListView) #165787

@PaananenReko

Description

@PaananenReko

Steps to reproduce

Description
Rich media ads served through Google Ad Manager stop responding to click events after a ListView is scrolled, provided that the scroll starts from the ad widget. This issue occurs specifically in Flutter apps but does not appear in fully native iOS applications.

Steps to Reproduce

  1. Create campaign in GAM with provided ad code.
  2. Embed ad from Google Ad Manager inside a Flutter ListView.
  3. Ensure that text inside the ad is updated correctly when interacting with button inside the ad without scrolling the listview
  4. Scroll the ListView, starting the gesture from the ad widget.
  5. Try clicking the button with in the ad

Affected Platforms
✅ iOS (Flutter app & iOS platform views)
❌ Does not occur on fully native iOS apps

Observations

  • Touchend event is not triggered on flutter app when touch is stopped. Once user taps background of the ad the touchend event is triggered.
  • On fully native iOS app the touchend event is triggered once the user interaction stops.

Tested on
Flutter version: 3.29.0
Platform: iOS (18.4)

Expected results

Expected Behavior

  • The text should update correctly when clicking the button in the ad (indicating that click event listener is triggered).

Actual results

Actual Behavior

  • The ad’s click event listener no longer works after scrolling if the touch started on the ad widget.
  • The issue also occurs when rendering the ad inside a Flutter plugin using a platform view on iOS.

Code sample

Test Ad Script for GAM campaign:

<script>
 var newDiv = document.createElement('div');
 var textSpan = document.createElement('span');
 var newContent = document.createTextNode('Initial state');
 textSpan.appendChild(newContent);
 newDiv.appendChild(textSpan);
 newDiv.appendChild(document.createElement('br'));
 document.body.appendChild(newDiv);

 var button1 = document.createElement('button');
 button1.textContent = 'Example button';
 button1.style.cssText = 'width: 200px; height: 100px; margin-bottom: 25px;';
 newDiv.appendChild(button1);

 button1.addEventListener('click', function () { textSpan.textContent = 'Clicked'; });
 button1.addEventListener('touchstart', function () { textSpan.textContent = 'Touch Started'; });
 button1.addEventListener('touchend', function () { textSpan.textContent = 'Touch Ended'; });
</script>

Screenshots or Video

Screenshots / Video demonstration

iOS app
https://github.com/user-attachments/assets/5a0f535d-3503-4421-80b4-7992a639e37b

Flutter app
https://github.com/user-attachments/assets/0a868956-da4d-4600-a801-7a2bc13f6d6c

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.0, on macOS 14.2 23C64 darwin-arm64, locale fi-FI)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.4)
    ! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.98.0)
[✓] Connected device (4 available)
    ! Device emulator-5554 is offline.
[✓] Network resources

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsf: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions