Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
Original file line number Diff line number Diff line change
@@ -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!)

XCTAssertNotNil(platformView.uiView)

view = nil
XCTAssertNil(platformView.uiView)
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Comment on lines +24 to 26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Returning a new, empty UIView when uiView is nil could lead to subtle bugs and unexpected behavior. For instance, the Flutter engine might add this empty view to the view hierarchy, resulting in a blank space where the webview should be, without any clear error indicating what went wrong.

Given the assumption that view() should not be called after the underlying native view is deallocated, it would be more robust to enforce this with a fatalError. This will help catch incorrect usage during development and provide a clear error message.

    func view() -> UIView {
      guard let uiView = uiView else {
        fatalError("The platform view is being accessed after it has been released.")
      }
      return 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
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 60;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
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; };
Expand Down Expand Up @@ -185,6 +187,7 @@
68BDCAEA23C3F7CB00D9C032 /* RunnerTests */ = {
isa = PBXGroup;
children = (
8F95A6ED2F5765B50071F2C2 /* PlatformViewImplTests.swift */,
8F0E23512EEB5D6B002AB342 /* ColorProxyAPITests.swift */,
33C8DAD92E8D711500A9B7CA /* TemporaryObjCStub.h */,
33C8DADA2E8D711500A9B7CA /* TemporaryObjCStub.m */,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview
description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 3.23.8
version: 3.23.9

environment:
sdk: ^3.9.0
Expand Down
Loading