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

Conversation

mkustermann
Copy link
Member

A _beginFrame() seems to schedule the next frame interanally. If the _beginFrame() takes a long time, it will finish after the expiration date of the next frame timer.

That in return makes a Timer.run(() => _drawFrame()) be scheduled after the next frame callback is already run. Though we want to ensure the _beginFrame() and _drawFrame() are together before starting to work on the next frame. We only want microtasks to be drained in-between those two.

(This is how C++ engine works)

We can get similar semantics by scheduling the _drawFrame() timer even before running the _beginFrame() code.

Issue #23
Issue dart-lang/sdk#59666

A `_beginFrame()` seems to schedule the next frame interanally. If the
`_beginFrame()` takes a long time, it will finish after the expiration
date of the next frame timer.

That in return makes a `Timer.run(() => _drawFrame())` be scheduled
*after* the next frame callback is already run. Though we want to ensure
the `_beginFrame()` and `_drawFrame()` are together before starting to
work on the next frame. We only want microtasks to be drained in-between
those two.

(This is how C++ engine works)

We can get similar semantics by scheduling the `_drawFrame()` timer even
before running the `_beginFrame()` code.

Issue dart-lang#23
Issue dart-lang/sdk#59666
@mkustermann mkustermann requested review from yjbanov and osa1 December 6, 2024 13:09
Copy link

Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at:

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

Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly.

Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR).

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants