WebView: withMinimumDeviceScaleFactor — fix blur on low-DPI displays (pageZoom / RasterizationScale)#38
Merged
Conversation
…-DPI Floors the WebView's effective render scale so content stays sharp when the host scales the editor up on a low-DPI display, where the OS otherwise upscales a 1x raster (blurry, most visibly text). A high-DPI display already exceeds the floor, so it's a no-op there. Both backends shrink the CSS viewport, so the option is documented as responsive-content-only. - macOS: public WKWebView.pageZoom (macOS 11+), applied as max(1, min/backing) in viewDidChangeBackingProperties so it tracks display moves and no-ops on Retina. - Windows: public ICoreWebView2Controller3::put_RasterizationScale = max(min, monitorScale), with ShouldDetectMonitorScaleChanges off and re-applied from the scale-factor notifier. No private SPI; both levers are documented public API. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
The player webview renders blurry on low-DPI (non-Retina / 100%) displays. Confirmed on a secondary 1920×1080 monitor:
devicePixelRatio = 1, CSS viewport1323, fitscale(1.467)— the fixed-size design is upscaled with no backing-resolution headroom.Change
Adds
withMinimumDeviceScaleFactor(double)to bothAppleWkWebViewandWinWebView2— a floor on the WebView's effective render scale, via public APIs:WKWebView.pageZoom(macOS 11+), applied asmax(1, min/backingScaleFactor)inviewDidChangeBackingProperties(tracks display moves; no-op on Retina).ICoreWebView2Controller3::put_RasterizationScale=max(min, monitorScale), monitor auto-detection disabled, re-applied from the scale-factor notifier.Both re-rasterise content at higher density and shrink the CSS viewport, so this is documented as responsive-content-only. Verified on macOS: with
.withMinimumDeviceScaleFactor(2.0), the same monitor reports viewport661/ fitscale(0.733)— the design now downscales off a 2×-rendered page → sharp.Consumer opt-in is in
minimal_core(MKUEmbeddedWebView).Testing
macOS AU/VST3/Standalone green; blur confirmed cleared on a real 1× secondary monitor. Windows path unbuilt (no toolchain) — needs a Windows compile.
🤖 Generated with Claude Code