Skip to content

fix(polyfill): innerWidth and innerHeight after a window resize on Windows and Linux - #272

Merged
triniwiz merged 1 commit into
masterfrom
fix/polyfill-desktop-resize
Nov 22, 2026
Merged

triniwiz merged 1 commit into
masterfrom
fix/polyfill-desktop-resize

Conversation

@triniwiz

Copy link
Copy Markdown
Member

Problem

Core raises orientationChanged on every window resize on Windows and Linux. The polyfill's handler (resize.ts) then wrote the screen size it read at load time. At load the app window doesn't exist yet, so that size is the screen's 1920x1080 default, and for a landscape window the handler swaps it. Because the write goes through the live metrics' setters, it pinned innerWidth/innerHeight at 1080x1920 for the rest of the session. That overrode both the window's real size and anything the page had assigned.

The symptom: after maximizing or entering full screen, anything sized from innerWidth/innerHeight goes wrong. In a PixiJS game on Windows (1536x864 DIPs at 125%), the menu camera framed itself from innerHeight = 1920, so the scene zoomed far out and the character drifted to the top of the stage. It stayed that way after restoring the window.

Fix

On Windows and Linux, the handler no longer writes the sizes. The live metrics already read the window (Screen.mainScreen.widthDIPs/heightDIPs), so the handler only updates orientation and emits resize. iOS and Android keep the rotation swap.

Tests

packages/canvas-polyfill/__test__/resize.test.mjs (node --test packages/canvas-polyfill/__test__/resize.test.mjs):

  • desktop: innerWidth/innerHeight follow the window after a resize. This fails on master (1080x1920).
  • desktop: a size the page assigned survives a resize. This fails on master.
  • mobile: a rotation still swaps the size.

I verified it on a Windows laptop: with the patched resize.js, innerWidth/innerHeight match the window after F11, after leaving F11, and after maximize, and the camera framing is correct in all three.

…ndows and Linux

Core raises orientationChanged on every window resize on Windows and
Linux. The handler wrote the screen size read when the polyfill loaded,
before the app window existed: the screen's 1920x1080 defaults, swapped
for a landscape window. Through the live metrics' setters that pinned
innerWidth and innerHeight at 1080x1920 for good, over the window's size
and over whatever the page had assigned. Anything sized from them after
a resize (maximize, full screen) was wrong: a game framing its camera
from innerHeight zoomed far out.

On Windows and Linux the handler now leaves the sizes to the live
metrics, which read the window, and only updates the orientation and
emits resize. iOS and Android keep the rotation swap.
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0c377ac1-a40d-4adb-a1da-a5997cc762aa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@triniwiz
triniwiz merged commit d85804f into master Nov 22, 2026
30 checks passed
@github-actions

Copy link
Copy Markdown

ℹ️ Note: npm publishing is disabled for pull requests.
Publishing is performed only from tag pushes via the npm Release workflow.
If you need a test publish, merge to master — pushes publish pr-tagged prereleases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant