-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Platform-View List / Grid scrolling is janky on IOS / Android #107486
Comments
I have the same problem #103014 |
+1 Also experiencing this issue and require the exact same use case as described above. |
Hi @Nico3652, Thanks for filing the issue. Could you please share a minimal and complete sample project so that we could directly run the sample app? Also there have been recent updates to platform views, So I would suggest checking the performance on the latest master channel by running
|
Hello @maheshmnj and thanks for reply. I've updated my issue with the link of the sample app containing the full code which you can clone. I tried the channel master but the problem is still present unfortunately. |
Thanks for the code sample @Nico3652, I do see the lag on the master channel too, But I believe this is the same issue as #103014 which uses Native ads using platformview. So I think we can track it as a duplicate? Screen.Recording.2022-07-14.at.11.25.54.AM.movflutter doctor -v (mac)
|
This issue is focused on the platform view performance impact in its generality and not only for the Native ads SDK. Solve the platform view issue will certainly also solve the ads performance but I'm not sure the other way around. |
Agreed, the Native ad issue appears to be a symptom of this more general performance problem, not the other way around. |
Thanks for the clarification @Nico3652, Labeling it as a platformview performance issue on IOS. Perhaps for Android, we should track it separately. Sample project can be found here native_view_project.zip
flutter doctor -v (mac)
|
@cyanglaz do we have any benchmarks for this? |
I think we do: https://github.com/flutter/flutter/tree/master/dev/benchmarks/platform_views_layout |
This issue is preventing me from going in production unfortunately |
@Tom3652 iOS PlatformView requires all flutter compositing happen on the main thread, which slows down the performances, especially when there are many platform views in a scroll view. May I ask what content are you trying to display as PlatformViews? Is there a way to make them non-platformView flutter widgets? |
@cyanglaz One use case that concerns me is the display of ads that run entirely through Platform Views and not through Flutter Widgets. |
My use case is essentially identical to that of @Tom3652 - Native Google Ads in a stream of content, although I can imagine there would be requirements for other native views in such a feed. |
Hey guys, The Android platform views are fixed to a degree. I think the Flutter teams should really prioritize these issues. Most of the attention now are given to expanding flutter to more platforms (web, desktop), even when the initial platforms (iOS, Android) are not perfectly executed unfortunately. Hope we can see a solution in the near future. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Let's keep conversation focused on the performance issues related to platform view threading model on iOS. Please avoid adding noise to GitHub issues. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I have a similar problem too. #114010 The difference is that on non-ProMotion devices (e.g., iphone8) it's smooth with barely perceptible jitter. However, there is noticeable jitter on the ProMotion device (e.g., iPhone13 Pro Max). @cyanglaz Here it seems to be more than just platform view performance issues. |
iPhone 8iPhone 13 Pro MaxActually, non-ProMotion devices will also experience jitter, but not as visible to the naked eye as ProMotion devices. flutter doctor -v
|
Capturing from offline discussion: the two main potential sources of perf issues here are:
As a next step here, we should compare perf of the scroll-lots-of-native-views test in the original report to scrolling the same list with just widgets, but with a platform view persistently on the screen, to isolate just the thread-merging part, to see to what extent each contributes to the issue. |
Performance comparison between multiple scenarios with iPhone 13 pro, with Flutter dev tools:
2* 5 PlatformViews, with the PlatformViews stationary
4*. 30 PlatformViews in the list, no creation destruction during scrolling.
My observations:
In summary, 2 things are happening that contributes the performance reduction.
The next step would be to find where in PlatformView's code takes long time during animation. My gut says it is either ApplyMutator is slow, or unnecessary overlays are created in SubmitFrame |
I found that setting the maskView is one of the bottlenecks that lowering down the performance, here I have tried removing all the clipping logic and just setting the maskView, the performance is still as bad. Masking is the probably the best way that I could find to clip a UIView. I'm not sure if we can avoid masking if we want to support clipping. One thing that we might be able to optimize is to pre-calculate the final clip path for the PlatformView, check if the PlatformView's frame is completely inside the final clip path, and do not set the mask view if that is the case. I will start prototype this and see if it increases performance. I believe (and hopefully) it will enhance performance for regular scrolling scenarios. Although it won't help if the App wants to do fancy clippings while scrolling. (For example, adding a clipRRect for each PlatformView in the ListView) |
The draft is ready at flutter/engine#37434. I have tested the performance with flutter dev tools it seems to have a significant performance increase while using the example app. It would be great If anyone else can verify if it fixes the visual janks for their app. |
Frame stuttering in PlatformView is far less noticeable on non-ProMotion devices than on ProMotion devices. It might be a not-bad optimization option if we could lower the refresh rate to 60Hz for pages containing PlatformView. :) |
Hi @cyanglaz and thanks for working on this ! I am sorry but i am not sure on how to proceed to test your draft ? I would like to |
You can compile a local engine with @cyanglaz's patch (see https://github.com/flutter/flutter/wiki/Compiling-the-engine for details). Working from home due to COVID-19, I only have an iPhone 8, no ProMotion device. Since the iPhone 8 has no noticeable stutter even without the patch, I can't verify that well either. |
I mean rendering at a refresh rate depending on the context of what is being rendered. See #90675 (comment) for more details. @cyanglaz @iskakaushik Do you guys have further plans? :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
My team and I are facing troubles for a while trying to implements native views inside scrollable content in our App.
The real problem here is that the Platform View rendering is very heavy and as a consequence the scrolling animation make it visible on screen by lag / freezing the UI.
So when native views are placed into ListView / GridView, the entire screen start to freeze because of performance.
Here are 2 videos to illustrate my words. A simple ListView with widgets inside.
The first contain Flutter widgets and the second Native views.
FLUTTER :
Simulator.Screen.Recording.-.iPhone.12.Pro.Max.-.2022-07-12.at.20.25.20.mp4
Simulator.Screen.Recording.-.iPhone.12.Pro.Max.-.2022-07-12.at.20.26.00.mp4
This is a completely empty App so the freezing could may be not very pronounced here but a simple app with common content (ex: users/photos) is much more impacting.
It was record on IOS but clearly tested on Android too and the problem still persist.
Our App is a full social media (photo / video / story) and when we are trying to add native view inside lists, this app quickly become unusable.
Here are linked issues #96679 (which should not be closed)
GOOGLE ADS SDK
Also currently trying to provide Ads into our Social Media app between photo and videos lists, the performance issue is even worse than the recorded example here while scrolling or animating other components.
ADS are provided with Platform View so the problem is remaining once again here, and this is very restrictive for us because we can not go in production version without ADS and native view because of business model.
Linked issues :
googleads/googleads-mobile-flutter#269
googleads/googleads-mobile-flutter#313
This issue should have a high priority level taking into account the huge impact for company or developers teams into their app.
Thank you.
-- FULL CODE --
https://github.com/Nico3652/native_view_project
-- FLUTTER DOCTOR --
The text was updated successfully, but these errors were encountered: