@@ -47,24 +47,11 @@ class EngineWindow extends ui.Window {
4747
4848 @override
4949 ui.Size get physicalSize {
50- if (_physicalSize? .value == null ) {
51- _computePhysicalSize ();
52- }
53- assert (_physicalSize != null );
54- assert (_physicalSize.value != null );
55- return _physicalSize.value;
56- }
57-
58- /// Computes the physical size of the screen from [html.window] .
59- ///
60- /// This function is expensive. It triggers browser layout if there are
61- /// pending DOM writes.
62- void _computePhysicalSize () {
6350 bool override = false ;
6451
6552 assert (() {
6653 if (webOnlyDebugPhysicalSizeOverride != null ) {
67- _physicalSize = FrameReference <ui. Size >( webOnlyDebugPhysicalSizeOverride) ;
54+ _physicalSize = webOnlyDebugPhysicalSizeOverride;
6855 override = true ;
6956 }
7057 return true ;
@@ -81,15 +68,23 @@ class EngineWindow extends ui.Window {
8168 windowInnerWidth = html.window.innerWidth * devicePixelRatio;
8269 windowInnerHeight = html.window.innerHeight * devicePixelRatio;
8370 }
84- _physicalSize = FrameReference <ui.Size >(ui.Size (
85- windowInnerWidth,
86- windowInnerHeight,
87- ));
71+ if (windowInnerWidth != _lastKnownWindowInnerWidth ||
72+ windowInnerHeight != _lastKnownWindowInnerHeight) {
73+ _lastKnownWindowInnerWidth = windowInnerWidth;
74+ _lastKnownWindowInnerHeight = windowInnerHeight;
75+ _physicalSize = ui.Size (
76+ windowInnerWidth,
77+ windowInnerHeight,
78+ );
79+ }
8880 }
81+
82+ return _physicalSize;
8983 }
9084
91- /// Lazily populated and cleared at the end of the frame.
92- FrameReference <ui.Size > _physicalSize;
85+ ui.Size _physicalSize = ui.Size .zero;
86+ double _lastKnownWindowInnerWidth = - 1 ;
87+ double _lastKnownWindowInnerHeight = - 1 ;
9388
9489 /// Overrides the value of [physicalSize] in tests.
9590 ui.Size webOnlyDebugPhysicalSizeOverride;
0 commit comments