Skip to content

fix: guard WKPreferences.inactiveSchedulingPolicy behind macOS 14.0+ runtime check#322

Merged
validatedev merged 1 commit intorobinebers:mainfrom
beznazwiska:fix/macos-ventura-webkit-compat
Mar 29, 2026
Merged

fix: guard WKPreferences.inactiveSchedulingPolicy behind macOS 14.0+ runtime check#322
validatedev merged 1 commit intorobinebers:mainfrom
beznazwiska:fix/macos-ventura-webkit-compat

Conversation

@beznazwiska
Copy link
Copy Markdown
Contributor

@beznazwiska beznazwiska commented Mar 27, 2026

Summary

OpenUsage crashes on launch on macOS 13.x (Ventura) with:

[WKPreferences setInactiveSchedulingPolicy:]: unrecognized selector sent to instance

WKPreferences.setInactiveSchedulingPolicy was introduced in macOS 14.0 (Sonoma). The current code in webkit_config.rs calls it unconditionally, which sends an unrecognized selector on older systems and causes an immediate abort.

Changes

  • Added a lightweight runtime version check using NSProcessInfo.operatingSystemVersion (already available via the objc2-foundation dependency)
  • On macOS 14.0+: behavior is completely unchangedsetInactiveSchedulingPolicy(.none) is called as before
  • On macOS <14.0: the call is skipped with an informational log message
  • App Nap prevention (app_nap.rs) is unaffected and continues to work on all macOS versions

The change is minimal (12 lines added, 0 removed from the original logic) and introduces no new dependencies.

Test plan

  • Verified the app launches and runs correctly on macOS 13.7 Ventura (Darwin 22.6.0, Intel x86_64)
  • Confirmed cargo build --release compiles without warnings
  • Verify no regression on macOS 14.x / 15.x (the guarded path preserves original behavior)

🤖 Generated with Claude Code


Summary by cubic

Fixes a launch crash on macOS 13 by guarding WKPreferences.setInactiveSchedulingPolicy behind a macOS 14.0+ runtime check. macOS 14+ behavior is unchanged.

  • Bug Fixes
    • Added a runtime check via NSProcessInfo.operatingSystemVersion (from objc2-foundation).
    • Skip the call and log on macOS <14 to avoid the "unrecognized selector" crash.
    • App Nap prevention remains unchanged.
    • No new dependencies; change limited to src-tauri/src/webkit_config.rs.

Written for commit e8c6647. Summary will update on new commits.

…lingPolicy

The `setInactiveSchedulingPolicy` API on `WKPreferences` was introduced
in macOS 14.0 (Sonoma). Calling it unconditionally causes a crash on
macOS 13.x (Ventura) with "unrecognized selector sent to instance".

This adds a lightweight runtime version guard using
`NSProcessInfo.operatingSystemVersion`. On macOS 14.0+ the behavior is
unchanged. On older systems the call is skipped gracefully with a log
message. App Nap prevention (handled separately in `app_nap.rs`) still
works on all supported macOS versions.

Tested on macOS 13.7 Ventura (Darwin 22.6.0, Intel x86_64).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the rust Pull requests that update rust code label Mar 27, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@robinebers
Copy link
Copy Markdown
Owner

LGTM, thank you @beznazwiska

Copy link
Copy Markdown
Collaborator

@validatedev validatedev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@validatedev validatedev merged commit 4e152f7 into robinebers:main Mar 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants