[web] Add RenderCanvas sizing diagnostics#188724
Closed
MarlonJD wants to merge 1 commit into
Closed
Conversation
This was referenced Jun 30, 2026
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft status
Diagnostic-only draft for #188724.
This is not a WebKit default enablement PR. It does not flip
webkit: true,and it does not claim the Mobile Safari Skwasm canvas sizing issue is fixed.
What changed
Adds compile-time gated RenderCanvas sizing diagnostics behind:
When enabled, the logs capture the values needed to separate the Mobile Safari
failure branches:
_pixelWidth/_pixelHeightEngineFlutterDisplay.instance.devicePixelRatiowindow.devicePixelRatiovisualViewportwidth/height/scaledocumentElement.clientWidth/clientHeightbitmap transfer
Why
On physical iPhone Mobile Safari, a Skwasm build can load
skwasm_heavy,main.dart.mjs, andmain.dart.wasm, complete benchmark profiles, and producenon-empty canvas pixels while the visible canvas CSS rect collapses to about
0.328125 x 0.328125px.The same failing evidence class has a
1206 x 2142backing store and a browserviewport of about
402 x 714at DPR3. A local-only forced CSS probe thatsets
canvas.style.width = canvas.width / devicePixelRatioandcanvas.style.height = canvas.height / devicePixelRatiorecovers the visiblesurface. The next step is to prove whether the bad value is a stale pixel size,
DPR/viewport timing, or a post-write CSS overwrite.
Refs issue #188723.
Validation
./bin/dart format engine/src/flutter/lib/web_ui/lib/src/engine/compositing/render_canvas.dart--gcs-prod;chrome-dart2js-canvaskit-engine,3/3 tests.
flutter_web_sdk/flutter_js/flutter.jsandcanvaskit/{canvaskit,skwasm,skwasm_heavy}.{js,wasm}.Diagnostic runtime follow-up
The first local rebuilt SDK diagnostic/no-log Simulator bundles were blocked
before canvas creation with:
from
canvaskit/skwasm_heavy.js. Those runs hadprofiles: [],renderCanvasSizingLogs=[], and did not reach the intended canvas sizing logs.Controls narrowed that blocker:
skwasm_heavy.wasminto the local rebuilt bundle didnot recover the run.
errors: []andnormal
402 x 714canvas geometry on the same Simulator.canvaskit/did not rescue localmain.dart.wasm/main.dart.mjs.canvaskit/directory.
contents but left the local
main.dart.mjssupport-runtime shape unchanged.--local-web-sdkpath invoked engine-prebuilt Dart3.12.1withkernel format
130, while the passing cached-SDK path used Dart3.13.0-254.0.devwith kernel format136.After aligning the local engine-prebuilt Dart SDK symlinks to the cached
3.13.0-254.0.devDart SDK and rebuilding the local platform dill set, thealigned local diagnostic bundle moved to the cached-like dart2wasm support
runtime shape and reached RenderCanvas logs.
Aligned diagnostic bundle:
Simulator MobileSafari one-benchmark run:
all-benchmarks-completeskwasm_heavy,main.dart.mjs,main.dart.wasmbench_card_infinite_scrollprofile[]1813requested=1206x2142,pixel=1206x2142,canvasAttr=1206.0x2142.0,[email protected],inlineStyle=402px/714px,computedStyle=402px/714px,[email protected],0.0Physical iPhone MobileSafari one-benchmark run:
all-benchmarks-completeskwasm_heavy,main.dart.mjs,main.dart.wasmbench_card_infinite_scrollprofile[]1807requested=1206x2142,pixel=1206x2142,canvasAttr=1206.0x2142.0,[email protected],inlineStyle=402px/714px,computedStyle=402px/714px,[email protected],0.0visible during the physical run. An automated physical screenshot is still
separate evidence and was not captured in this one-benchmark run.
Physical iPhone manual-screenshot follow-up:
all-benchmarks-completeskwasm_heavy,main.dart.mjs,main.dart.wasm[]5421requested=1206x2142,pixel=1206x2142,canvasAttr=1206.0x2142.0,[email protected],inlineStyle=402px/714px,computedStyle=402px/714px,[email protected],0.0benchmark content for the card, lazy text, and wrapbox scroll benchmarks:
20260630T021605_physical_iphone_skwasm_aligned_dart_sdk_diagnostic_manual_screenshot_window_card_scroll.png,20260630T021605_physical_iphone_skwasm_aligned_dart_sdk_diagnostic_manual_screenshot_window_text_scroll.png,20260630T021605_physical_iphone_skwasm_aligned_dart_sdk_diagnostic_manual_screenshot_window_wrapbox_scroll.png.RenderCanvas log-vs-collapse analysis:
1206 x 2142backing storeand non-empty pixels, but inline/computed CSS and canvas rect collapsed to
0.328125px / 0.328125px._ensureSizesetting1206 x 2142canvasattributes, then
updateLogicalSize:afterwriting402px / 714px, withnext-frame/transfer logs retaining
402 x 714._ensureSizehas a valid backing store andbefore/at
_updateLogicalHtmlCanvasSize()logical CSS write, or a lateroverwrite of that write.
Copied collapsed-bundle style observer follow-up:
diagnostic_bundles/20260629T1735_collapsed_skwasm_ready_rerun_bundle/bundleall-benchmarks-completeskwasm_heavy,main.dart.mjs,main.dart.wasmbench_card_infinite_scrollprofile[]642320.333333px / 0.333333px; the connected computed/rect value is0.328125 x 0.328125; the backing store later reaches1206 x 2142, butthe canvas CSS size is not corrected to
402 x 714.402.0px / 714.0pxwrites in this trace appear to belong toouter
flutter-viewsizing, not the canvas element.Analysis artifact:
Boundary: the diagnostic logging blocker is now narrowed to local Dart
compiler/platform-kernel/support-runtime drift and cleared for the aligned
local diagnostic control. The copied collapsed-bundle observer narrows the
remaining source question further: why does the canvas keep an early
1 / DPRlogical CSS size after the backing store is resized? This does not fix the
original Mobile Safari canvas sizing bug, and it is not default WebKit/Safari
enablement evidence.