-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[webview_flutter_wkwebview] Updates platform views on iOS to only have a weak reference to the native view #11175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d392d10
create fix
bparrishMines 8467c79
add test file
bparrishMines ac84885
fix test
bparrishMines c57fd50
change to uiview
bparrishMines 08693ba
remove mainactor
bparrishMines 43b5209
fix path to test
bparrishMines d5b22f0
unchange unrelated files
bparrishMines 0ab299a
add todo
bparrishMines e00629e
Merge branch 'main' of github.com:flutter/packages into wkwebview_pv
bparrishMines 91f4f7d
add null operator
bparrishMines 74e7298
Merge branch 'main' of github.com:flutter/packages into wkwebview_pv
bparrishMines 1b28b14
Merge branch 'main' of github.com:flutter/packages into wkwebview_pv
bparrishMines 1c5231e
formatting
bparrishMines 191736f
error message
bparrishMines d0a4f69
fix static reference
bparrishMines b1f7e6a
only log
bparrishMines fc3f4d5
Merge branch 'main' of github.com:flutter/packages into wkwebview_pv
bparrishMines b56e87f
improve todo comment
bparrishMines d2eef78
better changelog
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/PlatformViewImplTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning a new, empty
UIViewwhenuiViewisnilcould 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 afatalError. This will help catch incorrect usage during development and provide a clear error message.