From d392d10055d5a2f3f843d77a67a0e0902e440ea2 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 3 Mar 2026 14:27:38 -0500
Subject: [PATCH 01/15] create fix
---
.../webview_flutter_wkwebview/CHANGELOG.md | 4 ++
.../FlutterViewFactory.swift | 39 ++++++++-----------
.../ios/Flutter/AppFrameworkInfo.plist | 2 -
.../ios/Runner.xcodeproj/project.pbxproj | 6 ++-
.../xcshareddata/xcschemes/Runner.xcscheme | 2 +
.../webview_flutter_wkwebview/pubspec.yaml | 2 +-
6 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
index 07544187be1a..ffd9a1222dc9 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
+++ b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 3.23.9
+
+* Updates platform views on iOS to only have a weak reference to the native view.
+
## 3.23.8
* Fixes lossy transition from Dart Color to native UIColor when calling `setBackgroundColor`.
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index 757a329ea364..2e3db6092eb9 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -13,23 +13,23 @@ import Foundation
#error("Unsupported platform.")
#endif
-/// Implementation of `FlutterPlatformViewFactory` that retrieves the view from the `WebKitLibraryPigeonInstanceManager`.
-class FlutterViewFactory: NSObject, FlutterPlatformViewFactory {
- unowned let instanceManager: WebKitLibraryPigeonInstanceManager
-
- #if os(iOS)
- class PlatformViewImpl: NSObject, FlutterPlatformView {
- let uiView: UIView
+#if os(iOS)
+ class PlatformViewImpl: NSObject, FlutterPlatformView {
+ weak var uiView: UIView?
- init(uiView: UIView) {
- self.uiView = uiView
- }
+ init(uiView: UIView) {
+ self.uiView = uiView
+ }
- func view() -> UIView {
- return uiView
- }
+ func view() -> UIView {
+ return uiView ?? UIView()
}
- #endif
+ }
+#endif
+
+/// Implementation of `FlutterPlatformViewFactory` that retrieves the view from the `WebKitLibraryPigeonInstanceManager`.
+class FlutterViewFactory: NSObject, FlutterPlatformViewFactory {
+ unowned let instanceManager: WebKitLibraryPigeonInstanceManager
init(instanceManager: WebKitLibraryPigeonInstanceManager) {
self.instanceManager = instanceManager
@@ -42,14 +42,9 @@ class FlutterViewFactory: NSObject, FlutterPlatformViewFactory {
let identifier: Int64 = args is Int64 ? args as! Int64 : Int64(args as! Int32)
let instance: AnyObject? = instanceManager.instance(forIdentifier: identifier)
- if let instance = instance as? FlutterPlatformView {
- instance.view().frame = frame
- return instance
- } else {
- let view = instance as! UIView
- view.frame = frame
- return PlatformViewImpl(uiView: view)
- }
+ let view = instance as! UIView
+ view.frame = frame
+ return PlatformViewImpl(uiView: view)
}
#elseif os(macOS)
func create(
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist
index 1dc6cf7652ba..391a902b2beb 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist
@@ -20,7 +20,5 @@
????
CFBundleVersion
1.0
- MinimumOSVersion
- 13.0
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
index f7a909728079..30e00333683c 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
@@ -43,6 +43,7 @@
8F1488FE2D2DE27000191744 /* HTTPCookieProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488C82D2DE27000191744 /* HTTPCookieProxyAPITests.swift */; };
8F1488FF2D2DE27000191744 /* NavigationActionProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1488CB2D2DE27000191744 /* NavigationActionProxyAPITests.swift */; };
8F1489012D2DE91C00191744 /* AuthenticationChallengeResponseProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F1489002D2DE91C00191744 /* AuthenticationChallengeResponseProxyAPITests.swift */; };
+ 8F95A6EE2F5765B50071F2C2 /* PlatformViewImplTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F95A6ED2F5765B50071F2C2 /* PlatformViewImplTests.swift */; };
8FEC64852DA2C6DC00C48569 /* GetTrustResultResponseProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FEC64812DA2C6DC00C48569 /* GetTrustResultResponseProxyAPITests.swift */; };
8FEC64862DA2C6DC00C48569 /* WebpagePreferencesProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FEC64842DA2C6DC00C48569 /* WebpagePreferencesProxyAPITests.swift */; };
8FEC64872DA2C6DC00C48569 /* SecCertificateProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FEC64822DA2C6DC00C48569 /* SecCertificateProxyAPITests.swift */; };
@@ -136,6 +137,7 @@
8F1488E12D2DE27000191744 /* WebViewProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebViewProxyAPITests.swift; path = ../../darwin/Tests/WebViewProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8F1489002D2DE91C00191744 /* AuthenticationChallengeResponseProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AuthenticationChallengeResponseProxyAPITests.swift; path = ../../darwin/Tests/AuthenticationChallengeResponseProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8F66D9D72D1362BE000835F9 /* RunnerTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RunnerTests-Bridging-Header.h"; sourceTree = ""; };
+ 8F95A6ED2F5765B50071F2C2 /* PlatformViewImplTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PlatformViewImplTests.swift; path = /Users/bmparr/Development/packages/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift; sourceTree = ""; };
8FEC64812DA2C6DC00C48569 /* GetTrustResultResponseProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GetTrustResultResponseProxyAPITests.swift; path = ../../darwin/Tests/GetTrustResultResponseProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8FEC64822DA2C6DC00C48569 /* SecCertificateProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SecCertificateProxyAPITests.swift; path = ../../darwin/Tests/SecCertificateProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8FEC64832DA2C6DC00C48569 /* SecTrustProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SecTrustProxyAPITests.swift; path = ../../darwin/Tests/SecTrustProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
@@ -185,6 +187,7 @@
68BDCAEA23C3F7CB00D9C032 /* RunnerTests */ = {
isa = PBXGroup;
children = (
+ 8F95A6ED2F5765B50071F2C2 /* PlatformViewImplTests.swift */,
8F0E23512EEB5D6B002AB342 /* ColorProxyAPITests.swift */,
33C8DAD92E8D711500A9B7CA /* TemporaryObjCStub.h */,
33C8DADA2E8D711500A9B7CA /* TemporaryObjCStub.m */,
@@ -505,12 +508,10 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
- "${PODS_CONFIGURATION_BUILD_DIR}/path_provider_foundation/path_provider_foundation_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/webview_flutter_wkwebview/webview_flutter_wkwebview_privacy.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
- "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/path_provider_foundation_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/webview_flutter_wkwebview_privacy.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
@@ -579,6 +580,7 @@
8F1488ED2D2DE27000191744 /* ErrorProxyAPITests.swift in Sources */,
8F1488EE2D2DE27000191744 /* NSObjectProxyAPITests.swift in Sources */,
33C8DADB2E8D711500A9B7CA /* TemporaryObjCStub.m in Sources */,
+ 8F95A6EE2F5765B50071F2C2 /* PlatformViewImplTests.swift in Sources */,
8F1488EF2D2DE27000191744 /* NavigationResponseProxyAPITests.swift in Sources */,
8FEC64852DA2C6DC00C48569 /* GetTrustResultResponseProxyAPITests.swift in Sources */,
8FEC64862DA2C6DC00C48569 /* WebpagePreferencesProxyAPITests.swift in Sources */,
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index ef4558defd55..03bd8e4ad04b 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -44,6 +44,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
Date: Tue, 3 Mar 2026 14:29:16 -0500
Subject: [PATCH 02/15] add test file
---
.../darwin/Tests/PlatformViewImplTests.swift | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
new file mode 100644
index 000000000000..d4148c583428
--- /dev/null
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
@@ -0,0 +1,25 @@
+// Copyright 2013 The Flutter Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import XCTest
+
+@testable import webview_flutter_wkwebview
+
+#if os(iOS)
+ import UIKit
+#endif
+
+class PlatformViewImplTests: XCTestCase {
+ #if os(iOS)
+ func testPlatformViewImplStoresViewWithAWeakReference() {
+ var view: UIView? = UIView()
+ let platformView = PlatformViewImpl(uiView: view!)
+
+ XCTAssertEqual(view, platformView.view())
+
+ view = nil
+ XCTAssertNotEqual(view, platformView.view())
+ }
+ #endif
+}
From ac84885cd612eb5ee3f3433f9ce993486547446c Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 3 Mar 2026 14:35:10 -0500
Subject: [PATCH 03/15] fix test
---
.../darwin/Tests/PlatformViewImplTests.swift | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
index d4148c583428..befbc0355e8a 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import XCTest
+import WebKit
@testable import webview_flutter_wkwebview
@@ -13,13 +14,13 @@ import XCTest
class PlatformViewImplTests: XCTestCase {
#if os(iOS)
func testPlatformViewImplStoresViewWithAWeakReference() {
- var view: UIView? = UIView()
+ var view: WKWebView? = WKWebView()
let platformView = PlatformViewImpl(uiView: view!)
- XCTAssertEqual(view, platformView.view())
+ XCTAssertTrue(platformView.view() is WKWebView)
view = nil
- XCTAssertNotEqual(view, platformView.view())
+ XCTAssertFalse(platformView.view() is WKWebView)
}
#endif
}
From c57fd50a6d1357eaf03bb2798babef636f858449 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 3 Mar 2026 14:52:31 -0500
Subject: [PATCH 04/15] change to uiview
---
.../darwin/Tests/PlatformViewImplTests.swift | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
index befbc0355e8a..3c39ba09563b 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import XCTest
-import WebKit
@testable import webview_flutter_wkwebview
@@ -11,16 +10,17 @@ import WebKit
import UIKit
#endif
+@MainActor
class PlatformViewImplTests: XCTestCase {
#if os(iOS)
- func testPlatformViewImplStoresViewWithAWeakReference() {
- var view: WKWebView? = WKWebView()
+ @MainActor func testPlatformViewImplStoresViewWithAWeakReference() {
+ var view: UIView? = UIView()
let platformView = PlatformViewImpl(uiView: view!)
- XCTAssertTrue(platformView.view() is WKWebView)
+ XCTAssertNotNil(platformView.uiView)
view = nil
- XCTAssertFalse(platformView.view() is WKWebView)
+ XCTAssertNil(platformView.uiView)
}
#endif
}
From 08693ba619c0a27eb73e0eaebcdff9042ea3d9d6 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 3 Mar 2026 15:11:50 -0500
Subject: [PATCH 05/15] remove mainactor
---
.../darwin/Tests/PlatformViewImplTests.swift | 3 +--
.../example/ios/Runner.xcodeproj/project.pbxproj | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
index 3c39ba09563b..be9a9ff1b64e 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
@@ -10,10 +10,9 @@ import XCTest
import UIKit
#endif
-@MainActor
class PlatformViewImplTests: XCTestCase {
#if os(iOS)
- @MainActor func testPlatformViewImplStoresViewWithAWeakReference() {
+ func testPlatformViewImplStoresViewWithAWeakReference() {
var view: UIView? = UIView()
let platformView = PlatformViewImpl(uiView: view!)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
index 30e00333683c..a77e312d92b1 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 60;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
From 43b5209efe4a86ef9f7930d6d052af2325ab13f9 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 3 Mar 2026 15:13:18 -0500
Subject: [PATCH 06/15] fix path to test
---
.../example/ios/Runner.xcodeproj/project.pbxproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
index a77e312d92b1..37b4858d96e5 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj
@@ -137,7 +137,7 @@
8F1488E12D2DE27000191744 /* WebViewProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebViewProxyAPITests.swift; path = ../../darwin/Tests/WebViewProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8F1489002D2DE91C00191744 /* AuthenticationChallengeResponseProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AuthenticationChallengeResponseProxyAPITests.swift; path = ../../darwin/Tests/AuthenticationChallengeResponseProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8F66D9D72D1362BE000835F9 /* RunnerTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RunnerTests-Bridging-Header.h"; sourceTree = ""; };
- 8F95A6ED2F5765B50071F2C2 /* PlatformViewImplTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PlatformViewImplTests.swift; path = /Users/bmparr/Development/packages/packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift; sourceTree = ""; };
+ 8F95A6ED2F5765B50071F2C2 /* PlatformViewImplTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PlatformViewImplTests.swift; path = ../../darwin/Tests/PlatformViewImplTests.swift; sourceTree = SOURCE_ROOT; };
8FEC64812DA2C6DC00C48569 /* GetTrustResultResponseProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GetTrustResultResponseProxyAPITests.swift; path = ../../darwin/Tests/GetTrustResultResponseProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8FEC64822DA2C6DC00C48569 /* SecCertificateProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SecCertificateProxyAPITests.swift; path = ../../darwin/Tests/SecCertificateProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
8FEC64832DA2C6DC00C48569 /* SecTrustProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SecTrustProxyAPITests.swift; path = ../../darwin/Tests/SecTrustProxyAPITests.swift; sourceTree = SOURCE_ROOT; };
From d5b22f05fe33c03300a0a28d55682b4c8cc3611f Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Tue, 3 Mar 2026 15:49:07 -0500
Subject: [PATCH 07/15] unchange unrelated files
---
.../example/ios/Flutter/AppFrameworkInfo.plist | 2 ++
.../ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | 2 --
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist
index 391a902b2beb..1dc6cf7652ba 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist
@@ -20,5 +20,7 @@
????
CFBundleVersion
1.0
+ MinimumOSVersion
+ 13.0
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index 03bd8e4ad04b..ef4558defd55 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -44,7 +44,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
Date: Tue, 10 Mar 2026 16:09:02 -0400
Subject: [PATCH 08/15] add todo
---
.../FlutterViewFactory.swift | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index 2e3db6092eb9..7ad988a2f9c3 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -15,6 +15,12 @@ import Foundation
#if os(iOS)
class PlatformViewImpl: NSObject, FlutterPlatformView {
+ // TODO(bparrishMines): Change to strong reference once this issue is fixed in the engine and
+ // makes it to stable. See https://github.com/flutter/flutter/issues/168535.
+ // The InstanceManager used by pigeon adds an associated object to added instance that make a message call when they
+ // are deallocated. This sets a weak reference to the underlying UIView to prevent a crash where the UIView is no
+ // longer referenced by the plugin, but the FlutterViewController still maintains a reference to it when the
+ // BinaryMessenger becomes invalid.
weak var uiView: UIView?
init(uiView: UIView) {
@@ -22,7 +28,14 @@ import Foundation
}
func view() -> UIView {
- return uiView ?? UIView()
+ if (uiView == nil) {
+ #if DEBUG
+ fatalError("WebViewFlutterPluginError: UIView has be deallocated, but is being accessed.")
+ #else
+ return UIView()
+ #endif
+ }
+ return uiView
}
}
#endif
From 91f4f7dc986f254a2b9cec194eeb47daa9889646 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 11 Mar 2026 12:55:27 -0400
Subject: [PATCH 09/15] add null operator
---
.../Sources/webview_flutter_wkwebview/FlutterViewFactory.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index 7ad988a2f9c3..53a706267e56 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -35,7 +35,7 @@ import Foundation
return UIView()
#endif
}
- return uiView
+ return uiView!
}
}
#endif
From 1c5231ed08a7cc9afa8f41925b564e93d371c732 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 11 Mar 2026 17:02:00 -0400
Subject: [PATCH 10/15] formatting
---
.../webview_flutter_wkwebview/FlutterViewFactory.swift | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index 53a706267e56..e6aaaf3c2c36 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -28,11 +28,11 @@ import Foundation
}
func view() -> UIView {
- if (uiView == nil) {
+ if uiView == nil {
#if DEBUG
- fatalError("WebViewFlutterPluginError: UIView has be deallocated, but is being accessed.")
+ fatalError("WebViewFlutterPluginError: UIView has be deallocated, but is being accessed.")
#else
- return UIView()
+ return UIView()
#endif
}
return uiView!
From 191736f8a4901136b68eb78e6eadad2d9002e0a4 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 11 Mar 2026 17:06:04 -0400
Subject: [PATCH 11/15] error message
---
.../webview_flutter_wkwebview/FlutterViewFactory.swift | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index e6aaaf3c2c36..8db94b04f46f 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -15,6 +15,9 @@ import Foundation
#if os(iOS)
class PlatformViewImpl: NSObject, FlutterPlatformView {
+ static let nullUIViewErrorMessage: String =
+ "WebViewFlutterPluginError: UIView has been deallocated, but is still being requested as a PlatformView."
+
// TODO(bparrishMines): Change to strong reference once this issue is fixed in the engine and
// makes it to stable. See https://github.com/flutter/flutter/issues/168535.
// The InstanceManager used by pigeon adds an associated object to added instance that make a message call when they
@@ -30,8 +33,9 @@ import Foundation
func view() -> UIView {
if uiView == nil {
#if DEBUG
- fatalError("WebViewFlutterPluginError: UIView has be deallocated, but is being accessed.")
+ fatalError(nullUIViewErrorMessage)
#else
+ NSLog(nullUIViewErrorMessage)
return UIView()
#endif
}
From d0a4f69b10e4462524d1af742c092fc7e9f1e865 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Wed, 11 Mar 2026 17:28:13 -0400
Subject: [PATCH 12/15] fix static reference
---
.../webview_flutter_wkwebview/FlutterViewFactory.swift | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index 8db94b04f46f..e384f4e97753 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -33,9 +33,9 @@ import Foundation
func view() -> UIView {
if uiView == nil {
#if DEBUG
- fatalError(nullUIViewErrorMessage)
+ fatalError(PlatformViewImpl.nullUIViewErrorMessage)
#else
- NSLog(nullUIViewErrorMessage)
+ NSLog(PlatformViewImpl.nullUIViewErrorMessage)
return UIView()
#endif
}
From b1f7e6a310e24afe090203523313b2d3e941ccb3 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Thu, 12 Mar 2026 14:30:06 -0400
Subject: [PATCH 13/15] only log
---
.../FlutterViewFactory.swift | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index e384f4e97753..ed968dadf396 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -15,9 +15,6 @@ import Foundation
#if os(iOS)
class PlatformViewImpl: NSObject, FlutterPlatformView {
- static let nullUIViewErrorMessage: String =
- "WebViewFlutterPluginError: UIView has been deallocated, but is still being requested as a PlatformView."
-
// TODO(bparrishMines): Change to strong reference once this issue is fixed in the engine and
// makes it to stable. See https://github.com/flutter/flutter/issues/168535.
// The InstanceManager used by pigeon adds an associated object to added instance that make a message call when they
@@ -31,15 +28,14 @@ import Foundation
}
func view() -> UIView {
- if uiView == nil {
- #if DEBUG
- fatalError(PlatformViewImpl.nullUIViewErrorMessage)
- #else
- NSLog(PlatformViewImpl.nullUIViewErrorMessage)
- return UIView()
- #endif
+ if let uiView = uiView {
+ return uiView
}
- return uiView!
+
+ NSLog(
+ "WebViewFlutterPluginError: UIView has been deallocated, but is still being requested as a PlatformView."
+ )
+ return UIView()
}
}
#endif
From b56e87f0e2066acd25f41d196e4185c994d82039 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Thu, 12 Mar 2026 14:45:18 -0400
Subject: [PATCH 14/15] improve todo comment
---
.../webview_flutter_wkwebview/FlutterViewFactory.swift | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
index ed968dadf396..25192bab974d 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
+++ b/packages/webview_flutter/webview_flutter_wkwebview/darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/FlutterViewFactory.swift
@@ -17,10 +17,10 @@ import Foundation
class PlatformViewImpl: NSObject, FlutterPlatformView {
// TODO(bparrishMines): Change to strong reference once this issue is fixed in the engine and
// makes it to stable. See https://github.com/flutter/flutter/issues/168535.
- // The InstanceManager used by pigeon adds an associated object to added instance that make a message call when they
- // are deallocated. This sets a weak reference to the underlying UIView to prevent a crash where the UIView is no
- // longer referenced by the plugin, but the FlutterViewController still maintains a reference to it when the
- // BinaryMessenger becomes invalid.
+ // The InstanceManager used by pigeon adds an associated object to added instances that makes a message call when
+ // they are deallocated. This sets a weak reference to the underlying UIView to prevent a crash where the UIView is
+ // no longer referenced by the plugin, but the FlutterViewController still maintains a transitive reference to it
+ // when the BinaryMessenger becomes invalid.
weak var uiView: UIView?
init(uiView: UIView) {
From d2eef783363b61084eaece9f3e00043bd15bf177 Mon Sep 17 00:00:00 2001
From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com>
Date: Thu, 12 Mar 2026 14:47:12 -0400
Subject: [PATCH 15/15] better changelog
---
.../webview_flutter/webview_flutter_wkwebview/CHANGELOG.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
index 2970a5d0898f..5a4511008367 100644
--- a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
+++ b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
@@ -1,6 +1,7 @@
## 3.24.1
-* Updates platform views on iOS to only have a weak reference to the native view.
+* Updates platform views on iOS to only have a weak reference to the native view. This is a
+ potential workaround to prevent a crash during the Flutter engine shutdown. See https://github.com/flutter/flutter/issues/168535
## 3.24.0