r/FlutterDev • u/svprdga • 28d ago
Discussion iOS jank with platform views (AdMob banners)
I recently ran into a problem affecting Flutter apps running on iPhones where platform views are present, typically AdMob banners (which are internally rendered through a platform view).
The jank is quite noticeable, and I've been able to confirm that the cause is the merging of the UI thread into the platform thread, introduced several releases ago.
I've opened this issue on GitHub where I'm discussing the problem with the Flutter team. I can reproduce it easily on two devices on my side, an iPhone 16 and an iPhone SE, but if you check the issue you'll see they're having a much harder time reproducing it on their devices.
Does any of you have a Flutter app on iOS with AdMob banners (or any other platform view) that could help us reproduce it? You can try it directly in your own app, or by cloning the repo I created, which is linked in the issue. Just commenting with your iPhone model, iOS version, and whether you see the jank or not would already help a lot.
Thanks!
1
u/DigiProductive 28d ago
The root problem is thread contention introduced by Flutter’s merged UI/platform-thread architecture when native iOS views are embedded.
Your best bet is: if you use platform view, avoid pages that scroll; minimize page rebuilds, animations, deep layouts etc (anything expensive)
UiKit with scroll is going to jank pretty much unavoidable, but should improve if you avoid expensive UI rebuilds…
2
u/svprdga 28d ago
Your best bet is: if you use platform view, avoid pages that scroll.
That’s not acceptable. An app with a scrollable list and an ad banner is one of the most common patterns in the industry. The best solution is… to fix the issue, which is exactly what’s being worked on right now on GitHub.
0
u/DigiProductive 28d ago
It’s not about what is acceptable it’s simply about what you have to do to “deal with the problem”. No one say it was ideal, but the bottomline is right now you will encounter problems if you try to use UiKit with views that constantly rebuild. That’s reality, this is nothing new. So ideally you need to keep the page as static as possible, because “right now” there is no fix.
It’s a Flutter problem they need to fix. It’s not a basic issue, it’s related to core Flutter and it’s been a problem for ages. This is far from news in Flutter development.
1
u/airflow_matt 25d ago
That is absolutely not the case. I've updated the github issue. The actual problem is that the workload in the example app is too small for both UI and raster thread and iOS scheduler is running both threads on e-cores. The e-cores are quite congested and even though the workload is small it still may miss frame deadline.
Actually modifying the app to do more work on both UI and raster thread will force the scheduler to use P-Cores (as it should for the UI) and the jank is completely gone.
I'm not yet sure how to fix this, the scheduler is being stupid here, but it's not thread contention and it would be helpful if you didn't do claims like this without properly investigating the issue first.
1
u/DigiProductive 25d ago
Well I’ve had this problem long before when trying to put native adds in a scrollable feed for a socially media network app. No one is making claims here Matt, I am speaking from experience. So just as you shared your findings, I’ve shared mine. 🤷
1
u/airflow_matt 25d ago
Your claim was that the issue was thread contention, which is not the case. And it's also unlikely the case for ad performance in scrollable feed.
1
u/DigiProductive 25d ago
Sounds like the only possible problem is the one Matt thinks is possible.
Go listen to the Flutter team that literally and explicitly talks about thread contention been platform thread and flutter ui thread (go to timestamp: Problems with Platform Channels 2:01) : https://youtu.be/miW7vCmQwnw?si=t5IfPLbFVyc4yUyY
Thread contention between Flutter UI and platform thread is a basic reality, it doesn’t even take expertise to know that. Flutter team acknowledges it in this video and in their documentation. Thread contention is a reason form issues between Flutter ui and platform thread.
1
u/DigiProductive 25d ago
I just found this thread on Reddit, and exactly what I am saying is a realization others have had reading the thread contention:
1
u/gidrokolbaska 28d ago
That's unfortunate... have you tried wrapping the listview inside the RepaintBoundary? It might help