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

Schedule _drawFrame() timer before running _beginFrame() #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions engine/lib/src/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,7 @@ class PlatformDispatcher {
final int microseconds = _frameTime.inMicroseconds;
_frameTime += const Duration(milliseconds: 16);
Timer.run(() {
final Stopwatch beginSw = Stopwatch()..start();
_beginFrame(microseconds);
beginSw.stop();
late final Stopwatch beginSw;
Copy link
Member

Choose a reason for hiding this comment

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

Don't think it needs to be late. Allocate the Stopwatch here, then just start it later. Or start it here too, the only difference is the time taken to to call Timer.run to schedule the time.
(So only move the _beginFrame call to after scheduling the timer, not the stopwatch allocation and start.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed your comment in copybara-made gerrit CL & added you as reviewer

-> https://dart-review.googlesource.com/c/flute/+/399380

Timer.run(() {
final Stopwatch drawSw = Stopwatch()..start();
_drawFrame();
Expand All @@ -587,6 +585,9 @@ class PlatformDispatcher {
drawSw.elapsedMicroseconds / 1000);
_frameCount += 1;
});
beginSw = Stopwatch()..start();
_beginFrame(microseconds);
beginSw.stop();
});
},
);
Expand Down
Loading