From d543f11652dbf0064dec519e3a8b42628ccc697e Mon Sep 17 00:00:00 2001 From: wangtian Date: Tue, 11 Feb 2025 19:48:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3javaScriptBridgeInterface?= =?UTF-8?q?=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangtian --- .../plugin/webview/in_app_webview/InAppWebView.ets | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets index c533bee1..62a107fb 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets @@ -695,6 +695,12 @@ export default class InAppWebView implements InAppWebViewInterface { this.webViewAssetLoaderExt.dispose(); this.webViewAssetLoaderExt = null; } + if(this.javaScriptBridgeInterface != null){ + this.controller.deleteJavaScriptRegister(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); + this.controller.refresh(); + this.javaScriptBridgeInterface.dispose(); + this.javaScriptBridgeInterface = null; + } } getUrl(): string { -- Gitee From efce0b9be2031be82b5d828e88681e204850007b Mon Sep 17 00:00:00 2001 From: wangtian Date: Fri, 14 Feb 2025 17:11:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=B3=84=E9=9C=B2OOM=E9=97=AE=E9=A2=98=EF=BC=8C=E9=87=8A?= =?UTF-8?q?=E6=94=BEInAppWebView=E7=9B=B8=E5=85=B3=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangtian --- .../webview/in_app_webview/InAppWebView.ets | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets index 62a107fb..da25652e 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets @@ -695,12 +695,30 @@ export default class InAppWebView implements InAppWebViewInterface { this.webViewAssetLoaderExt.dispose(); this.webViewAssetLoaderExt = null; } + if(this.controller){ + try { + this.controller.deleteJavaScriptRegister(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); + this.controller.refresh(); + } catch (error) { + Log.e(TAG, `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + } if(this.javaScriptBridgeInterface != null){ - this.controller.deleteJavaScriptRegister(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); - this.controller.refresh(); this.javaScriptBridgeInterface.dispose(); this.javaScriptBridgeInterface = null; } + if(this.findInteractionController != null){ + this.findInteractionController.dispose(); + this.findInteractionController = null; + } + if(this.pullToRefreshLayout != null){ + this.pullToRefreshLayout.dispose(); + this.pullToRefreshLayout = null; + } + if(this.channelDelegate != null){ + this.channelDelegate.dispose(); + this.channelDelegate = null; + } } getUrl(): string { -- Gitee From ac84a46e804df437d71873675364eb9291880db1 Mon Sep 17 00:00:00 2001 From: wangtian Date: Fri, 14 Feb 2025 18:01:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=B3=84=E9=9C=B2OOM=E9=97=AE=E9=A2=98=EF=BC=8C=E9=87=8A?= =?UTF-8?q?=E6=94=BEInAppWebView=E7=9B=B8=E5=85=B3=E5=AF=B9=E8=B1=A1=20par?= =?UTF-8?q?t2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangtian --- .../find_interaction/FindInteractionController.ets | 5 ++++- .../plugin/webview/in_app_webview/InAppWebView.ets | 10 +++------- .../webview/in_app_webview/InAppWebViewClient.ets | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets index b040118f..936b048f 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/find_interaction/FindInteractionController.ets @@ -68,6 +68,9 @@ export class FindInteractionController implements Disposable { } dispose(): void { - throw new Error('Method not implemented.'); + if(this.channelDelegate != null){ + this.channelDelegate.dispose(); + this.channelDelegate = null; + } } } \ No newline at end of file diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets index da25652e..0bb20066 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebView.ets @@ -74,7 +74,7 @@ export default class InAppWebView implements InAppWebViewInterface { public id: number; public windowId: number | null | undefined; public inAppWebViewClient: InAppWebViewClient | null = null; - public channelDelegate: WebViewChannelDelegate; + public channelDelegate: WebViewChannelDelegate | null = null; private javaScriptBridgeInterface: JavaScriptBridgeInterface | null = null; public customSettings: InAppWebViewSettings; public isLoading: boolean = false @@ -696,12 +696,8 @@ export default class InAppWebView implements InAppWebViewInterface { this.webViewAssetLoaderExt = null; } if(this.controller){ - try { - this.controller.deleteJavaScriptRegister(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); - this.controller.refresh(); - } catch (error) { - Log.e(TAG, `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); - } + this.controller.deleteJavaScriptRegister(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); + this.controller.refresh(); } if(this.javaScriptBridgeInterface != null){ this.javaScriptBridgeInterface.dispose(); diff --git a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets index 72ed83e5..23e24258 100644 --- a/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets +++ b/flutter_inappwebview_ohos/ohos/src/main/ets/components/plugin/webview/in_app_webview/InAppWebViewClient.ets @@ -151,7 +151,7 @@ export default class InAppWebViewClient { URLUtil.guessFileName(event.url, event.contentDisposition, event.mimetype), null ); - this.inAppWebView.channelDelegate.onDownloadStartRequest(downloadStartRequest) + this.inAppWebView.channelDelegate?.onDownloadStartRequest(downloadStartRequest) } } onErrorReceive = (event: Any) => { -- Gitee