[Bug]: Device-toolbar viewport size does not match the CSS viewport the page receives (~1.44× larger) #10525
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
Open any local page in the Preview panel (I used a Vite dev server on
http://localhost:5243).Open the device toolbar and set the viewport to
375 × 667(freeform), or pick the iPhone SE preset.In the page, read the CSS viewport:
({ innerWidth, innerHeight, devicePixelRatio, scale: visualViewport.scale })Repeat with
390 × 844and271 × 586.
Expected behavior#
The CSS viewport the page lays out in matches the size the device toolbar displays: 375 × 667 gives innerWidth === 375, so mobile breakpoints and wrapping behave as they would on the named device.
Actual behavior#
The page receives a viewport about 1.44× larger than the displayed size, at every size:
| Toolbar setting | innerWidth × innerHeight |
|---|---|
| 375 × 667 | 540 × 961 |
| 390 × 844 | 562 × 1216 |
| 271 × 586 | 390 × 844 |
devicePixelRatio is 2 and visualViewport.scale is 1, so the page itself is not zoomed; the panel is supplying a larger viewport than it reports. preview_status sometimes reports the displayed size (viewport: {width: 390, height: 844}) while the DOM reports 562 for the same tab.
The practical effect is that a "375 wide" preview renders layouts a real 375px device would not: a header that wraps to two rows on an iPhone SE stays on one row here, and a day strip shows eight days where the device shows five. To see the true 375px layout you have to type 260 × 463.
This may be tied to the preview zoom level (the kebab-menu zoom from #8900). In Chrome's device toolbar, zoom scales the rendered frame without changing the CSS viewport; here the CSS viewport seems to scale with it. The preview_resize timeouts are already covered by #3712 and are not part of this report.
Version#
T3 Code (Nightly) 0.0.38-nightly.20260901.1250, macOS 26.6.2, external display reporting screen.width 2560 at 2×. MCP client: Claude Code.
juliusmarminge added labelsvia-triage
juliusmarminge added labelsbug
Note
Grok responding on behalf of Julius.
Fixed by #14039, which just merged: local preview webviews are now sized with the ratio of guest zoom to host zoom, so the CSS viewport the page receives matches the device-toolbar size when the app window is zoomed. Please reopen if you still see a mismatch on the next nightly.
juliusmarminge closed this
Sign in to join this conversation.
Thanks for the measurements — this looks like a real desktop Preview bug, not a duplicate of the nearby zoom/resize threads.
What we think is going on
The device toolbar and
data-preview-css-*show the requested size (375×667, iPhone SE, etc.). The guest<webview>is laid out asrequested × previewZoomin the host page, then Electron applies the tab’s ownsetZoomFactor. That pairing is meant to keep CSSinnerWidthat the requested size (same idea as Chrome’s device mode: visual scale should not change the layout viewport).Your ~1.44× ratio is consistent at every size (
375→540,390→562,271→390, and the260×463workaround). That factor is Chromium zoom level 2 (1.2² = 1.44), not a Preview kebab-zoom step (those are 110% / 125% / 150% / …). App UI zoom (View → Zoom In/Out, Cmd+=) usessetZoomLevelin 0.5 steps; four steps lands on 1.44.#6649 stopped app zoom from visually zooming the previewed page by re-asserting the tab zoom on the guest. That matches
visualViewport.scale === 1anddevicePixelRatio === 2. The leftover effect is that the webview’s box is still sized in the zoomed host, so the page’s CSS viewport grows while the toolbar still says 375.preview_status.viewportSettingis the toolbar value;viewportis liveinnerWidth/innerHeightwhen the guest is rendering. Those can disagree for this reason (separate from thepreview_resizetimeouts in #3712).Not the same bug as
390→427preset case there is ~one app-zoom step,1.2^0.5, so related class, different report)Workaround
View → Actual Size(Cmd+0) so the app chrome is at 100%, then re-checkinnerWidth. Preview kebab zoom at 100% should also stay at 100%. Until this is fixed, the toolbar size is not a reliable CSS viewport.Fix direction
Keep guest
innerWidth/innerHeightequal to the toolbar setting after both host window zoom and preview tab zoom — visual fit/zoom only, like Chrome’s device toolbar. Desktop-only; web/mobile do not host this<webview>.