基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
fix(windows): do not trigger callback after webiview disposed
Prediditb9c18304a62c
diff --git a/lib/webview/webview_controller_impel/webview_windows_controller_impel.dart b/lib/webview/webview_controller_impel/webview_windows_controller_impel.dartindex 26800667..9d2067a3 100644--- a/lib/webview/webview_controller_impel/webview_windows_controller_impel.dart+++ b/lib/webview/webview_controller_impel/webview_windows_controller_impel.dart@@ -16,8 +16,7 @@ class WebviewWindowsItemControllerImpelawait _setupProxy();headlessWebview ??= HeadlessWebview();await headlessWebview!.run();- await headlessWebview!- .setPopupWindowPolicy(WebviewPopupWindowPolicy.deny);+ await headlessWebview!.setPopupWindowPolicy(WebviewPopupWindowPolicy.deny);initEventController.add(true);}@@ -56,6 +55,7 @@ class WebviewWindowsItemControllerImpelisVideoSourceLoaded = false;videoLoadingEventController.add(true);subscriptions.add(headlessWebview!.onM3USourceLoaded.listen((data) {+ if (headlessWebview == null) return;String url = data['url'] ?? '';if (url.isEmpty) {return;@@ -68,6 +68,7 @@ class WebviewWindowsItemControllerImpelvideoParserEventController.add((url, offset));}));subscriptions.add(headlessWebview!.onVideoSourceLoaded.listen((data) {+ if (headlessWebview == null) return;String url = data['url'] ?? '';if (url.isEmpty) {return;@@ -106,13 +107,18 @@ class WebviewWindowsItemControllerImpelWebviewController.disposeEnvironment();}- // The webview_windows package does not have a method to unload the current page.- // The loadUrl method opens a new tab, which can lead to memory leaks.- // Directly disposing of the webview controller would require reinitialization when switching episodes, which is costly.+ // The webview_windows package does not have a method to unload the current page.+ // The loadUrl method opens a new tab, which can lead to memory leaks.+ // Directly disposing of the webview controller would require reinitialization when switching episodes, which is costly.// Therefore, this method is used to redirect to a blank page instead.Future<void> redirect2Blank() async {- await headlessWebview!.executeScript('''- window.location.href = 'about:blank';- ''');+ if (headlessWebview == null) return;+ try {+ await headlessWebview!.executeScript('''+ window.location.href = 'about:blank';+ ''');+ } catch (e) {+ KazumiLogger().d('WebView: redirect2Blank skipped (likely disposed): $e');+ }}}