fix #1837
This commit is contained in:
parent
8dfddc2e12
commit
acb20fc10a
@ -4,6 +4,7 @@
|
||||
- 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 `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
|
||||
|
||||
|
@ -25,7 +25,9 @@ class _HeadlessInAppWebViewExampleScreenState
|
||||
|
||||
headlessWebView = new HeadlessInAppWebView(
|
||||
initialUrlRequest: URLRequest(url: url),
|
||||
initialSettings: InAppWebViewSettings(),
|
||||
initialSettings: InAppWebViewSettings(
|
||||
isInspectable: kDebugMode,
|
||||
),
|
||||
onWebViewCreated: (controller) {
|
||||
print('HeadlessInAppWebView created!');
|
||||
},
|
||||
|
@ -80,6 +80,7 @@ public class HeadlessInAppWebView : Disposable {
|
||||
channelDelegate?.dispose()
|
||||
channelDelegate = nil
|
||||
plugin?.headlessInAppWebViewManager?.webViews[id] = nil
|
||||
flutterWebView?.dispose(removeFromSuperview: true)
|
||||
flutterWebView = nil
|
||||
plugin = nil
|
||||
}
|
||||
|
@ -630,6 +630,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
|
||||
channelDelegate?.dispose()
|
||||
channelDelegate = nil
|
||||
webView?.dispose()
|
||||
webView?.removeFromSuperview()
|
||||
webView = nil
|
||||
view = nil
|
||||
if previousStatusBarStyle != -1 {
|
||||
|
@ -9,7 +9,7 @@ import Foundation
|
||||
import WebKit
|
||||
|
||||
public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable {
|
||||
|
||||
|
||||
var myView: UIView?
|
||||
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 let webView = webView() {
|
||||
webView.dispose()
|
||||
if removeFromSuperview {
|
||||
webView.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
if removeFromSuperview {
|
||||
myView?.removeFromSuperview()
|
||||
}
|
||||
myView = nil
|
||||
}
|
||||
}
|
||||
|
||||
public func dispose() {
|
||||
dispose(removeFromSuperview: false)
|
||||
}
|
||||
|
||||
deinit {
|
||||
debugPrint("FlutterWebViewController - dealloc")
|
||||
dispose()
|
||||
|
@ -3300,7 +3300,6 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
|
||||
isPausedTimersCompletionHandler = nil
|
||||
SharedLastTouchPointTimestamp.removeValue(forKey: self)
|
||||
callAsyncJavaScriptBelowIOS14Results.removeAll()
|
||||
super.removeFromSuperview()
|
||||
plugin = nil
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class InAppWebViewManager: ChannelDelegate {
|
||||
public func disposeKeepAlive(keepAliveId: String) {
|
||||
if let flutterWebView = keepAliveWebViews[keepAliveId] as? FlutterWebViewController {
|
||||
flutterWebView.keepAliveId = nil
|
||||
flutterWebView.dispose()
|
||||
flutterWebView.dispose(removeFromSuperview: true)
|
||||
keepAliveWebViews[keepAliveId] = nil
|
||||
}
|
||||
}
|
||||
|
@ -82,9 +82,7 @@ public class HeadlessInAppWebView : Disposable {
|
||||
channelDelegate?.dispose()
|
||||
channelDelegate = nil
|
||||
plugin?.headlessInAppWebViewManager?.webViews[id] = nil
|
||||
if let view = flutterWebView?.view() {
|
||||
view.superview?.removeFromSuperview()
|
||||
}
|
||||
flutterWebView?.dispose(removeFromSuperview: true)
|
||||
flutterWebView = nil
|
||||
plugin = nil
|
||||
}
|
||||
|
@ -326,6 +326,7 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
|
||||
channelDelegate?.dispose()
|
||||
channelDelegate = nil
|
||||
webView?.dispose()
|
||||
webView?.removeFromSuperview()
|
||||
webView = nil
|
||||
window = nil
|
||||
plugin = nil
|
||||
|
@ -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 let webView = webView() {
|
||||
webView.dispose()
|
||||
if removeFromSuperview {
|
||||
webView.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
if removeFromSuperview {
|
||||
myView?.removeFromSuperview()
|
||||
}
|
||||
myView = nil
|
||||
}
|
||||
}
|
||||
|
||||
public func dispose() {
|
||||
dispose(removeFromSuperview: false)
|
||||
}
|
||||
|
||||
deinit {
|
||||
debugPrint("FlutterWebViewController - dealloc")
|
||||
dispose()
|
||||
|
@ -2626,7 +2626,6 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
|
||||
navigationDelegate = nil
|
||||
isPausedTimersCompletionHandler = nil
|
||||
callAsyncJavaScriptBelowIOS14Results.removeAll()
|
||||
super.removeFromSuperview()
|
||||
plugin = nil
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class InAppWebViewManager: ChannelDelegate {
|
||||
public func disposeKeepAlive(keepAliveId: String) {
|
||||
if let flutterWebView = keepAliveWebViews[keepAliveId] as? FlutterWebViewController {
|
||||
flutterWebView.keepAliveId = nil
|
||||
flutterWebView.dispose()
|
||||
flutterWebView.dispose(removeFromSuperview: true)
|
||||
keepAliveWebViews[keepAliveId] = nil
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user