Skip to content

Commit 007e631

Browse files
Xlyptonclaude
andcommitted
fix(web): remove first-paint status-bar hairline on iOS PWA (#74)
After reverting to black-translucent, a thin seam still showed at the very top on a COLD-launched iOS standalone PWA, clearing only after a relayout (e.g. a back-navigation). Cause (flutter/flutter#84833): Flutter's web engine sizes its canvas from document.documentElement.clientHeight on the WebKit path, and that value is briefly unsettled on first paint of a cold PWA (missing the viewport-fit=cover safe-area adjustment) -> the canvas paints a few px short of the true top edge for one frame, exposing a hairline until WebKit settles clientHeight. Alias clientHeight/clientWidth to the already-correct window.innerHeight/ innerWidth via a synchronous inline script BEFORE flutter_bootstrap.js, so the very first read is correct. Inert on Chrome/Android (Flutter reads innerHeight there; getters are configurable and can't throw). Verified the Blink boot path is unaffected by a headless-Chrome smoke. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent ba391a2 commit 007e631

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎web/index.html‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,27 @@
132132
For more details:
133133
* https://docs.flutter.dev/platform-integration/web/initialization
134134
-->
135+
<script>
136+
// iOS Safari PWA first-paint fix (flutter/flutter#84833): on WebKit,
137+
// Flutter's web engine sizes its view from
138+
// document.documentElement.clientHeight/clientWidth rather than
139+
// window.innerHeight/innerWidth. On a cold-launched standalone PWA that
140+
// value is briefly unsettled (missing the viewport-fit=cover safe-area
141+
// adjustment), so Flutter's canvas paints a few px short of the true top
142+
// edge for one frame, exposing a hairline strip at the top until any
143+
// relayout (e.g. a back-navigation) makes WebKit settle it. Aliasing the
144+
// getters to the already-correct window.innerHeight/innerWidth makes the
145+
// very first read correct. Inert on Chrome/Android (Flutter doesn't read
146+
// clientHeight there).
147+
Object.defineProperty(document.documentElement, 'clientHeight', {
148+
get: function () { return window.innerHeight; },
149+
configurable: true,
150+
});
151+
Object.defineProperty(document.documentElement, 'clientWidth', {
152+
get: function () { return window.innerWidth; },
153+
configurable: true,
154+
});
155+
</script>
135156
<script src="flutter_bootstrap.js" async></script>
136157

137158
<script>

0 commit comments

Comments
 (0)