From 42743f23eb11191f07d36be3c2e0db2b7188559f Mon Sep 17 00:00:00 2001 From: Le Minh Hoang Date: Sun, 24 Oct 2021 23:11:21 +0700 Subject: [PATCH 1/2] fix. Crash happens when HeadlessInAppWebView's dispose function is called in iOS --- ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift b/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift index 6fb9a1be..4bfa9e75 100644 --- a/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift +++ b/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift @@ -21,6 +21,10 @@ public class HeadlessInAppWebView : FlutterMethodCallDelegate { self.channel?.setMethodCallHandler(self.handle) } + deinit { + dispose() + } + public override func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { let arguments = call.arguments as? NSDictionary From 6635a7e8dfbe60da943c792c53972e4d87d9b816 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Sat, 16 Apr 2022 00:24:16 +0200 Subject: [PATCH 2/2] Update HeadlessInAppWebView.swift --- .../HeadlessInAppWebView/HeadlessInAppWebView.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift b/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift index 4bfa9e75..b5f2ef62 100644 --- a/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift +++ b/ios/Classes/HeadlessInAppWebView/HeadlessInAppWebView.swift @@ -21,10 +21,6 @@ public class HeadlessInAppWebView : FlutterMethodCallDelegate { self.channel?.setMethodCallHandler(self.handle) } - deinit { - dispose() - } - public override func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { let arguments = call.arguments as? NSDictionary @@ -96,4 +92,9 @@ public class HeadlessInAppWebView : FlutterMethodCallDelegate { HeadlessInAppWebViewManager.webViews.removeValue(forKey: id) flutterWebView = nil } + + deinit { + print("HeadlessInAppWebView - dealloc") + dispose() + } }