Skip to content

feat(renderer): track devicePixelRatio changes at runtime#166

Closed
sauyon wants to merge 1 commit into
coder:mainfrom
sauyon:sauyon/hidpi-dpr-tracking
Closed

feat(renderer): track devicePixelRatio changes at runtime#166
sauyon wants to merge 1 commit into
coder:mainfrom
sauyon:sauyon/hidpi-dpr-tracking

Conversation

@sauyon
Copy link
Copy Markdown

@sauyon sauyon commented May 18, 2026

The renderer captured window.devicePixelRatio once in its constructor and never re-checked it. Browser zoom, window drags between monitors with different scales, and OS scale changes all leave the canvas backing store sized to the old ratio — blurry one way, oversharp the other.

Subscribe to a matchMedia query pinned to the current DPR and update the field on change. Since each MediaQueryList is bound to one ratio, re-create the query on every change. The render loop's needsResize check picks up the new DPR and forces a full resize+redraw on the next frame, so no explicit render call is needed.

Skip the subscription when the caller pinned a DPR via options — they opted out of browser-driven changes.

The renderer captured window.devicePixelRatio once in its constructor
and never re-checked it. Browser zoom, window drags between monitors
with different scales, and OS scale changes all leave the canvas
backing store sized to the old ratio — blurry one way, oversharp the
other.

Subscribe to a matchMedia query pinned to the current DPR and update
the field on change. Since each MediaQueryList is bound to one ratio,
re-create the query on every change. The render loop's needsResize
check picks up the new DPR and forces a full resize+redraw on the
next frame, so no explicit render call is needed.

Skip the subscription when the caller pinned a DPR via options — they
opted out of browser-driven changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sauyon sauyon force-pushed the sauyon/hidpi-dpr-tracking branch from 90e0c4c to 091a780 Compare May 18, 2026 05:58
@sauyon sauyon closed this May 18, 2026
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