Skip to content

fix(v3/darwin): zoom the page with WKWebView.pageZoom instead of magnification - #6227

Open
APshenkin wants to merge 1 commit into
wailsapp:masterfrom
APshenkin:darwin-page-zoom
Open

APshenkin wants to merge 1 commit into
wailsapp:masterfrom
APshenkin:darwin-page-zoom

Conversation

@APshenkin

@APshenkin APshenkin commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

On macOS Window.ZoomIn() / ZoomOut() / ZoomReset() / SetZoom() / GetZoom() — and the ZoomIn / ZoomOut / ResetZoom menu roles built on them — drive -[WKWebView setMagnification:]. Magnification is a view-level scale transform: the layout viewport stays as it was, the page is drawn larger and clipped at the window edges, nothing reflows. Windows (put_ZoomFactor) and Linux (webkit_web_view_set_zoom_level) implement the same API as a browser zoom, and so does Safari.

This switches the darwin implementation to WKWebView.pageZoom (macOS 11+), which is that browser zoom: the CSS viewport shrinks, text wraps, responsive layouts adapt — the behaviour the other two backends already have. Details and measurements in #6226.

Changes

  • windowZoomSet / windowZoomGet / windowZoomIn / windowZoomOut go through two static helpers that use pageZoom and fall back to magnification below macOS 11 — the package is compiled with -mmacosx-version-min=10.13, so the @available guard keeps it warning-free there.
  • windowZoomReset resets the page zoom and keeps resetting the magnification, so a pinch zoom (AllowsMagnification) still returns to actual size on ⌘0.
  • Step size (0.05) and the 1.0 floor on the way down are unchanged; GetZoom() now reports the page zoom factor.

Fixes #6226

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • WEP (proposal only; no implementation)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Repro app from #6226 — 800 px window, long paragraph, ZoomIn() × 6 then ZoomReset(), metrics reported by the page:

documentElement.clientWidth visualViewport.width visualViewport.scale paragraph lines right-edge marker
master, zoomed 800 615 1.30 10 776 (clipped)
this PR, zoomed 616 615 1.00 13 591 (visible)

GetZoom() returns 1.30 in both; ZoomReset() restores the initial values (800 / 800 / 1.00 / 10 / 776) in both. The recordings in #6226 show the same difference interactively. go test ./pkg/application/ passes; no new compiler warnings.

  • Windows
  • macOS
  • Linux

Test Configuration

# System
┌──────────────────────────────┐
| Name          | MacOS        |
| Version       | 27.0         |
| ID            | 26A428       |
| Branding      | MacOS 27.0   |
| Platform      | darwin       |
| Architecture  | arm64        |
| Apple Silicon | true         |
| CPU           | Apple M4 Max |
| CPU           | Apple M4 Max |
| GPU           | 40 cores     |
| Memory        | 128 GB       |
└──────────────────────────────┘
# Build Environment
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Wails CLI      | v3.0.0-dev                                                                                          |
| Go Version     | go1.27.1                                                                                            |
| -buildmode     | exe                                                                                                 |
| -compiler      | gc                                                                                                  |
| CGO_CFLAGS     |                                                                                                     |
| CGO_CPPFLAGS   |                                                                                                     |
| CGO_CXXFLAGS   |                                                                                                     |
| CGO_ENABLED    | 1                                                                                                   |
| CGO_LDFLAGS    |                                                                                                     |
| DefaultGODEBUG | cryptocustomrand=1,tlssecpmlkem=0,tracebacklabels=0,urlstrictcolons=0,x509sslcertoverrideplatform=0 |
| GOARCH         | arm64                                                                                               |
| GOARM64        | v8.0                                                                                                |
| GOOS           | darwin                                                                                              |
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Checklist:

  • (v2 only) I have updated website/src/pages/changelog.mdx with details of this PR (v3 changelog entries are added automatically)
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation — the docs do not describe the zoom API, nothing to change
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works — WKWebView behaviour, verified with the repro above
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes
    • Improved webview zoom compatibility on macOS 11 and later while preserving support for older versions.
    • Zoom-out continues to stop at the minimum zoom level, and reset returns the webview to its default zoom.

…ification

ZoomIn/ZoomOut/ZoomReset/SetZoom/GetZoom on macOS drove
-[WKWebView setMagnification:], a view-level scale: the layout viewport
stays the same, the page is drawn larger and clipped at the window
edges, nothing reflows. Windows (put_ZoomFactor) and Linux
(webkit_web_view_set_zoom_level) implement the same API as a browser
zoom, and so does Safari.

WKWebView.pageZoom (macOS 11+) is that browser zoom; below macOS 11 the
magnification path stays as the fallback. ZoomReset also keeps resetting
the magnification so a pinch zoom (AllowsMagnification) still returns to
actual size.

Fixes wailsapp#6226
@github-actions github-actions Bot added Bug Something isn't working v3 MacOS labels Oct 5, 2026
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: wailsapp/wails/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d5007056-f22f-44c0-9891-44211a9783d6
📥 Commits

Reviewing files that changed from the base of the PR and between 3a83b2c and d9f2b85.

📒 Files selected for processing (1)
  • v3/pkg/application/webview_window_darwin.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

macOS webview zoom uses WKWebView.pageZoom on macOS 11 and later. Earlier macOS versions use magnification. Reset, set, get, increment, and decrement operations use version-aware helpers.

Changes

macOS Webview Zoom

Layer / File(s) Summary
Zoom helpers and operations
v3/pkg/application/webview_window_darwin.go
Added helpers that use pageZoom on macOS 11 and later, and magnification on earlier versions. Updated zoom operations to use the helpers. Reset also sets magnification to 1.0. Zoom-out retains its existing threshold and decrement behavior.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: leaanthony

Merge Risk: ⚪ Minimal · up to d9f2b

The macOS zoom change is ready to merge after normal checks; no specific unresolved behavior issue was identified.

Architecture Summary

Architecture risk: 🔵 Low · up to d9f2b

The change affects 1 system.

Changed systems: v3

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — v3 (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in v3/pkg/application/webview_window_darwin.go: Added zoom helpers that read and write pageZoom on macOS 11 or later and fall back to magnification on earlier versions.
  • observed — Modified behavior in v3/pkg/application/webview_window_darwin.go: Zoom reset, set, get, and increment now use the compatibility helpers instead of directly reading or setting magnification. Reset also directly sets magnification to 1.0; decrement uses the helper and retains the existing rule of subtracting 0.05 only when zoom exceeds 1.05, otherwise resetting to 1.0.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the macOS change to use WKWebView.pageZoom instead of magnification.
Description check ✅ Passed The description summarizes the change, links the fixed issue, identifies the change type, and provides reproducible macOS test results and test configuration. It also completes the applicable checklis…
Linked Issues check ✅ Passed Issue #6226 requires macOS browser-style zoom, an older-macOS fallback, and reset of both zoom modes. The diff uses WKWebView.pageZoom behind a macOS 11 availability check, falls back to magnificati…
Out of Scope Changes check ✅ Passed The diff changes only macOS zoom handling in webview_window_darwin.go. Each change supports issue #6226. No unrelated changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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

A rabbit taps the zoom control,
The page reflows from edge to edge.
On older Macs, magnification stays,
Reset brings both scales back to one.
Soft paws applaud the tidy view.

Comment @coderabbitai help to get the list of available commands.

@taliesin-ai

Copy link
Copy Markdown
Collaborator

Automated v3 GA-readiness test result for head d9f2b85f97235c9ae7fcd1866022d3e86962128f

Platform CLI build Unit tests (./pkg/... ./internal/...) Example build (examples/window)
macOS (mac-node1) PASS PASS (51/51 pkgs) PASS
Windows (win-node1) PASS PASS (52/52 pkgs) PASS
Linux not run (darwin-only change; Linux node unavailable)

The results match the master baseline at 1a6053d8, which passed on both platforms. The app was not launched because there was no GUI session over SSH, so the zoom behaviour itself was not checked at runtime. This comment is only a build and test report. It is not a review of the behaviour change.

This branch has not been deployed

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

Labels

Bug Something isn't working MacOS v3

Projects

None yet

2 participants