Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

With the current stopwatch design, we request the frame rate multiple times per frame. On Android this calls into JNI which is pretty slow. If we cache the value at construction of the StopwatchVisualizer, then we will only compute it once per frame (because the StopwatchVisualizer is reconstructed each frame).

Fixes flutter/flutter#137797

So the issue isn't that we're checking the fresh rate every frame, its that we were checking N times on each frame.

explicit StopwatchVisualizer(const Stopwatch& stopwatch)
: stopwatch_(stopwatch) {}
: stopwatch_(stopwatch) {
frame_budget_ = stopwatch_.GetFrameBudget();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's note why this is happening so someone doesn't refactor it back in the future (it won't be clear this is a JNI call).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 13, 2023
@auto-submit auto-submit bot merged commit ed001a5 into flutter:main Nov 13, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 13, 2023
@jonahwilliams jonahwilliams deleted the cache_frame_rate branch November 16, 2023 18:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[engine] Stopwatch Visualizer checks refresh rate every frame.

2 participants