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

Jittery performance on first run of animation/transitions due to shader compilations #813

Closed
sethladd opened this issue Dec 8, 2015 · 76 comments · Fixed by #27660
Closed
Assignees
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) customer: solaris engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
Milestone

Comments

@sethladd
Copy link
Contributor

sethladd commented Dec 8, 2015

On some apps, the first time you run a "big" animation (like a hero transition), there appears to be some jitter/jank. After the animation is warmed up, it appears to become smoother.

This is a tracking issue to investigate and solve.

@sethladd sethladd added customer: art platform-android Android applications specifically labels Dec 8, 2015
@Hixie Hixie added the c: performance Relates to speed or footprint issues (see "perf:" labels) label Dec 11, 2015
@Hixie Hixie added this to the Blue Sky milestone Dec 11, 2015
@eseidelGoogle
Copy link
Contributor

Now that --release builds exist and use AOT mode, there should no longer be initial compile jitter? If you have specific traces happy to look at them!

@sethladd sethladd reopened this Oct 11, 2017
@sethladd sethladd modified the milestones: 5: Make Hixie proud, 3: Current Milestone Oct 11, 2017
@sethladd sethladd changed the title Jittery performance on animation first-runs on Android Jittery performance on first run of animation/transitions Oct 11, 2017
@sethladd sethladd added framework flutter/packages/flutter repository. See also f: labels. and removed platform-android Android applications specifically labels Oct 11, 2017
@sethladd
Copy link
Contributor Author

Reopening as this is a systemic issue. Report from our mailing list: "2) First time loading shows lag, but after some time experience becomes smoother." and "Initially home screen lags for the first time only, then it gets smoother" and we recently saw it with a customer's app and their initial onboarding screens (on a Pixel, a modern phone).

@Hixie
Copy link
Contributor

Hixie commented Dec 20, 2017

This is a metabug for tracking these similar issues.

Fixing this is our top performance priority.

Assigning to @cbracken who is currently tasked with investigating this.

@Hixie Hixie added this to To Do in Milestone 3 Jan 26, 2018
@Hixie Hixie moved this from To Do to Engine in Milestone 3 Jan 26, 2018
@Hixie Hixie moved this from Engine to Page Load Performance in Milestone 3 Jan 26, 2018
@flippingbitss
Copy link

Any updates on this ?

@mmm111mmm
Copy link

mmm111mmm commented Apr 10, 2018

I'm on 0.2.8 of the flutter.io Gallery app on the Play Store with a Nexus 4. I'm looking at the Shrine app, the hero transition particularly.

The performance degradation between first run and subsequent runs seems almost completely gone compared to previous versions.

There still seems to be a very, very slight difference between first and subsequent runs but it's very, very, slight to the point where I'm not even sure if it's there after looking at it numerous times.

It's still very choppy on my Nexus 7. But I think that is related to #11861 Or perhaps tablet specific as I'm not sure Google are testing Flutter on tablets.

@Hixie Hixie modified the milestones: 3: Current Milestone, 4: Next milestone Apr 17, 2018
@cbracken cbracken assigned liyuqian and unassigned cbracken Jun 7, 2018
@christian-muertz
Copy link
Contributor

Any update on this?

We want to launch our app soon... This performance issue is critically for us :/

@liyuqian
Copy link
Contributor

I haven't uploaded a solution yet. But I've added some tracing as mentioned in #28113 (comment) . It would be nice if you can trace your performance issues with master channel and see if the font loading is the cause.

@miguelpruivo
Copy link

@kf6gpe I’m sitting at 1.5.3 @ dev. When was it synced with master? Anyhow, I’m looking to release an app with this issue (if not fixed until then) early next month.

Fingers crossed for a solution on this. It always look like the app is doing some heavy task in those little seconds.

@liyuqian
Copy link
Contributor

@miguelcmedeiros : v1.5.3 should have the added trace events. Can you please follow #813 (comment) (especially item 5) to capture a trace of your issue so we can figure out how to help you?

@yunyu
Copy link

yunyu commented Apr 25, 2019

@liyuqian I'm not sure if this is the correct place to post this, but here is a ~200 LoC single file example which exhibits the issue (as well as #28113 and #31086) on iOS, but works fine on Android (with android.permission.INTERNET): https://github.com/yunyu/flutter_scroll_stutter_test/blob/master/lib/main.dart

It consists of a feed containing images with a text overlay and a basic parallax effect.

@miguelpruivo
Copy link

miguelpruivo commented Apr 27, 2019

Noticed that this also happens when the iPhone is in low power mode. It completely jitters scroll and animations.

@liyuqian
Copy link
Contributor

@yunyu : Thank you very much for your example app! I did reproduced the stutter on an iPhone X, and it didn't stutter on an iPhone 6S. I checked the trace and it's not related to the shader compilations of this issue so I'll route the discussion to #31086 (comment)

@liyuqian
Copy link
Contributor

liyuqian commented May 1, 2019

I'm closing this bug since all new complaints here seem to be unrelated with our original issue. I created a new issue #31881 for our original task of improving flutter_gallery's shader compilation jank. Other iOS related first animation jank issues should be routed to either #28113 or #31086. If both of them don't seem to be the issue that you had, please feel free to create a new issue.

@shinayser
Copy link

shinayser commented May 28, 2019

I am experiencing this problem on a current production app (flutter v1.5.4). The first time my animations run janky (after an install), then it runs smooth.
Both Android and iOS.

@michinchin
Copy link

Experiencing this specifically with hero animations. Other animations seem to run smooth. However, initial hero animation is a bit janky

@arsen
Copy link

arsen commented Jun 20, 2019

Same for me, initial run of a hero animation is missing frames.

@miguelpruivo
Copy link

miguelpruivo commented Jun 20, 2019

It seems to happen with all animations/scroll at start of an iOS app and/or reloading from background. It’s 2/3 seconds janky and then smooth until closed and reopen again. You can replicate it everytime in an iPhone X (at least).

@michinchin
Copy link

Anyone find a fix? Or a workaround for this?

@michinchin
Copy link

Found it lags for the first time on both Android and iOS initial start up

@liyuqian
Copy link
Contributor

We're coming up with a long-term solution for this and that progress is tracked publicly on #32170 . Currently, we have a 16-page internal draft design doc with 9 different proposed solutions in it.

In shorter terms, we believe that there might be some specific issues that we can quickly solve just for iPhone X since the issue seems to be less bad on older iPhones. We're currently purchasing iPhone X to add to our device lab so we can debug the performance of iPhone X: #34590

@michinchin
Copy link

#32170

This is not only an issue on the iPhone X. We have done testing on the Pixel 3 and other android devices and have found the same effect.

@liyuqian
Copy link
Contributor

@michinchin : we're aware of that hence #32170 is not just for iOS, but also for Android, Fuchsia, Desktop, and probably all platforms that Flutter directly compiles into binaries.

iOS currently just has additional issues. For example, we can store binary persistent shader cache on Android, but we can only store GLSL persistent shader cache on iOS. That requires iOS to do one more compilation (compared to Android). For that, we're also enabling Metal backend for iOS which should help this specific issue.

@miguelpruivo
Copy link

@liyuqian thank you for the updates. Currently (and because I’m an iPhone X user) I immediately noticed it and I must say that despite of being an issue already tracked, it bothers me somehow to have a production app that launches on a scroll screen where it always feel janky as the user starts it on iPhone for the first 2 seconds.

Oddly and in my experience, it seems to affect only the iOS. Android devices were I’ve tested it, seem to be good and smooth right from the launch point.

@liyuqian
Copy link
Contributor

@miguelcmedeiros : that's exactly the difference between binary persistent shader cache and GLSL persistent shader cache. On Android, there's 0 work if you close the app and re-open the app. On iOS, re-opening the app triggers another GLSL to binary compilation.

@miguelpruivo
Copy link

@liyuqian got it. Do you have an idea of when a fix may be available? Have you already found a solution for it or still drafting for?

PS: You've tagged the wrong person. 😄

@liyuqian
Copy link
Contributor

Oops. We haven't picked which solution to pursue. Will update #32170 with some proper time estimation once we made the decision.

@erf
Copy link

erf commented Mar 8, 2020

@liyuqian Any news on this?

I'm experiencing jaggy animations every first time i do:

Navigator.push(MaterialPageRoute(fullscreenDialog: true, builder: (context) => SomePage()));

Second time i open a page, it' much smoother.

I'm on an iPhone 7.

flutter --version
Flutter 1.15.18 • channel dev • https://github.com/flutter/flutter.git
Framework • revision 9437639590 (31 hours ago) • 2020-03-06 10:24:23 -0800
Engine • revision 5aff311948
Tools • Dart 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)

@liyuqian
Copy link
Contributor

@erf : we're actively working on SkSL shader warm-up. Some preliminary results on iOS should be available in 1-2 months.

@liyuqian
Copy link
Contributor

For progress, please check #32170 . We'll be referencing it when we're making smaller fixes.

@erf
Copy link

erf commented Mar 30, 2020

@liyuqian i feel the performance has been improved in the latest dev version 1.16.3 ..?

@liyuqian
Copy link
Contributor

@erf : it's nice to hear that! We're always working hard to improve the performance. While #32170 isn't fixed yet, we've made at least 13 other quantified improvements between Sep 2019 and Dec 2019.

@lock
Copy link

lock bot commented Apr 15, 2020

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 flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) customer: solaris engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
No open projects
Milestone 3
Page Load Performance (chris)
Development

Successfully merging a pull request may close this issue.