This commit is contained in:
Lorenzo Pichilli 2023-11-14 22:47:54 +01:00
parent 8dfddc2e12
commit acb20fc10a
12 changed files with 37 additions and 11 deletions

View File

@ -4,6 +4,7 @@
- Added `disableWebView` static method on `InAppWebViewController` for Android - Added `disableWebView` static method on `InAppWebViewController` for Android
- Added support for Android `WebViewFeature.isStartupFeatureSupported`, `WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS`, `WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX`, `WebViewFeature.WEB_MESSAGE_ARRAY_BUFFER` - Added support for Android `WebViewFeature.isStartupFeatureSupported`, `WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS`, `WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX`, `WebViewFeature.WEB_MESSAGE_ARRAY_BUFFER`
- Added `WebMessage.type` property - Added `WebMessage.type` property
- Fixed "iOS EXC_BAD_ACCESS crash on kill app with InAppWebView keyboard open" [#1837](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1837)
### BREAKING CHANGES ### BREAKING CHANGES

View File

@ -25,7 +25,9 @@ class _HeadlessInAppWebViewExampleScreenState
headlessWebView = new HeadlessInAppWebView( headlessWebView = new HeadlessInAppWebView(
initialUrlRequest: URLRequest(url: url), initialUrlRequest: URLRequest(url: url),
initialSettings: InAppWebViewSettings(), initialSettings: InAppWebViewSettings(
isInspectable: kDebugMode,
),
onWebViewCreated: (controller) { onWebViewCreated: (controller) {
print('HeadlessInAppWebView created!'); print('HeadlessInAppWebView created!');
}, },

View File

@ -80,6 +80,7 @@ public class HeadlessInAppWebView : Disposable {
channelDelegate?.dispose() channelDelegate?.dispose()
channelDelegate = nil channelDelegate = nil
plugin?.headlessInAppWebViewManager?.webViews[id] = nil plugin?.headlessInAppWebViewManager?.webViews[id] = nil
flutterWebView?.dispose(removeFromSuperview: true)
flutterWebView = nil flutterWebView = nil
plugin = nil plugin = nil
} }

View File

@ -630,6 +630,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
channelDelegate?.dispose() channelDelegate?.dispose()
channelDelegate = nil channelDelegate = nil
webView?.dispose() webView?.dispose()
webView?.removeFromSuperview()
webView = nil webView = nil
view = nil view = nil
if previousStatusBarStyle != -1 { if previousStatusBarStyle != -1 {

View File

@ -9,7 +9,7 @@ import Foundation
import WebKit import WebKit
public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable { public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable {
var myView: UIView? var myView: UIView?
var keepAliveId: String? var keepAliveId: String?
@ -185,15 +185,27 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
} }
} }
public func dispose() { // method added to fix:
// https://github.com/pichillilorenzo/flutter_inappwebview/issues/1837
public func dispose(removeFromSuperview: Bool) {
if keepAliveId == nil { if keepAliveId == nil {
if let webView = webView() { if let webView = webView() {
webView.dispose() webView.dispose()
if removeFromSuperview {
webView.removeFromSuperview()
}
}
if removeFromSuperview {
myView?.removeFromSuperview()
} }
myView = nil myView = nil
} }
} }
public func dispose() {
dispose(removeFromSuperview: false)
}
deinit { deinit {
debugPrint("FlutterWebViewController - dealloc") debugPrint("FlutterWebViewController - dealloc")
dispose() dispose()

View File

@ -3300,7 +3300,6 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
isPausedTimersCompletionHandler = nil isPausedTimersCompletionHandler = nil
SharedLastTouchPointTimestamp.removeValue(forKey: self) SharedLastTouchPointTimestamp.removeValue(forKey: self)
callAsyncJavaScriptBelowIOS14Results.removeAll() callAsyncJavaScriptBelowIOS14Results.removeAll()
super.removeFromSuperview()
plugin = nil plugin = nil
} }

View File

@ -79,7 +79,7 @@ public class InAppWebViewManager: ChannelDelegate {
public func disposeKeepAlive(keepAliveId: String) { public func disposeKeepAlive(keepAliveId: String) {
if let flutterWebView = keepAliveWebViews[keepAliveId] as? FlutterWebViewController { if let flutterWebView = keepAliveWebViews[keepAliveId] as? FlutterWebViewController {
flutterWebView.keepAliveId = nil flutterWebView.keepAliveId = nil
flutterWebView.dispose() flutterWebView.dispose(removeFromSuperview: true)
keepAliveWebViews[keepAliveId] = nil keepAliveWebViews[keepAliveId] = nil
} }
} }

View File

@ -82,9 +82,7 @@ public class HeadlessInAppWebView : Disposable {
channelDelegate?.dispose() channelDelegate?.dispose()
channelDelegate = nil channelDelegate = nil
plugin?.headlessInAppWebViewManager?.webViews[id] = nil plugin?.headlessInAppWebViewManager?.webViews[id] = nil
if let view = flutterWebView?.view() { flutterWebView?.dispose(removeFromSuperview: true)
view.superview?.removeFromSuperview()
}
flutterWebView = nil flutterWebView = nil
plugin = nil plugin = nil
} }

View File

@ -326,6 +326,7 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
channelDelegate?.dispose() channelDelegate?.dispose()
channelDelegate = nil channelDelegate = nil
webView?.dispose() webView?.dispose()
webView?.removeFromSuperview()
webView = nil webView = nil
window = nil window = nil
plugin = nil plugin = nil

View File

@ -174,15 +174,27 @@ public class FlutterWebViewController: NSObject, /*FlutterPlatformView,*/ Dispos
} }
} }
public func dispose() { // method added to fix:
// https://github.com/pichillilorenzo/flutter_inappwebview/issues/1837
public func dispose(removeFromSuperview: Bool) {
if keepAliveId == nil { if keepAliveId == nil {
if let webView = webView() { if let webView = webView() {
webView.dispose() webView.dispose()
if removeFromSuperview {
webView.removeFromSuperview()
}
}
if removeFromSuperview {
myView?.removeFromSuperview()
} }
myView = nil myView = nil
} }
} }
public func dispose() {
dispose(removeFromSuperview: false)
}
deinit { deinit {
debugPrint("FlutterWebViewController - dealloc") debugPrint("FlutterWebViewController - dealloc")
dispose() dispose()

View File

@ -2626,7 +2626,6 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
navigationDelegate = nil navigationDelegate = nil
isPausedTimersCompletionHandler = nil isPausedTimersCompletionHandler = nil
callAsyncJavaScriptBelowIOS14Results.removeAll() callAsyncJavaScriptBelowIOS14Results.removeAll()
super.removeFromSuperview()
plugin = nil plugin = nil
} }

View File

@ -80,7 +80,7 @@ public class InAppWebViewManager: ChannelDelegate {
public func disposeKeepAlive(keepAliveId: String) { public func disposeKeepAlive(keepAliveId: String) {
if let flutterWebView = keepAliveWebViews[keepAliveId] as? FlutterWebViewController { if let flutterWebView = keepAliveWebViews[keepAliveId] as? FlutterWebViewController {
flutterWebView.keepAliveId = nil flutterWebView.keepAliveId = nil
flutterWebView.dispose() flutterWebView.dispose(removeFromSuperview: true)
keepAliveWebViews[keepAliveId] = nil keepAliveWebViews[keepAliveId] = nil
} }
} }