-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(ios/macos): Add handler for web content process termination #14325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat(ios/macos): Add handler for web content process termination #14325
Conversation
Package Changes Through 2954c83There are 11 changes which include @tauri-apps/api with minor, tauri-cli with minor, tauri-utils with minor, tauri-runtime-wry with minor, tauri-runtime with minor, tauri with minor, tauri-bundler with minor, @tauri-apps/cli with minor, tauri-build with minor, tauri-codegen with patch, tauri-macros with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
This commit fixes the critical issue where the app shows a blank screen when reopened after being inactive on iPhone for extended periods. **Problem:** - iOS terminates the WKWebView's WebContent process when app is backgrounded - JavaScript-based detection cannot work because the JS engine is part of the terminated process - Users see about:blank and must force-close the app **Solution:** 1. Patched wry to dev branch with WebView process termination handler (wry#1624) 2. Added native iOS health monitoring in Rust that runs in main app process 3. Monitors WebView responsiveness every 2 seconds via JavaScript eval 4. Automatically reloads page when WebView becomes unresponsive 5. Removed ineffective JavaScript-only recovery code from App.jsx **Technical Details:** - Uses Cargo patch to pull wry from GitHub dev branch - Native monitoring survives WebContent process termination - Spawns background thread for continuous health checks - See IOS_WEBVIEW_FIX.md for full documentation **References:** - Upstream fix: tauri-apps/wry#1624 - Related PR: tauri-apps/tauri#14325 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…tion This commit replaces the polling-based workaround with a proper native implementation using Apple's official WKNavigationDelegate protocol. **What Changed:** 1. Implemented native WKNavigationDelegate in webview_helper.rs using objc2 2. Added ProcessTerminationDelegate class that implements webViewWebContentProcessDidTerminate 3. Removed inefficient polling code that checked WebView health every 2 seconds 4. Removed unused imports (WebviewWindowExt, sel) 5. Updated documentation to reflect proper implementation **Technical Implementation:** - Forward-declared WKWebView and WKNavigationDelegate using objc2 extern declarations - Created custom Objective-C class at runtime using define_class! macro - Set navigation delegate directly on WKWebView instance - Stored delegate in thread-local storage to keep it alive - Automatically reloads page when iOS terminates WebContent process **Benefits:** ✅ Uses Apple's official delegate method (proper standard) ✅ No polling - called directly by WebKit framework ✅ Zero performance impact when running normally ✅ No battery drain from background thread ✅ Clean, maintainable code following existing patterns ✅ Follows same objc2 pattern as keyboard scroll prevention **References:** - Apple WKNavigationDelegate: https://developer.apple.com/documentation/webkit/wknavigationdelegate - wry PR #1624: tauri-apps/wry#1624 - Tauri PR #14325: tauri-apps/tauri#14325 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This PR depends on tauri-apps/wry#1624