Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios][platform_view][admob] Recycle admob banners #158944

Open
hellohuanlin opened this issue Nov 14, 2024 · 3 comments · Fixed by googleads/googleads-mobile-flutter#1275
Open
Assignees
Labels
a: platform-views Embedding Android/iOS views in Flutter apps P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@hellohuanlin
Copy link
Contributor

hellohuanlin commented Nov 14, 2024

Use case

A while back we compared the performance between Flutter and Native ad banners in a scrollable list. On native, it is very easy to recycle the ad banners like this:

func viewDidLoad {
  cachedBanners = (0..<10).map { _ in 
    let banner = GADBannerView()
    banner.loadRequest()
    return banner
  }
}

func cellForRowAtIndexPath() {
  let banner = cachedBanner[indexPath.row];
  ...
}

Side note: in this native implementation, I load 10 requests upfront in viewDidLoad, which isn't ideal. It'd be great if we can improve it by loading it lazily.

Proposal

Recycle ad banners in Flutter.

Potential work can be either (pending investigation):

  1. No change (maybe we already support it?). Though we will need to document how to do it.
  2. Change to AdMob plugin
  3. Change to Flutter's platform view.
@hellohuanlin hellohuanlin added platform-ios iOS applications specifically a: platform-views Embedding Android/iOS views in Flutter apps team-ios Owned by iOS platform team labels Nov 14, 2024
@hellohuanlin hellohuanlin changed the title [ios][ad][platform_view]recycle admob ad banners [ios][ad][platform_view]recycle admob banners Nov 14, 2024
@hellohuanlin hellohuanlin changed the title [ios][ad][platform_view]recycle admob banners [ios][platform_view][admob] Recycle admob banners Nov 14, 2024
@jmagman jmagman added P2 Important issues not at the top of the work list triaged-ios Triaged by iOS platform team labels Dec 18, 2024
@hellohuanlin
Copy link
Contributor Author

Update: I was able to get it working by some quick and dirty change in the plugin. Next up I will try to optimize it by loading the ads lazily, rather than loading 5 ads on app launch.

Video_20250128_150655_743.mp4

@hellohuanlin
Copy link
Contributor Author

Update:

I was able to get lazy loading working. The original approach didn't work, so I came up with a new (and simpler) approach. The new approach doesn't change iOS specific code anymore, so it should also works on Android (which is great).

Next up: I bought an Android device (still waiting for delivery) and will make sure it actually works. Will update here.

@hellohuanlin
Copy link
Contributor Author

Update: I have just verified the same solution works for Android, and currently working on measuring the performance improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: platform-views Embedding Android/iOS views in Flutter apps P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
Status: Ready
Development

Successfully merging a pull request may close this issue.

2 participants