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

Conversation

@loic-sharma
Copy link
Member

Adds a Windows desktop API to be notified when the next frame has been drawn. In the future, this will be used by Windows app to hide the window until the first frame has been drawn. This effectively just exposes the corresponding API in embedder.h.

Follow up to: #35244

Part of flutter/flutter#41980

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Comment on lines +186 to +191
// Pump messages for the Windows platform task runner.
::MSG msg;
while (::GetMessage(&msg, nullptr, 0, 0)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
Copy link
Member Author

@loic-sharma loic-sharma Aug 15, 2022

Choose a reason for hiding this comment

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

This is necessary as otherwise platform tasks - including the next frame callback - won't run. The Windows platform thread's task runner is actually a window. It is woken up by posting a message to its window. If messages aren't dispatched, the Windows platform task runner is never woken up, and platform tasks are never executed.

Copy link
Contributor

@yaakovschectman yaakovschectman left a comment

Choose a reason for hiding this comment

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

LGTM
It looks the existing next frame callback handling that these changes utilize work by passing the callback around through several layers of abstraction (e.g. engine, embedder, delegate) before eventually ending up at the Rasterizer, am I understanding that right?

@loic-sharma
Copy link
Member Author

loic-sharma commented Aug 15, 2022

@yaakovschectman Yup that's correct. The full chain will be:

  1. (TODO) App registers a first frame callback using the Windows desktop's next frame API
  2. Windows desktop API registers a next frame callback using the embedder's next frame API
  3. Embedder API registers a next frame callback using the shell
  4. The shell posts a task to the raster thread to set the rasterizer's next frame callback
  5. After the rasterizer draws the next frame, it fires its next frame callback if one exists from the raster thread
  6. This executes the embedder API's next frame callback
  7. This executes the Windows desktop API's next frame callback, which switches to the platform thread
  8. (TODO) This executes the app's first frame callback

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM stamp from a Japanese personal seal

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 15, 2022
@auto-submit auto-submit bot merged commit a47ddf9 into flutter:main Aug 15, 2022
@loic-sharma loic-sharma deleted the windows_first_frame branch August 15, 2022 23:40
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 16, 2022
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 platform-windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants