Skip to content

Commit c1c38ad

Browse files
authored
[web] Fix empty first frame in multiview mode (flutter#172493)
The issue was caused by a stale `EngineFlutterView.physicalSize` that happened to be `Size(0, 0)` making rendering a no-op in the first frame. Fixes flutter#172397
1 parent 6937b0c commit c1c38ad

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

engine/src/flutter/lib/web_ui/lib/src/engine/window.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class EngineFlutterView implements ui.FlutterView {
197197
/// the CSS box-model restrictions imposed on its `hostElement` (especially when
198198
/// hiding `overflow`). Flutter does not attempt to interpret the styles of
199199
/// `hostElement` to compute its `physicalConstraints`, only its current size.
200+
@visibleForTesting
200201
void resize(ui.Size newPhysicalSize) {
201202
// The browser uses CSS, and CSS operates in logical sizes.
202203
final ui.Size logicalSize = newPhysicalSize / devicePixelRatio;
@@ -205,7 +206,7 @@ class EngineFlutterView implements ui.FlutterView {
205206
..height = '${logicalSize.height}px';
206207

207208
// Force an update of the physicalSize so it's ready for the renderer.
208-
_computePhysicalSize();
209+
_physicalSize = _computePhysicalSize();
209210
}
210211

211212
/// Lazily populated and cleared at the end of the frame.

engine/src/flutter/lib/web_ui/test/engine/window_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,9 @@ Future<void> testMain() async {
744744
// Resize the host to 20x20 (physical pixels).
745745
view.resize(const ui.Size.square(50));
746746

747+
// The view's physicalSize should be updated too.
748+
expect(view.physicalSize, const ui.Size(50.0, 50.0));
749+
747750
await view.onResize.first;
748751

749752
// The host tightly wraps the rootElement:

0 commit comments

Comments
 (0)