@@ -132,80 +132,6 @@ At this point, the [`Layer`][] tree generated by your Flutter
132
132
program, per frame, is converted into
133
133
OpenGL (or Vulkan or Metal) GPU instructions.
134
134
135
- ## Memory and latency
136
-
137
- Showing a Flutter UI has a non-trivial latency cost.
138
- This cost can be lessened by starting the Flutter engine
139
- ahead of time.
140
-
141
- The most relevant choice for add-to-app scenarios is for you
142
- to decide when to pre-load a ` FlutterEngine `
143
- (that is, to load the Flutter library, start the Dart VM,
144
- and run entrypoint in an isolate), and what the memory and latency
145
- cost is of that pre-warm. You also need to know how the pre-warm
146
- affects the memory and latency cost of rendering a first Flutter
147
- frame when the UI component is subsequently attached
148
- to that ` FlutterEngine ` .
149
-
150
- As of Flutter v1.10.3, and testing on a low-end 2015 class device
151
- in release-AOT mode, pre-warming the ` FlutterEngine ` costs:
152
-
153
- * 42 MB and 1530 ms to prewarm on ** Android** .
154
- 330 ms of it is a blocking call on the main thread.
155
- * 22 MB and 860 ms to prewarm on ** iOS** .
156
- 260 ms of it is a blocking call on the main thread.
157
-
158
- A Flutter UI can be attached during the pre-warm.
159
- The remaining time is joined to the time-to-first-frame latency.
160
-
161
- Memory-wise, a cost sample (variable,
162
- depending on the use case) could be:
163
-
164
- * ~ 4 MB OS's memory usage for creating pthreads.
165
- * ~ 10 MB GPU driver memory.
166
- * ~ 1 MB for Dart runtime-managed memory.
167
- * ~ 5 MB for Dart-loaded font maps.
168
-
169
- Latency-wise,
170
- a cost sample (variable, depending on the use case) could be:
171
-
172
- * ~ 20 ms to collect the Flutter assets from the application package.
173
- * ~ 15 ms to dlopen the Flutter engine library.
174
- * ~ 200 ms to create the Dart VM and load the AOT snapshot.
175
- * ~ 200 ms to load Flutter-dependent fonts and assets.
176
- * ~ 400 ms to run the entrypoint, create the first widget tree,
177
- and compile the needed GPU shader programs.
178
-
179
- The ` FlutterEngine ` should be pre-warmed late enough to delay the
180
- memory consumption needed but early enough to avoid combining the
181
- Flutter engine start-up time with the first frame latency of
182
- showing Flutter.
183
-
184
- The exact timing depends on the app's structure and heuristics.
185
- An example would be to load the Flutter engine in the screen
186
- before the screen is drawn by Flutter.
187
-
188
- Given an engine pre-warm, the first frame cost on UI attach is:
189
-
190
- * 320 ms on ** Android** and an additional 12 MB
191
- (highly dependent on the screen's physical pixel size).
192
- * 200 ms on ** iOS** and an additional 16 MB
193
- (highly dependent on the screen's physical pixel size).
194
-
195
- Memory-wise, the cost is primarily the graphical memory buffer used for
196
- rendering and is dependent on the screen size.
197
-
198
- Latency-wise, the cost is primarily waiting for the OS callback to provide
199
- Flutter with a rendering surface and compiling the remaining shader programs
200
- that are not pre-emptively predictable. This is a one-time cost.
201
-
202
- When the Flutter UI component is released, the UI-related memory is freed.
203
- This doesn't affect the Flutter state, which lives in the ` FlutterEngine `
204
- (unless the ` FlutterEngine ` is also released).
205
-
206
- For performance details on creating more than one ` FlutterEngine ` ,
207
- see [ multiple Flutters] [ ] .
208
-
209
135
[ android-engine ] : {{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html
210
136
[ auxiliary threads ] : {{site.repo.flutter}}/blob/main/docs/about/The-Engine-architecture.md#threading
211
137
[ CAEAGLLayer ] : {{site.apple-dev}}/documentation/quartzcore/caeagllayer
0 commit comments