-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix(macos/ios): Add handler for web content process termination (fix #14371) #14523
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
Changes from all commits
82efc67
f39aeb6
2954c83
04c64dc
c848d4b
13bb380
160d7e2
12d4894
fb41639
05daf95
9d087bd
477e710
b296654
4988d6e
c5a9f9d
3791c6c
1bda592
3e7e738
f184c59
578b7b3
31aef4d
69d4483
f28ede5
cfa6a38
e491659
129f0fb
342e25b
23250c0
b6fb7ec
7160b46
e8991c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "tauri": "minor:feat" | ||
| "tauri-runtime": "minor:feat" | ||
| "tauri-runtime-wry": "minor:feat" | ||
| --- | ||
|
|
||
| Add handler for web content process termination on macOS and iOS. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,9 @@ use crate::{ | |
| EventLoopMessage, EventTarget, Manager, Runtime, Scopes, UriSchemeContext, Webview, Window, | ||
| }; | ||
|
|
||
| #[cfg(any(target_os = "macos", target_os = "ios"))] | ||
| use crate::app::OnWebContentProcessTerminate; | ||
|
|
||
| use super::{ | ||
| window::{DragDropPayload, DRAG_DROP_EVENT, DRAG_ENTER_EVENT, DRAG_LEAVE_EVENT, DRAG_OVER_EVENT}, | ||
| {AppManager, EmitPayload}, | ||
|
|
@@ -70,6 +73,9 @@ pub struct WebviewManager<R: Runtime> { | |
| pub invoke_handler: Box<InvokeHandler<R>>, | ||
| /// The page load hook, invoked when the webview performs a navigation. | ||
| pub on_page_load: Option<Arc<OnPageLoad<R>>>, | ||
| /// The web content process termination hook. | ||
| #[cfg(any(target_os = "macos", target_os = "ios"))] | ||
| pub on_web_content_process_terminate: Option<Arc<OnWebContentProcessTerminate<R>>>, | ||
| /// The webview protocols available to all webviews. | ||
| pub uri_scheme_protocols: Mutex<HashMap<String, Arc<UriSchemeProtocol<R>>>>, | ||
| /// Webview event listeners to all webviews. | ||
|
|
@@ -304,6 +310,29 @@ impl<R: Runtime> WebviewManager<R> { | |
| } | ||
| })); | ||
|
|
||
| #[cfg(any(target_os = "macos", target_os = "ios"))] | ||
| if pending.on_web_content_process_terminate_handler.is_none() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fallback resolves the global Could this be consolidated so the full priority chain is resolved in one place? Something like: // in into_pending_webview:
let handler = per_webview_handler.or_else(|| global_handler.clone());
pending.handler = match handler {
Some(h) => wrap_custom_handler(manager, label, h),
None => build_default_reload_handler(manager, label),
};This way tauri-runtime-wry just passes the handler through to wry without any default logic and the Tauri layer owns all the decisions. |
||
| let app_manager_ = manager.manager_owned(); | ||
| if app_manager_ | ||
| .webview | ||
| .on_web_content_process_terminate | ||
| .is_some() | ||
| { | ||
| let label_ = pending.label.clone(); | ||
| pending | ||
| .on_web_content_process_terminate_handler | ||
| .replace(Box::new(move || { | ||
| if let Some(w) = app_manager_.get_webview(&label_) { | ||
| if let Some(on_web_content_process_terminate) = | ||
| &app_manager_.webview.on_web_content_process_terminate | ||
| { | ||
| on_web_content_process_terminate(&w); | ||
| } | ||
| } | ||
| })); | ||
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "protocol-asset")] | ||
| if !registered_scheme_protocols.contains(&"asset".into()) { | ||
| let asset_scope = app_manager | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.