fix(macos-shell): guard _serverTrust KVC — native shell crashed on every navigation#41
Merged
Merged
Conversation
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.
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.
The native WKWebView shell called abort() on every finished navigation (macOS 26 / WebKit 21623).
webView:didFinishNavigation:read the private_serverTrustivar viavalueForKey:, which raisesNSUndefinedKeyException(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