r/FlutterDev • u/AAkhtar • Feb 17 '21
Discussion iOS jank - Reproducible example
https://github.com/flutter/flutter/issues/7618021
u/serial_dev Feb 17 '21
We had the exact same issue at my former company (and many of my friends complained about their apps, too). The mobile app had some beautiful animations (IMO, but I'm obviously biased), but the whole animation had like 3 frames rendered on a 1000+ USD phone on the first animation. It's a terrible first impression. When you triggered the animations a couple of times, it was smooth, though.
The frustrating part was how people automatically assumed I messed something up with the animations, and asked me to look into it. Well, I did, watched, and read everything performance and animation related. It's nothing I can solve on my own!
The issue is present on both iOS and Android, except it's 100x worse on iOS. The main reason for that (IIRC) is that on Android, the first animation(s) after installation is slow, whereas on iOS every time you open the app, the first animation(s) are very slow.
Another negative is that it counts for every different animation. If you have multiple different (hopefully beautiful) animations, all of those will jank like crazy the first couple of times they run. All the effort for nothing, people will ask: "which cross-platform tool did you use?". Very embarrassing.
The SkSL warmup is also mostly useless: you would need to create the warmup files manually (the last time I checked), and they wouldn't even help on modern iOS devices (where the issue is the worst, and all the potential investors had modern iOS devices).
For people who were asking if Flutter is still a good choice: in my opinion, our startup wouldn't even have an app now if it wasn't for Flutter. Other parts of Flutter are amazing, such as hot reload, Dart, the language is amazing yet simple. Writing plugins is also extremely easy and most often the existing plugins are good enough (and if it isn't, it's easy to fork, patch, and use that).
6
u/eseidelGoogle Feb 22 '21
I agree with this assessment. I'm sorry for the trouble. We are working to finally address this longstanding first-run issue (on iOS and Android as you suggest).
SkSL warm-up was a solution we pursued for the Google Assistant launch hoping it to be more generically useful. It proved not to be, as you've discovered. I expect we will remove/replace that solution with whatever more general approach the team lands on as part of our current efforts.
Thank you for your continued patience. I'm glad Flutter has otherwise worked well for you.
1
u/AAkhtar Feb 18 '21
I actually don't think quitting the app resets the shaders on iOS. Would love to learn if I'm wrong. It might just be that the shader performance is worse on iOS than Android since they're using Metal vs OpenGL.
4
u/escamoteur Feb 18 '21
Nope, Metal is actually faster than OpenGL, that isn't the problem. But indeed currently the shaders are compiled on every start
2
1
u/eseidelGoogle Feb 22 '21
My understanding is there are multiple layers of caching. I'm not sure which are reset when without asking someone on the right subteam. Moving from OpenGL to Metal we lost one of the layers of caching. I would expect to see worst behavior on first run of first install, and after that smooth behavior of animations on Android. On iOS second-run should be improved behavior, but not as smooth as Android (due to lack of a metal-compatible shader cache), is my understanding.
First run shader jank, as discussed, is not the only cause of jank. It's possible to have animations which are always janky (even after shader compile) for other reasons. But we're going to do our part to help remove the first-launch shader jank as an issue to start.
https://github.com/flutter/flutter/issues/74630 is a bug tracking moving shader compilation out of the first-draw path.
13
u/riveraj33 Feb 17 '21
Would it be recommended to move off of flutter for a startup? We are halfway through our app and have a concern of a poor user experience. Our app can be classified to be the social media type. A smooth experience is important. Any chance this will be fixed this year?
14
Feb 17 '21
I'm currently the CTO for 2 Startups, unless you can measure the actual impact of the decreased user experience and translate that into costs I would stay on track with Flutter and find workarounds.
Startups in general should not aim at perfection but growth, if you feel growth is staggered due to this particular issue you should measure through A/B testing or any other way that objectively supports your decision.
3
u/Creative-Trouble3473 Feb 20 '21
I totally agree with you, BUT, if you're a professional services company and offer your clients Flutter solutions, and your clients start Googling "what Flutter is" and come across posts like this (or videos like this one: https://youtu.be/L3iqmyoogfA), you will have a HARD time explaining how great Flutter is.
1
Feb 20 '21
I understand your point but you are missing the key issue which is "compared to what?"
1
u/Creative-Trouble3473 Feb 20 '21
Compared to native. Or even Xamarin - many popular Xamarin apps are pretty smooth. Or web. There are choices aplenty, but the right solution will always depend on the nature of the project. Right now a web Flutter app in Safari is sometimes smoother than a native app.
1
Feb 20 '21
Are you not gonna take into account costs + time to market?
6
u/Creative-Trouble3473 Feb 21 '21
Again, this depends on the project. I developed one app in native iOS, and the Android app was developed by me and two other developers (one junior, one senior) in Flutter. The iOS app took me around 1 year to complete, and the Flutter app took us around 9 months - with 3 developers working on it and with well-established requirements (which I cannot tell about the iOS app).
Yes, it is faster to hot-reload everything, but the time spent writing native bridges, trying to figure out build issues, managing Flutter upgrades, and no good quality content on Flutter development, meant it actually took us more time than the native iOS. But, I also think that native Android would take us even more than that. In fact, that's where we started with 1 developer and saw no major progress in 3 months and decided to switch to Flutter.
Now, we decided to go 100% Flutter, but we have a lot of experience - new teams starting using Flutter might still struggle and take more time to develop Flutter apps. Projects that involve more native code, e.g. MAM integration, data security, etc. might not see too much benefit in being written in Flutter. Even if there are native plugins available, I'm often the one who ends up rewriting them and fixing bugs (most on Android as people don't understand the Android lifecycle well). However, if you have complex and custom UI, then yes, I'd say Flutter is a good choice. But you do need an experienced developer to mentor mid-level and junior devs if you plan to take on more complex projects
Btw. we haven't heard our clients complaining about poor animations. I complain, bu I'm a pedantic developer. My PM thinks I'm obsessed.
In my personal opinion, Flutter is much easier than old-fashioned native Android. It's perhaps on par with modern (read: fully Jetpack) Android development, but I would favour Flutter as I can get an iOS app at almost no extra cost. It's better than Xcode's storyboards. But it's WAY behind SwiftUI's simplicity.
I'd say: use whatever you're most comfortable with. But know your tools and don't assume you can get there with Flutter if you haven't got enough Flutter experience yet. It's a great framework, but the road isn't smooth yet.
1
1
u/AAkhtar Feb 17 '21
I'm in exactly the same boat. At this point I'm continuing, will wait to see how the animation heavy aspects of my app look and if any of the workarounds w/ loading animations during splash screens work.
Have you been able to test your app on iOS devices?
3
u/riveraj33 Feb 17 '21
I have and can see the stutters. Even apps already on the AppStore built with flutter have these stutters, like eBay motors. So many great aspects of flutter but I’m so disappointed in the fact that it’s not native smooth.
2
u/AAkhtar Feb 17 '21
Do you plan on trying the workaround? Apparently you can load your widget in a background layer on a stack and run the animation there during a fake splash screen - wait 300 ms after init.
2
u/riveraj33 Feb 17 '21
Yes thanks for mentioning that. I will try that workaround. If it works well or at least greatly improves it I’ll stay on flutter.
2
u/AAkhtar Feb 17 '21
I'd love to hear how that goes if you try it. I'm not far ahead enough yet with my app.
2
2
u/Scharesoft Feb 19 '21
That's a good idea. Is there anywhere a good example for such background layer?
6
2
u/more-food-plz Feb 18 '21
I would stick with it. I think the flutter team will come up with some work arounds and things will get better. Once your app takes off with millions of users you can rebuild separate native apps for Android/iOS 😉
1
Feb 17 '21
You can work around this by profiling and precompiling shaders. Kind of sucks but I definitely wouldn't move away from Flutter for this. Especially for a startup where you don't even know if people will want your app in the first place.
13
u/syscom13 Feb 17 '21 edited Feb 17 '21
Does this iOS jank issue really have an impact from a user/business perspective? I am not so sure.
Just look at Fastic. They are doing pretty well in terms of revenues: $1.6 million in revenues in January alone. They are probably one of the most successful Flutter-based app out there.
From their users perspective? When I'm looking at their rating on iOS (4.7/5 from 100k users) I can't really see anyone complaining about this specific problem. Or about the fact that the app doesn't feel "native". Fact is: 99% of users don't even know what native is.
My point is: yes, from a developer perspective, this is extremely annoying. But do users really care or notice? Genuine question.
Edit: spelling
2
u/AAkhtar Feb 18 '21
Depends on your app / market. E.g I'm working on a consumer app, for people with ADHD. Having jank and making people wait during the onboarding would basically kill my app. They won't get thru onboarding.
3
u/mihaelamj Feb 19 '21
They do, of course. that is why they pay extra for iOS devices.
2
u/syscom13 Feb 20 '21
Fastic and Reflectly both suffer from this specific issue. It is quite noticeable with Reflectly due to the heavy amount of animation they have implemented. But when you look closely at their users comments for the iOS version on Sensortower (for instance), this problem does not surface in the feedback about the UX.
In fact, people seem pleased with the UX and UI (with both Fastic and Reflectly). As for those leaving negative ratings, well, they are mostly complaining about the subscription's price... So I'm not so sure about this assumption.
1
u/mihaelamj Feb 21 '21
If the service is unattainable any other way, then yes, clients have no choice. Until a similar service with a better UI appears.
5
Feb 19 '21 edited Feb 19 '21
according google devs not recommend to use it, but my short-term solution is disabling metal and use opengl. I use this version: https://github.com/acoutts/flutter-engines-no-metal/tree/master/1.22.3 of the engine and haven't any problems with animations and performance. Right now my app using by 1000 iOS users and about 2000 android users. Another thing you can try is run animations behind the splash screen. Here is example and it work! https://gist.github.com/Renesanse/1572e5090075fd79251d4fd4543d7274
1
u/AAkhtar Feb 19 '21
Is your app pretty simple or complex? What kind of animations are you using?
(Asking because a lot of ppl say the opengl version leads to out of memory crashes and othe weird behavior)
2
Feb 19 '21 edited Feb 19 '21
Hello, I can estimate my app as a mid complex application in UI part. About presentation I have a dialogs, modals, backdrops, transitions with a bunch of content. A lot of crossFade animations inside futurebuilders and others, several custom painters(brand logos, loaders and others), animatedSliver list and others slivers with animations. Live preview of machine learning image scanning with a lot of animations too. Btw, I follow all recommendations from flutter team and use my knowledge of how flutter works best as I can. So I have not any problems with OOM error, thx god. But, I hear sometimes from colleagues about this problem, unfortunately with no logs of something concrete, maybe I just a lucky guy =)
1
u/AAkhtar Feb 19 '21
that's pretty awesome. thanks for sharing this workaround. I'll definitely try that if nothing changes on this front by the time i release the app.
2
u/Piero512 Feb 20 '21
Hey, is there a way for the Skia team to be able to interpret Skia Shader Language directly on the GPU? (this would be kinda slow maybe, imagine putting a SPIR-V of an SkSL interpreter and compiling the bytecode to native in the first app install, but maybe it can be hidden on the splash screen before Flutter renders it's first frame) - Invoke a software renderer while the specialized shader is being compiled on the background? I think the milestones on the Flutter umbrella bugs already lists some of those but there's like no blockers on them AFAIK.
There's a known open source project that has had this issue of having to stall the threads until a shader is compiled, and they had quite the solution, and it's called Dolphin Emulator.
1
u/AAkhtar Feb 20 '21
Sounds like you should ask this on the github issue, doubt anyone who knows the answer would see it here.
2
u/Piero512 Feb 20 '21
Well, after reading the shader compilation PSA on flutter.dev, they aren't going to work with the "ubershader" AKA SkiaSL interpreter on GPU, because there is no way to know if the effort of porting a Skia SL interpreter as a shader program would run fast enough on regular phones, and the time needed to compile this shader would be quite a big chunk of the start-up time. I wonder if you can AOT this on Apple's infrastructure and deliver using features like Google Play's distribution. Considering there is like 20 iPhone models, they might just be okay to just AOT compile the shader.
56
Feb 17 '21
Honestly. I have been a huge advocate of flutter for the last two years but I currently feel:
misled. The 60FPS claim is totally disingenuous at this point.
frustrated. This is a huge flaw in our app and I’m basically helpless to do anything about it. From what I can gather there are one or two Google devs working on this alongside other commitments and no-one seems to have a conceptual solution as yet.
uninformed. There are multiple github issues and no single place to easily track the status of this issue.
Would I use flutter for my next project based on the current state of play. Sadly the answer is currently no.
14
Feb 17 '21
The 60FPS claim is totally disingenuous at this point.
I agree. It's a little worrying that even when warmed up this animation is still like 30 fps.
11
Feb 17 '21
I mean flutter (by its own definition) is a UI framework (and bar this issue, by far and away the best one I’ve ever worked with).
How can they not be making this their number 1 priority? I’m concerned that the reason might be that there is no good solution to this....
9
Feb 17 '21
I also feel really really disappointed as this completely lets down what is an otherwise fantastic framework.
5
u/Akandoji Feb 17 '21
I'm curious, which framework would you use now? React Native /Cross-platform or native?
Tbh I think I'm having a bit of Flutter fatigue too. It's saying something when official support is so bad that I have to rely on third party plug-ins. Community is the only thing keeping Flutter alive, not Google.
16
Feb 17 '21
Community is the only thing keeping Flutter alive, not Google.
Definitely disagree there. The Flutter developers are absolutely amazing at providing helpful documentation, videos, etc. and I don't know of another project with such a healthy Github Issues page. Consider what Google normally provides!
They really need to fix this issue but I don't think you can say official support is bad by any measure.
3
u/KaiN_SC Feb 17 '21
If you look for react native its even more extreme. Google did aot for flutter.
62
u/Renaud06 Feb 17 '21
I cant understand how they choose to release new stuff instead of repair this kind of problems (which exist on android too). I say that as a big fan of flutter, but who cares about Web stable 1.0 when you cant correctly animate on a 1000€ smartphone .
20
Feb 17 '21
This. They at least need to clearly communicate the reasons why and exactly what they are doing to resolve this issue alongside the other work.
3
Feb 17 '21
I think they have haven't they? It's shader compilation, and you need to do an annoying and fragile PGO-style profiling step to collect precompiled shaders to fix it.
I really hope they don't think that's a long-term fix. They need to fundamentally change their architecture so doesn't need to compile any shaders at all at runtime. I presume that is a fairly enormous amount of work though.
5
Feb 17 '21
Unfortunately the profiling to pre-compile the shaders only works for android. Otherwise I’d be more than happy with this. So at present, there is no fix for the issue on iOS (other than running the animations behind a fake splash screen on startup which we may need to consider but feels just horrible).
0
Feb 17 '21
[deleted]
5
u/escamoteur Feb 18 '21
To be fair, you need very special knowledge on shader programming and GPUs which not everyon in the Flutter team probably has. So its not a contradiction to produce new widgets in parallel
2
u/mihaelamj Feb 20 '21
you need very special knowledge on shader programming and GPUs which not everyon in the Flutter team probably has
Exactly. And that means that this is just a beginning. Problems of this kind are just gonna keep coming with no one to fix them.
5
u/Flutter28292 Feb 17 '21
Was the PhysicalModel really new? I think the video about it said it is being used under the hood a lot so probably only the video showing it was new.
4
u/jonah_williams Feb 18 '21
PhysicalModel was added in Feb 2017: https://github.com/flutter/flutter/pull/8471
37
u/gmatuella Feb 17 '21
Currently, that’s indeed one of the most underwhelming issues with Flutter.
No matter which position you’re into, it’s really hard to justify to your client/PM/boss that, instead of native, you will build a hybrid application, with a shared codebase and all the pros it come along this fact - but with a cost of user experience in iOS; this project will lag behind any native apps due to an existing problem with the tool you are using. I see use cases where experience is not that big of a deal, but it’s still a relevant issue that you must always bring with you, no matter for who you are building your applications to.
15
Feb 17 '21
Totally agree. I’m a tech decision maker for a large UK PLC. We have already invested in Flutter so we are trying to navigate this as best as possible, however with hindsight I would not choose it again given the current state.
3
u/benniii Feb 17 '21 edited Feb 17 '21
I would still choose it 10/10. What are you concrete problems? I believe you have poor performance improvement
I work on an app that has multiple videos on the same pages, a lot of images and a lot of networking and still running super smooth on android and pretty smooth on iOS. especially when you use ist for 20 seconds then it runs on 60 fps on iOS aswell constantly.
PM me if you want to talk about this in detail u/two_pints_timmy
11
u/lnkprk114 Feb 17 '21
I want to believe this, but my samsung s20 drops frames on the default sample gallery app. That's crazy. It's worse performance than React Native apps, much less purely native apps.
2
u/benniii Feb 17 '21
interesting. our app runs super smooth on the Samsung S9 I have for testing
2
u/Creative-Trouble3473 Feb 17 '21
I have 12 Pro MAX, and I tested a number of apps, both developed by my team and by other developers (from App Store) - they all have laggy UI.
1
u/ftgander Feb 19 '21
I just tried Insight Timer on my Xs Max and it was perfectly smooth (even on the first run, surprisingly). Would you try it on your 12 Pro Max and report back? If you don’t mind, of course.
1
u/ftgander Feb 19 '21
https://play.google.com/store/apps/details?id=com.spotlightsix.zentimerlite2
What about this app? It runs smooth on my Xs Max, if it lags on your s20 I’m really surprised. Maybe it’s due to the high refresh rate screen being double the FPS of the app?
2
u/lnkprk114 Feb 19 '21
That one does run smoothly (also it's fucking gorgeous). I had a few stutters here and there but all in all it was great. I'm not sure why some flutter apps seem to struggle while others seem to do just fine. I'd think it was performance optimizations in the better running apps but again things like the gallery app stuttering make that assumption questionable.
1
u/ftgander Feb 19 '21 edited Feb 19 '21
What gallery app are you speaking of? I don’t see an official one on iOS.
Edit: I found it. https://play.google.com/store/apps/details?id=io.flutter.demo.gallery&hl=en_CA&gl=US
Weird it’s not on iOS. The repo for it links to here though: https://gallery.flutter.dev/ , which runs surprisingly well for Flutter Web considering it’s still in beta.
2
u/eseidelGoogle Feb 22 '21
We tried several times to publish via the Apple App store but were not able to get the Flutter Gallery past App Store review. :/ I disagree with the reviewers decisions, but it's never been top of my list to go argue with Apple about. :)
You can build it yourself from https://github.com/flutter/gallery or of course use gallery.flutter.dev (for the web version).
1
u/ftgander Feb 22 '21
Thanks for the explanation! That’s weird because there’s an app called “flutter catalog” that does nearly the same thing as gallery and is on the App Store. :shrug:
1
u/eseidelGoogle Feb 22 '21
Honestly it can feel kinda random which shaders take a long time to compile vs. not. It also can depend on hardware.
Thankfully recently folks have started filing some really nicely isolated bugs which is helping us dive into resolving some of the more pathological shader-compile issues, in addition to also of course changing Flutter's architecture to allow removing synchronous-shader-compilation from the first-draw path.
https://github.com/flutter/flutter/projects/188 links to some of the examples of helpful bugs filed recently.
0
u/ftgander Feb 18 '21
Something wrong with ur s20, son.
2
u/lnkprk114 Feb 18 '21
Honestly I'd prefer that's the case, but it's not because huge, heavy native apps run smoothly. It's Flutter unfortunately.
-1
u/ftgander Feb 18 '21
Flutter apps ran perfectly smooth on my Pixel 2 and 3 and also run fine on my Xs Max from what I can tell.
Something is not correct with your scenario.
3
u/lnkprk114 Feb 19 '21
Considering the linked issue is gaining a ton of traction, I'd say it's not just me.
2
7
Feb 17 '21
The use case for our app means that users open it on average once per day and use it for about 60 seconds. This means that every day they get iOS jank. As soon as the shaders have warmed up the user has finished using the app.
1
u/aytunch Mar 04 '21
I would like to know which video player you used in order to have multiple video views on one screen? Looking at the issues the official video_player plugin can definitely not handle multiple controllers.
I will be really glad if you could share your strategy on this
1
u/benniii Mar 04 '21
I created a video player tile widget with one controller each, which played the video. I added them into a scrollable list. I gave each tile a unique video url which was loaded by the tiles.
10
u/benniii Feb 17 '21
I am working on several Flutter Apps right now and I have the same impressions as you have. The good thing is that you can do a lot to improve the performance even with these issues still persisting but you dont get native performance or the performance as on Android. I am quite sure they will fix it in 2021 but right now they have not. They fixed ist in the SKIA Engine but this fix was not released for Flutter to this date.
11
u/Creative-Trouble3473 Feb 17 '21
According to this, they are looking for community contributors to fix the issue:
https://github.com/flutter/flutter/issues/26688#issuecomment-779344758
Nooot goood. I really don't know how they can focus on other things like web support or adding new widgets while they have such a massive problem with UI performance.
1
u/eseidelGoogle Feb 22 '21
I believe that reply was specific to that one bug on the Gallery (which is just a demo app we've mostly built for ourselves). We have a lot more devs working on performance than we do on specifically tuning the Gallery. :)
8
Feb 18 '21
Google should have kept OpenGL as the primary rendering backend on iOS until the issues with the Metal implementation were resolved.
Then the SkSL warmup approach would still work and none of this would be an issue.
4
u/eseidelGoogle Feb 22 '21
I suspect if I had known about the metal caching break I would have advocated for that at the time. At this point, rolling back to OpenGL would be much harder. My teams also tell me that OpenGL support on iOS is getting worse, not better, so it would probably introduce other bugs. :/
Regardless, we're working on a number of improvements at this time:
https://github.com/flutter/flutter/projects/188
I hope where we end up is much easier to use than SkSL warm-up, which was mostly something we built specifically to solve jank for the Google Assistant team launching on some specific low-powered hardware (instead of the case of iOS/Android devs where apps must work on a wide range of hardware).
1
Feb 23 '21
Thanks for your reply and the handy Github project link. For balance, first run jank is one of the few parts of Flutter that I've had any issues with. Thanks for your work on Flutter.
I know it's a difficult problem to fix properly but I'm sure you guys will figure it out given time.
5
u/fredgrott Feb 17 '21
of course some of you missed that there is already an intermediate workable solution implied in the comments to the issue..still have to work out timing of the work-around on an individual project basis as each app wil have a different number of screen animations they have to pre-load but it's do-able in the short term while waiting for the long term solution
8
Feb 17 '21
Are you referring to running the animations behind the splash screen on startup?
2
u/Scharesoft Feb 19 '21
Everyone is talking about this idea, but I didn't find any working example for this workaround.
1
1
Oct 21 '21
Newbie here so be kind. I understand what is "jank". But I don't understand in what situations it becomes apparent in Flutter. I see mention of shaders. That's a term I see used in game dev - not web dev. How does it apply to Flutter? Is it only an issue when one uses shaders? Or are shaders just fundamental to animation in Flutter? Are animations that important to app UX that one would abandon Flutter over this issue? Thanks!
0
0
Feb 17 '21
[deleted]
3
u/AAkhtar Feb 17 '21
Yep, that same page you linked says the shader warmup method is not available for iOS devices.
https://flutter.dev/docs/perf/rendering/shader#limitations-and-considerations
So the SkSL warm-up would only speed up older iOS devices by default
4
156
u/eseidelGoogle Feb 18 '21
Hi. Flutter Co-founder/Engineering Director here.
First, I'd like to thank the reporter for writing such a nice bug. Clear, concise, reproducible cases always help make it possible for those contributing to a project like Flutter to more easily address reported issues.
Second, I'd like to acknowledge the concerns offered in the comments on this post. There are certainly cases of jank (missed frames) we are aware of with Flutter (there always are with any system). Performance, including "jank" is a multifaceted issue, which we're continuing to improve, daily. Some cases of jank are “Flutter’s fault” and some end up being traced to other issues. Again, the importance of filing such concise bugs makes that tracing and fixing much easier, thank you.
Jank is one of *many* aspects of performance we track and improve. Memory, on-disk-size, launch speed, etc. are all constantly tracked, improved and regressions addressed daily by the project. If you’d like to get involved, more hands are always welcome. https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md
Before I dive into talking about what Flutter in working on regarding jank, I want to reiterate that there can be *many* causes of jank in an app. Examples I’ve seen include run-away 3rd party library (something Flutter tries to isolate devs from by running code on a separate UI thread), a long stall parsing something off the network (again something Flutter tries to help with with async calls, Isolates or the “compute” helper call in the framework) as well as of course from bugs inside Flutter, the OS or the hardware itself. Regardless of the source, we try to make it possible for developers to discover and fix dropped frames (e.g. with https://flutter.dev/docs/development/tools/devtools/overview, https://flutter.dev/docs/perf/rendering/ui-performance, https://flutter.dev/docs/development/tools/devtools/performance, etc.) in hopes of always helping devs provide users the best possible experience.
So to address some of the other comments with concerns around first-run jank and what Flutter can do better: First-run jank is frame-drops which affect *only* the first time an animation runs. On Android, that generally means the first time ever, as we cache the resulting shaders (programs which run on the GPU) and reload them next time you run the app. On iOS, after Metal, it means first-run-per-app-launch, currently (previously was first-time-ever with OpenGL).
Specifically to iOS, there was a change about a year ago when we switched the default from OpenGL to Metal on iOS (https://github.com/flutter/engine/pull/17431). As a result, we (unintentionally) lost one of the layers of caching of shaders due to lack of support in Metal/Skia. This made one cause of "first run jank” happen on every run on iOS. This is not the only performance issue you may ever encounter (and often isn’t the root cause of reported instances of jank), but is a specific issue we are addressing through planned architectural changes I will discuss below.
Why is there any first run jank at all? You might ask. Why is the “first run” any different from any other run? Well, Flutter works like a game. Unlike the underlying iOS/Android system which intentionally uses a small number of shaders for the small number of animations/effects present within the included widget set, Flutter allows developers to create arbitrary effects/animations, at the cost of that to run these on the GPU, shaders have to be compiled. Additionally, unlike an OS, Flutter doesn't have a shared cache for all uses of those shaders between apps. And unlike a game, Flutter does not compile shaders at launch (hence the loading screens of games), but rather at first use. This all can result in a stall/jank at first use of a new animation/effect, sometimes during the animation itself when such is most visible to users. :(
I've come to believe over the years that our approach to shader compilation with stalling-to-compile-shaders-on-first-use was an architectural error. Not a fatal one, obviously, but one now with 100,000s of applications shipping and millions of Flutter devs that it’s time for us to correct. Stall-to-compile-shaders is an issue we can address and one we're currently in the process of correcting. We will have more about that soon, but in short, current ideas include making shader compilation explicit inside the Flutter Engine to make it possible for developers to program around this necessity (and show something else during compilation for example -- like how iOS does with tile stalls). This won’t address all possible jank in every app, but it is one area we’re investing in.
There are of course many other things we're doing in the jank-performance space, including improving our developer tools (linked above) for improved profiling (linked above). We're also looking at additional widgets to help contain or prevent jank for areas requiring lots of shader compiles (loading complex animations from a file for example).
Flutter's job in the end is to provide a fantastic foundation to build from regarding performance and tools to "set developers up to succeed" in making their Apps perform well on top of that foundation. Both are areas we continue to improve and I hope to offer some longer-form discussions of such in the near future.
As always, we're listening. The feel, the look and the performance of YOUR app in YOUR users hands is very important to us. We're constantly improving. With the number of applications (including at Google!) built on Flutter today, it's paramount that it always be possible to achieve "the best the device can do". I think we do a pretty good job overall, but can definitely do better at setting developers up to succeed re: jank, and you will see us doing more in the coming months.
As always, please do not hesitate to reach out if we can help. flutter.dev/support. https://twitter.com/_eseidel