Skip to content

fix(macos-shell): guard _serverTrust KVC — native shell crashed on every navigation#41

Merged
mdheller merged 2 commits into
mainfrom
fix-webkit-servertrust-crash
Jun 20, 2026
Merged

fix(macos-shell): guard _serverTrust KVC — native shell crashed on every navigation#41
mdheller merged 2 commits into
mainfrom
fix-webkit-servertrust-crash

Conversation

@mdheller

Copy link
Copy Markdown
Contributor

The native WKWebView shell called abort() on every finished navigation (macOS 26 / WebKit 21623). webView:didFinishNavigation: read the private _serverTrust ivar via valueForKey:, which raises NSUndefinedKeyException (not nil) now that the ivar is gone. Wrapped in @try/@catch like the file's other private-API calls. Verified compiles + links; rebuilt binary installed over the crashing app.

🤖 Generated with Claude Code

mdheller added 2 commits June 19, 2026 22:05
The native WKWebView shell aborted on EVERY finished navigation on macOS 26 /
WebKit 21623. webView:didFinishNavigation: read the private WKWebView ivar via
[wv valueForKey:@"_serverTrust"] with a comment claiming it was 'graceful if
absent' — but valueForKey: on an UNDEFINED key raises NSUndefinedKeyException,
it does not return nil. _serverTrust was removed/renamed on newer WebKit, so
the unhandled exception called abort() (SIGABRT) right after page load.

Wrap the private-KVC read in @try/@catch (trust=NULL on miss), matching how the
other private-API calls in this file are already guarded. Verified: compiles +
links cleanly; rebuilt binary installed over the crashing app.

Crash: -[BBDelegate webView:didFinishNavigation:] -> -[WKWebView
valueForUndefinedKey:] -> NSException -> abort().
Nothing in the repo compiled the native WKWebView shell into a .app — it was
built by hand, which is exactly how the _serverTrust KVC crash shipped without
anyone noticing. Add scripts/bearbrowser-build-native-shell.sh:

  1. gates on verify-native-macos-shell.sh (contract greps + throwaway compile)
  2. compiles BearBrowserWebKitLauncher.m (Cocoa/WebKit/AVFoundation/Security)
  3. renders Info.plist from packaging/macos/Info.plist.template
  4. installs bundle resources (BearBrowser-start.html, fonts/, icon)
  5. ad-hoc signs + clears quarantine
  6. optional --install to replace /Applications/BearBrowser.app

Verified: full run produces a valid signed BearBrowser.app. Now this whole
class of bug is caught by the gate before a build can ship.
@mdheller mdheller merged commit 81581de into main Jun 20, 2026
18 checks passed
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