feat(v3/macos): isolate private macOS APIs behind an appstore build tag - #6060
Draft
leaanthony wants to merge 2 commits into
Draft
feat(v3/macos): isolate private macOS APIs behind an appstore build tag#6060leaanthony wants to merge 2 commits into
appstore build tag#6060leaanthony wants to merge 2 commits into
Conversation
Every undocumented WebKit and AppKit call Wails makes on macOS now lives in mac_private_api_darwin.go, behind a small set of wailsPrivate* functions. Building with -tags appstore selects mac_private_api_appstore_darwin.go instead, which implements the same functions with public APIs or documented no-ops. The Go API is identical in both builds; only the visual result differs where macOS offers no public equivalent. Isolated surfaces: - WKWebView transparency (drawsBackground, backgroundColor) - Web Inspector (_inspector, developerExtrasEnabled) - NSGlassEffectView cross-window grouping and undocumented style values Also adds MacWebviewPreferences.PreferPageRenderingUpdatesNear60FPS, which toggles WebKit's PreferPageRenderingUpdatesNear60FPSEnabled feature flag. WebKit enables it by default and it rounds the display refresh rate down to the nearest multiple of 60, so a 120Hz ProMotion display drives the page at 60fps. Setting it to application.Disabled lets the webview render at the display's native rate. Ignored under -tags appstore. On macOS 13.3+ the Web Inspector is now enabled through the public WKWebView.inspectable property, keeping the private preference only as a fallback for older systems. Three tests keep the seam honest, and all run on any platform: private references may not appear outside the guarded files, the build variants must be mutually exclusive, and both variants must implement the same functions. Refs #6056
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Description
Every undocumented WebKit and AppKit call Wails makes on macOS now lives in a single file,
v3/pkg/application/mac_private_api_darwin.go, behind a small set ofwailsPrivate*functions. Building with-tags appstoreselectsmac_private_api_appstore_darwin.goinstead, which implements the same functions with public APIs or documented no-ops. The Go API is identical in both builds; only the visual result differs where macOS offers no public equivalent.Isolated surfaces:
-tags appstoredrawsBackground,backgroundColor)underPageBackgroundColoris set instead_inspector,developerExtrasEnabled)OpenDevTools()is a no-op; the window is still inspectable from Safari's Develop menu on macOS 13.3+NSGlassEffectViewcross-window grouping and undocumented style valuesNSAppearanceTwo related changes come with it:
MacWebviewPreferences.PreferPageRenderingUpdatesNear60FPStoggles WebKit's feature flag of the same name. WebKit enables it by default, and it rounds the display's refresh rate down to the nearest whole multiple of 60 (framesPerSecondNearestFullSpeedinAnimationFrameRate.cpp), so a 120Hz ProMotion display drives the page at 60fps and a 165Hz display at 55fps. Setting it toapplication.Disabledlets the webview render at the display's native rate. There is no public API for this, so it is ignored under-tags appstore.WKWebView.inspectableproperty, keeping the privatedeveloperExtrasEnabledpreference only as a fallback for older systems. This shrinks the private surface of default builds too.Refs #6056
Supersedes #5955, which took the same approach under the name
noprivateapis; that branch has since fallen behindmaster. Happy to close this instead if you would rather land that one.Type of change
How Has This Been Tested?
Not yet built or run on a Mac — this was developed in a Linux container, so the Objective-C has been reviewed but not compiled. It needs a macOS build of both variants before it leaves draft.
What has been verified, on Linux:
go listforGOOS=darwinselects exactly one variant per configuration: the private files by default, the appstore files with-tags appstore, and only the always-on appstore file with-tags appstore,production.mac_private_api_test.go, all platform-independent:TestPrivateMacAPIsAreIsolated— no private selector or key may appear in any other Apple-platform source. Verified to fail when one is reintroduced.TestPrivateMacAPIBuildVariantsAreExclusive— the variants never compile together.TestPrivateMacAPIVariantsImplementTheSameFunctions— every declared seam function is implemented by both variants, so a missing no-op fails on Linux rather than at link time on a Mac.Still to check on hardware:
PreferPageRenderingUpdatesNear60FPS: application.Disabledreaches ~120fps on a ProMotion display via therequestAnimationFramecounter from [v3/macOS] WKWebView capped at 60 FPS on ProMotion display #6056.-tags appstorebinary is free of the private symbols.Test Configuration
Linux container; no macOS toolchain available.
Checklist:
pkg/applicationcannot be built in this container (no GTK)Generated by Claude Code