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

Make --cache-sksl less susceptible to shader jank while caching shaders #84994

Open
jacob314 opened this issue Jun 21, 2021 · 8 comments
Open
Labels
c: proposal A detailed proposal for a change to Flutter P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@jacob314
Copy link
Contributor

Currently users can struggle with following https://flutter.dev/docs/perf/rendering/shader because shader jank can cause frames to be skipped causing not enough shaders to be cached. When users fail to cache all shaders, they assume that shader caching just doesn't fully resolve shader jank. You may still see exactly the same number of frames janking just different frames after the animation survived the first janked frame.

Options:

  1. Automatically run with a large time dilation value when --cache-sksl is passed. Potentially a value of 30 might be required to cope with shader jank that lasts for 500ms but this could be very annoying for users caching shaders.

  2. More difficult: run with a custom clock so that simulates running the application pretending no frames janked. Potentially this would still be combined with some smaller amount of time dilation (e.g 5) to increase the chances of cache hits.

@jonahwilliams
Copy link
Member

We could create a service protocol extension to set the time dilation value and run that at startup if --cache-sksl is passed. That won't completely capture all startup frames unless you also start paused and resume though.

@jacob314
Copy link
Contributor Author

using a Dart define to set the initial value could be easier than starting paused and resuming although starting paused and resuming sounds reasonable.

@jonahwilliams
Copy link
Member

I would recommend against using compile time defines if possible since it will lead to extra rebuilds when users switch in and out of this mode

@jonahwilliams
Copy link
Member

actually, start paused wouldn't work since we could not set the value if the app were paused. Could set it as an engine flag like --route

@jacob314
Copy link
Contributor Author

On the topic of not forcing users to perform extra builds to cache shaders, why do we recommend that shaders are cached in profile build instead of allowing a debug build? Debug build combined with time dilation should be just about as effective for caching shaders.
In debug mode, using a Dart define would not be an issue.

@jonahwilliams
Copy link
Member

Yeah, I believe the recommendation with profile mode is just too avoid losing many frames.

@TahaTesser TahaTesser added in triage Presently being triaged by the triage team passed first triage c: proposal A detailed proposal for a change to Flutter tool Affects the "flutter" command-line tool. See also t: labels. and removed in triage Presently being triaged by the triage team labels Jun 22, 2021
@jonahwilliams
Copy link
Member

you could also run through the animations sequence multiple times, though that might be difficult if it is non-repeatable by nature (like a startup animation).

I wonder if the recording "persists" through a hot restart?

@dnfield
Copy link
Contributor

dnfield commented Sep 9, 2021

I think what we really want here is some mode where the app "renders every frame". Time dilation is a sort of work around to get at that, but what we really want is a way to make sure that each and every frame that can be rendered is,no matter how long we have to wait for it. See also discussion at #85118

@flutter-triage-bot flutter-triage-bot bot added the team-tool Owned by Flutter Tool team label Jul 8, 2023
@eliasyishak eliasyishak added P2 Important issues not at the top of the work list triaged-tool Triaged by Flutter Tool team labels Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: proposal A detailed proposal for a change to Flutter P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

No branches or pull requests

6 participants