This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Add scheduleWarmUpFrame #50570
Merged
Merged
Add scheduleWarmUpFrame #50570
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1950e72
Impl engine
dkwingsmt f55dfdf
Web
dkwingsmt 7f76c5f
Rename to RequestWarmUpFrame and add web time
dkwingsmt 31a5ea3
Change to scheduleWarmUpFrame and EndWarmUpFrame
dkwingsmt 590287d
Comment
dkwingsmt 40b269b
Doc
dkwingsmt 2d70a0f
Simplify web implementation
dkwingsmt 4af9f06
Fix comment
dkwingsmt bfe5570
More doc
dkwingsmt 21439c4
Fix doc
dkwingsmt 1bd21db
More doc
dkwingsmt 4f41658
Fix linter
dkwingsmt eeac064
Fix comment
dkwingsmt 9c5bce4
Add test
dkwingsmt cdcf71a
Fix test
dkwingsmt 7ab7d8e
Better test
dkwingsmt afbcfae
Merge remote-tracking branch 'origin/main' into force-sync-frame
dkwingsmt 7381087
Simplify test and add platformdispatcher test
dkwingsmt 05d3d2d
Better structure
dkwingsmt 06957bb
Better name
dkwingsmt 68953c0
Merge branch 'main' into force-sync-frame
dkwingsmt a9b7511
Merge branch 'main' into force-sync-frame
dkwingsmt 8731e47
Add web platform dispatcher test
dkwingsmt cdeffd9
Merge branch 'main' into force-sync-frame
dkwingsmt 5d9f48b
Web comments
dkwingsmt 1589c59
Merge remote-tracking branch 'origin/main' into force-sync-frame
dkwingsmt 556984f
Fix test
dkwingsmt 2b6d3b2
Revert timer run change
dkwingsmt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,30 @@ void debugResetEngineInitializationState() { | |
| _initializationState = DebugEngineInitializationState.uninitialized; | ||
| } | ||
|
|
||
| void renderFrame(int timeInMicroseconds) { | ||
| frameTimingsOnVsync(); | ||
|
|
||
| // In Flutter terminology "building a frame" consists of "beginning | ||
| // frame" and "drawing frame". | ||
| // | ||
| // We do not call `frameTimingsOnBuildFinish` from here because | ||
| // part of the rasterization process, particularly in the HTML | ||
| // renderer, takes place in the `SceneBuilder.build()`. | ||
| frameTimingsOnBuildStart(); | ||
| if (EnginePlatformDispatcher.instance.onBeginFrame != null) { | ||
| EnginePlatformDispatcher.instance.invokeOnBeginFrame( | ||
| Duration(microseconds: timeInMicroseconds)); | ||
| } | ||
|
|
||
| if (EnginePlatformDispatcher.instance.onDrawFrame != null) { | ||
| // TODO(yjbanov): technically Flutter flushes microtasks between | ||
| // onBeginFrame and onDrawFrame. We don't, which hasn't | ||
| // been an issue yet, but eventually we'll have to | ||
| // implement it properly. | ||
| EnginePlatformDispatcher.instance.invokeOnDrawFrame(); | ||
| } | ||
| } | ||
|
|
||
| /// Initializes non-UI engine services. | ||
| /// | ||
| /// Does not put any UI onto the page. It is therefore safe to call this | ||
|
|
@@ -158,8 +182,6 @@ Future<void> initializeEngineServices({ | |
| if (!waitingForAnimation) { | ||
| waitingForAnimation = true; | ||
| domWindow.requestAnimationFrame((JSNumber highResTime) { | ||
| frameTimingsOnVsync(); | ||
|
|
||
| // Reset immediately, because `frameHandler` can schedule more frames. | ||
| waitingForAnimation = false; | ||
|
|
||
|
|
@@ -170,29 +192,14 @@ Future<void> initializeEngineServices({ | |
| // microsecond precision, and only then convert to `int`. | ||
| final int highResTimeMicroseconds = | ||
| (1000 * highResTime.toDartDouble).toInt(); | ||
|
|
||
| // In Flutter terminology "building a frame" consists of "beginning | ||
| // frame" and "drawing frame". | ||
| // | ||
| // We do not call `frameTimingsOnBuildFinish` from here because | ||
| // part of the rasterization process, particularly in the HTML | ||
| // renderer, takes place in the `SceneBuilder.build()`. | ||
| frameTimingsOnBuildStart(); | ||
| if (EnginePlatformDispatcher.instance.onBeginFrame != null) { | ||
| EnginePlatformDispatcher.instance.invokeOnBeginFrame( | ||
| Duration(microseconds: highResTimeMicroseconds)); | ||
| } | ||
|
|
||
| if (EnginePlatformDispatcher.instance.onDrawFrame != null) { | ||
| // TODO(yjbanov): technically Flutter flushes microtasks between | ||
| // onBeginFrame and onDrawFrame. We don't, which hasn't | ||
| // been an issue yet, but eventually we'll have to | ||
| // implement it properly. | ||
| EnginePlatformDispatcher.instance.invokeOnDrawFrame(); | ||
| } | ||
| renderFrame(highResTimeMicroseconds); | ||
| }); | ||
| } | ||
| }; | ||
| warmUpFrameCallback = () { | ||
| // TODO(dkwingsmt): Can we give it some time value? | ||
| renderFrame(0); | ||
|
||
| }; | ||
|
|
||
| assetManager ??= ui_web.AssetManager(assetBase: configuration.assetBase); | ||
| _setAssetManager(assetManager); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,8 @@ class Animator final { | |
|
|
||
| void RequestFrame(bool regenerate_layer_trees = true); | ||
|
|
||
| void ForceSyncFrame(); | ||
|
||
|
|
||
| //-------------------------------------------------------------------------- | ||
| /// @brief Tells the Animator that this frame needs to render another view. | ||
| /// | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.