Diff
Modified: branches/safari-614.1.5-branch/Source/WebKit/ChangeLog (290482 => 290483)
--- branches/safari-614.1.5-branch/Source/WebKit/ChangeLog 2022-02-25 01:44:44 UTC (rev 290482)
+++ branches/safari-614.1.5-branch/Source/WebKit/ChangeLog 2022-02-25 01:46:54 UTC (rev 290483)
@@ -1,3 +1,57 @@
+2022-02-24 Russell Epstein <repst...@apple.com>
+
+ Cherry-pick r290442. rdar://problem/89345853
+
+ [MacCatalyst] REGRESSION(r290091): sometimes can crash if `WKWebView` is deallocated before the next visible content rect update
+ https://bugs.webkit.org/show_bug.cgi?id=237126
+ <rdar://problem/89345853>
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ Tests: WKWebViewResize.DoesNotAssertInDeallocAfterChangingFrame
+ WKWebViewResize.DoesNotAssertInDeallocAfterChangingBounds
+
+ * UIProcess/API/ios/WKWebViewIOS.h:
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView _acquireResizeAssertionForReason:]):
+ (-[WKWebView _invalidateResizeAssertions]): Added.
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView dealloc]):
+ Make sure to `-invalidate` any remaining assertions in `-dealloc` as required by `_UIInvalidatable`.
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewResize.mm: Added.
+ (TEST.WKWebViewResize.DoesNotAssertInDeallocAfterChangingFrame):
+ (TEST.WKWebViewResize.DoesNotAssertInDeallocAfterChangingBounds):
+
+ * TestWebKitAPI/SourcesCocoa.txt:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290442 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-02-24 Devin Rousso <drou...@apple.com>
+
+ [MacCatalyst] REGRESSION(r290091): sometimes can crash if `WKWebView` is deallocated before the next visible content rect update
+ https://bugs.webkit.org/show_bug.cgi?id=237126
+ <rdar://problem/89345853>
+
+ Reviewed by Tim Horton.
+
+ Tests: WKWebViewResize.DoesNotAssertInDeallocAfterChangingFrame
+ WKWebViewResize.DoesNotAssertInDeallocAfterChangingBounds
+
+ * UIProcess/API/ios/WKWebViewIOS.h:
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView _acquireResizeAssertionForReason:]):
+ (-[WKWebView _invalidateResizeAssertions]): Added.
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView dealloc]):
+ Make sure to `-invalidate` any remaining assertions in `-dealloc` as required by `_UIInvalidatable`.
+
2022-02-22 Alan Coon <alanc...@apple.com>
Cherry-pick r290317. rdar://problem/89206950
Modified: branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (290482 => 290483)
--- branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2022-02-25 01:44:44 UTC (rev 290482)
+++ branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2022-02-25 01:46:54 UTC (rev 290483)
@@ -649,6 +649,10 @@
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), (__bridge CFStringRef)notificationName.get(), nullptr);
#endif
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+ [self _invalidateResizeAssertions];
+#endif
+
[super dealloc];
}
Modified: branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h (290482 => 290483)
--- branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h 2022-02-25 01:44:44 UTC (rev 290482)
+++ branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h 2022-02-25 01:46:54 UTC (rev 290483)
@@ -49,6 +49,10 @@
- (void)_accessibilitySettingsDidChange:(NSNotification *)notification;
- (void)_frameOrBoundsChanged;
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+- (void)_invalidateResizeAssertions;
+#endif
+
- (BOOL)usesStandardContentView;
- (void)_processDidExit;
Modified: branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (290482 => 290483)
--- branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-02-25 01:44:44 UTC (rev 290482)
+++ branches/safari-614.1.5-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-02-25 01:46:54 UTC (rev 290483)
@@ -2013,14 +2013,19 @@
if (!strongSelf)
return;
- for (auto resizeAssertion : std::exchange(strongSelf->_resizeAssertions, { }))
- [resizeAssertion _invalidate];
+ [strongSelf _invalidateResizeAssertions];
}).get()];
}
- _resizeAssertions.append(adoptNS([windowScene _holdLiveResizeSnapshotForReason:reason]));
+ _resizeAssertions.append(retainPtr([windowScene _holdLiveResizeSnapshotForReason:reason]));
}
+- (void)_invalidateResizeAssertions
+{
+ for (auto resizeAssertion : std::exchange(_resizeAssertions, { }))
+ [resizeAssertion _invalidate];
+}
+
#endif // HAVE(MAC_CATALYST_LIVE_RESIZE)
// Unobscured content rect where the user can interact. When the keyboard is up, this should be the area above or below the keyboard, wherever there is enough space.
Modified: branches/safari-614.1.5-branch/Tools/ChangeLog (290482 => 290483)
--- branches/safari-614.1.5-branch/Tools/ChangeLog 2022-02-25 01:44:44 UTC (rev 290482)
+++ branches/safari-614.1.5-branch/Tools/ChangeLog 2022-02-25 01:46:54 UTC (rev 290483)
@@ -1,3 +1,53 @@
+2022-02-24 Russell Epstein <repst...@apple.com>
+
+ Cherry-pick r290442. rdar://problem/89345853
+
+ [MacCatalyst] REGRESSION(r290091): sometimes can crash if `WKWebView` is deallocated before the next visible content rect update
+ https://bugs.webkit.org/show_bug.cgi?id=237126
+ <rdar://problem/89345853>
+
+ Reviewed by Tim Horton.
+
+ Source/WebKit:
+
+ Tests: WKWebViewResize.DoesNotAssertInDeallocAfterChangingFrame
+ WKWebViewResize.DoesNotAssertInDeallocAfterChangingBounds
+
+ * UIProcess/API/ios/WKWebViewIOS.h:
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView _acquireResizeAssertionForReason:]):
+ (-[WKWebView _invalidateResizeAssertions]): Added.
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView dealloc]):
+ Make sure to `-invalidate` any remaining assertions in `-dealloc` as required by `_UIInvalidatable`.
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewResize.mm: Added.
+ (TEST.WKWebViewResize.DoesNotAssertInDeallocAfterChangingFrame):
+ (TEST.WKWebViewResize.DoesNotAssertInDeallocAfterChangingBounds):
+
+ * TestWebKitAPI/SourcesCocoa.txt:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290442 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-02-24 Devin Rousso <drou...@apple.com>
+
+ [MacCatalyst] REGRESSION(r290091): sometimes can crash if `WKWebView` is deallocated before the next visible content rect update
+ https://bugs.webkit.org/show_bug.cgi?id=237126
+ <rdar://problem/89345853>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewResize.mm: Added.
+ (TEST.WKWebViewResize.DoesNotAssertInDeallocAfterChangingFrame):
+ (TEST.WKWebViewResize.DoesNotAssertInDeallocAfterChangingBounds):
+
+ * TestWebKitAPI/SourcesCocoa.txt:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
2022-02-19 Sihui Liu <sihui_...@apple.com>
Set custom general storage directory for custom WebsiteDataStore in TestController
Modified: branches/safari-614.1.5-branch/Tools/TestWebKitAPI/SourcesCocoa.txt (290482 => 290483)
--- branches/safari-614.1.5-branch/Tools/TestWebKitAPI/SourcesCocoa.txt 2022-02-25 01:44:44 UTC (rev 290482)
+++ branches/safari-614.1.5-branch/Tools/TestWebKitAPI/SourcesCocoa.txt 2022-02-25 01:46:54 UTC (rev 290483)
@@ -286,6 +286,7 @@
Tests/WebKitCocoa/WKWebViewGetContents.mm
Tests/WebKitCocoa/WKWebViewLoadAPIs.mm
Tests/WebKitCocoa/WKWebViewPrintFormatter.mm
+Tests/WebKitCocoa/WKWebViewResize.mm
Tests/WebKitCocoa/WKWebViewServerTrustKVC.mm
Tests/WebKitCocoa/WKWebViewSnapshot.mm
Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm
Modified: branches/safari-614.1.5-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (290482 => 290483)
--- branches/safari-614.1.5-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-02-25 01:44:44 UTC (rev 290482)
+++ branches/safari-614.1.5-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2022-02-25 01:46:54 UTC (rev 290483)
@@ -2582,6 +2582,7 @@
952F7166270BD99700D00DCC /* CSSViewportUnits.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = CSSViewportUnits.html; sourceTree = "<group>"; };
952F7166270BD99700D00DCD /* CSSViewportUnits.svg */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = CSSViewportUnits.svg; sourceTree = "<group>"; };
953ABB3425C0D681004C8B73 /* WKWebViewUnderPageBackgroundColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewUnderPageBackgroundColor.mm; sourceTree = "<group>"; };
+ 953DF77B27C6DE5D00FDF3A5 /* WKWebViewResize.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewResize.mm; sourceTree = "<group>"; };
958B70E026C46EDC00B2022B /* NSAttributedStringWebKitAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NSAttributedStringWebKitAdditions.mm; sourceTree = "<group>"; };
95A524942581A10D00461FE9 /* WKWebViewThemeColor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewThemeColor.mm; sourceTree = "<group>"; };
95B6B3B6251EBF2F00FC4382 /* MediaDocument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaDocument.mm; sourceTree = "<group>"; };
@@ -3715,6 +3716,7 @@
D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */,
7A42ABD625CCD0F500980BCA /* WKWebViewLoadAPIs.mm */,
2D01D06D23218FEE0039AA3A /* WKWebViewPrintFormatter.mm */,
+ 953DF77B27C6DE5D00FDF3A5 /* WKWebViewResize.mm */,
37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */,
93F56DA81E5F9181003EDE84 /* WKWebViewSnapshot.mm */,
CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */,
Added: branches/safari-614.1.5-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewResize.mm (0 => 290483)
--- branches/safari-614.1.5-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewResize.mm (rev 0)
+++ branches/safari-614.1.5-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewResize.mm 2022-02-25 01:46:54 UTC (rev 290483)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "TestCocoa.h"
+#import "TestWKWebView.h"
+#import <wtf/RetainPtr.h>
+
+#if HAVE(MAC_CATALYST_LIVE_RESIZE)
+
+TEST(WKWebViewResize, DoesNotAssertInDeallocAfterChangingFrame)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+ [webView setFrame:NSMakeRect(0, 0, 400, 300)];
+
+ bool didThrow = false;
+ @try {
+ webView = nil;
+ } @catch (NSException *exception) {
+ didThrow = true;
+ }
+ EXPECT_FALSE(didThrow);
+}
+
+TEST(WKWebViewResize, DoesNotAssertInDeallocAfterChangingBounds)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+ [webView setBounds:NSMakeRect(0, 0, 400, 300)];
+
+ bool didThrow = false;
+ @try {
+ webView = nil;
+ } @catch (NSException *exception) {
+ didThrow = true;
+ }
+ EXPECT_FALSE(didThrow);
+}
+
+#endif // HAVE(MAC_CATALYST_LIVE_RESIZE)