@@ -102,6 +102,30 @@ void debugResetEngineInitializationState() {
102
102
_initializationState = DebugEngineInitializationState .uninitialized;
103
103
}
104
104
105
+ void renderFrame (int timeInMicroseconds) {
106
+ frameTimingsOnVsync ();
107
+
108
+ // In Flutter terminology "building a frame" consists of "beginning
109
+ // frame" and "drawing frame".
110
+ //
111
+ // We do not call `frameTimingsOnBuildFinish` from here because
112
+ // part of the rasterization process, particularly in the HTML
113
+ // renderer, takes place in the `SceneBuilder.build()`.
114
+ frameTimingsOnBuildStart ();
115
+ if (EnginePlatformDispatcher .instance.onBeginFrame != null ) {
116
+ EnginePlatformDispatcher .instance.invokeOnBeginFrame (
117
+ Duration (microseconds: timeInMicroseconds));
118
+ }
119
+
120
+ if (EnginePlatformDispatcher .instance.onDrawFrame != null ) {
121
+ // TODO(yjbanov): technically Flutter flushes microtasks between
122
+ // onBeginFrame and onDrawFrame. We don't, which hasn't
123
+ // been an issue yet, but eventually we'll have to
124
+ // implement it properly.
125
+ EnginePlatformDispatcher .instance.invokeOnDrawFrame ();
126
+ }
127
+ }
128
+
105
129
/// Initializes non-UI engine services.
106
130
///
107
131
/// Does not put any UI onto the page. It is therefore safe to call this
@@ -158,8 +182,6 @@ Future<void> initializeEngineServices({
158
182
if (! waitingForAnimation) {
159
183
waitingForAnimation = true ;
160
184
domWindow.requestAnimationFrame ((JSNumber highResTime) {
161
- frameTimingsOnVsync ();
162
-
163
185
// Reset immediately, because `frameHandler` can schedule more frames.
164
186
waitingForAnimation = false ;
165
187
@@ -170,29 +192,14 @@ Future<void> initializeEngineServices({
170
192
// microsecond precision, and only then convert to `int`.
171
193
final int highResTimeMicroseconds =
172
194
(1000 * highResTime.toDartDouble).toInt ();
173
-
174
- // In Flutter terminology "building a frame" consists of "beginning
175
- // frame" and "drawing frame".
176
- //
177
- // We do not call `frameTimingsOnBuildFinish` from here because
178
- // part of the rasterization process, particularly in the HTML
179
- // renderer, takes place in the `SceneBuilder.build()`.
180
- frameTimingsOnBuildStart ();
181
- if (EnginePlatformDispatcher .instance.onBeginFrame != null ) {
182
- EnginePlatformDispatcher .instance.invokeOnBeginFrame (
183
- Duration (microseconds: highResTimeMicroseconds));
184
- }
185
-
186
- if (EnginePlatformDispatcher .instance.onDrawFrame != null ) {
187
- // TODO(yjbanov): technically Flutter flushes microtasks between
188
- // onBeginFrame and onDrawFrame. We don't, which hasn't
189
- // been an issue yet, but eventually we'll have to
190
- // implement it properly.
191
- EnginePlatformDispatcher .instance.invokeOnDrawFrame ();
192
- }
195
+ renderFrame (highResTimeMicroseconds);
193
196
});
194
197
}
195
198
};
199
+ warmUpFrameCallback = () {
200
+ // TODO(dkwingsmt): Can we give it some time value?
201
+ renderFrame (0 );
202
+ };
196
203
197
204
assetManager ?? = ui_web.AssetManager (assetBase: configuration.assetBase);
198
205
_setAssetManager (assetManager);
0 commit comments