-
Notifications
You must be signed in to change notification settings - Fork 6k
Add scheduleWarmUpFrame #50570
Add scheduleWarmUpFrame #50570
Changes from 1 commit
1950e72
f55dfdf
7f76c5f
31a5ea3
590287d
40b269b
2d70a0f
4af9f06
bfe5570
21439c4
1bd21db
4f41658
eeac064
9c5bce4
cdcf71a
7ab7d8e
afbcfae
7381087
05d3d2d
06957bb
68953c0
a9b7511
8731e47
cdeffd9
5d9f48b
1589c59
556984f
2b6d3b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -808,29 +808,32 @@ class PlatformDispatcher { | |
| @Native<Void Function()>(symbol: 'PlatformConfigurationNativeApi::ScheduleFrame') | ||
| external static void _scheduleFrame(); | ||
|
|
||
| /// Immediately render a frame by invoking the [onBeginFrame] and | ||
| /// [onDrawFrame] callbacks synchronously. | ||
| /// Schedule a frame to run as soon as possible, rather than waiting for the | ||
| /// engine to request a frame in response to a system "Vsync" signal. | ||
| /// | ||
| /// This method performs the same computation for a frame as [scheduleFrame] | ||
| /// does, but instead of doing so at an appropriate opportunity, the render is | ||
| /// completed synchronously within this call. | ||
| /// This method is used during application startup so that the first frame | ||
| /// (which is likely to be quite expensive) can start a few extra milliseconds | ||
| /// earlier. Using it in other situations might lead to unintended results, | ||
| /// such as screen tearing. Depending on the platform, the warm up frame | ||
| /// might or might not be actually rendered to the screen. | ||
| /// | ||
| /// Prefer [scheduleFrame] to update the display in normal operation. The | ||
| /// [scheduleWarmUpFrame] method is designed for situations that require a frame is | ||
| /// rendered as soon as possible, even at the cost of rendering quality. An | ||
| /// example of using this method is [SchedulerBinding.scheduleWarmUpFrame], | ||
| /// which is called during application startup so that the first frame can be | ||
| /// presented to the screen a few extra milliseconds earlier. | ||
| /// For more introduction to the warm up frame, see | ||
| /// [SchedulerBinding.scheduleWarmUpFrame]. | ||
| /// | ||
| /// This method uses the provided callbacks as the begin frame callback and | ||
| /// the draw frame callback instead of [onBeginFrame] and [onDrawFrame]. | ||
| /// | ||
| /// See also: | ||
| /// | ||
| /// * [SchedulerBinding.scheduleWarmUpFrame], which uses this method. | ||
| /// * [scheduleFrame]. | ||
| void scheduleWarmUpFrame(VoidCallback beginFrameCallback, VoidCallback drawFrameCallback) { | ||
| /// * [SchedulerBinding.scheduleWarmUpFrame], which uses this method, and | ||
| /// introduces the warm up frame in more details. | ||
| /// * [scheduleFrame], which schedules the frame at the next appropriate | ||
| /// opportunity and should be used to render regular frames. | ||
| void scheduleWarmUpFrame({required VoidCallback beginFrame, required VoidCallback drawFrame}) { | ||
dkwingsmt marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is meant for first frame only, why not call it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The biggest reason, in my opinion, is that this frame is not guaranteed to be rendered, for example if Besides, I don't want to give developers the impression that scheduling the first frame using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition to what Tong said: The warmup frame is also used in hot reload scenarios where it isn't the first frame of the app.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The semantics of this method sound pretty complicated. I guess warm up is fine then. Should we have some assertions in the engine for this method? For example, should we make sure it's only called for the first frame, and is never called after a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it's possible, since |
||
| // We use timers here to ensure that microtasks flush in between. | ||
| Timer.run(beginFrameCallback); | ||
| Timer.run(beginFrame); | ||
| Timer.run(() { | ||
| drawFrameCallback(); | ||
| drawFrame(); | ||
| _endWarmUpFrame(); | ||
| }); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.