Skip to content
Permalink
Browse files
Frequent crash under -[WKPDFView web_setMinimumSize:]_block_invoke
https://bugs.webkit.org/show_bug.cgi?id=152266
<rdar://problem/22092676>

Reviewed by Simon Fraser.

Source/WebKit2:

* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView web_setMinimumSize:]):
We weren't retaining the UIScrollView, but depending on it surviving
into this block's invocation.

We don't need to do this asynchronously anymore because the referenced
bug is fixed, so make it happen synchronously. This also fixes the crash
because there's no opportunity for the scroll view to be released.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/WKPDFViewResizeCrash.mm: Added.
Add a test that crashed before this change, and doesn't crash after.


Canonical link: https://commits.webkit.org/170381@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194060 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Dec 14, 2015
1 parent b1c4e0b commit fd2dd96250375b5014b7040b020ecec95fa5618f
@@ -1,3 +1,20 @@
2015-12-14 Tim Horton <timothy_horton@apple.com>

Frequent crash under -[WKPDFView web_setMinimumSize:]_block_invoke
https://bugs.webkit.org/show_bug.cgi?id=152266
<rdar://problem/22092676>

Reviewed by Simon Fraser.

* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView web_setMinimumSize:]):
We weren't retaining the UIScrollView, but depending on it surviving
into this block's invocation.

We don't need to do this asynchronously anymore because the referenced
bug is fixed, so make it happen synchronously. This also fixes the crash
because there's no opportunity for the scroll view to be released.

2015-12-14 Tim Horton <timothy_horton@apple.com>

TiledCoreAnimationDrawingAreaProxy::createFenceForGeometryUpdate() sets fence port on context twice
@@ -219,16 +219,11 @@ - (void)web_setMinimumSize:(CGSize)size

[self _computePageAndDocumentFrames];

// FIXME: This dispatch_async is unnecessary except to work around rdar://problem/15035620.
// Once that is resolved, we should do the setContentOffset without the dispatch_async.
RetainPtr<WKPDFView> retainedSelf = self;
dispatch_async(dispatch_get_main_queue(), [retainedSelf, oldDocumentLeftFraction, oldDocumentTopFraction] {
CGSize contentSize = retainedSelf->_scrollView.contentSize;
UIEdgeInsets contentInset = retainedSelf->_scrollView.contentInset;
[retainedSelf->_scrollView setContentOffset:CGPointMake((oldDocumentLeftFraction * contentSize.width) - contentInset.left, (oldDocumentTopFraction * contentSize.height) - contentInset.top) animated:NO];
CGSize newContentSize = _scrollView.contentSize;
UIEdgeInsets contentInset = _scrollView.contentInset;
[_scrollView setContentOffset:CGPointMake((oldDocumentLeftFraction * newContentSize.width) - contentInset.left, (oldDocumentTopFraction * newContentSize.height) - contentInset.top) animated:NO];

[retainedSelf _revalidateViews];
});
[self _revalidateViews];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
@@ -1,3 +1,15 @@
2015-12-14 Tim Horton <timothy_horton@apple.com>

Frequent crash under -[WKPDFView web_setMinimumSize:]_block_invoke
https://bugs.webkit.org/show_bug.cgi?id=152266
<rdar://problem/22092676>

Reviewed by Simon Fraser.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/WKPDFViewResizeCrash.mm: Added.
Add a test that crashed before this change, and doesn't crash after.

2015-12-14 Chris Fleizach <cfleizach@apple.com>

AX: iOS: Text field variations do not have the correct traits
@@ -35,6 +35,7 @@
290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 290A9BB81735F42300D71BBC /* OpenNewWindow.html */; };
290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */; };
297234B7173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 297234B5173AFAC700983601 /* CustomProtocolsInvalidScheme_Bundle.cpp */; };
2D00065F1C1F589A0088E6A7 /* WKPDFViewResizeCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */; };
2D1FE0B01AD465C1006CD9E6 /* FixedLayoutSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */; };
2D8104CC1BEC13E70020DA46 /* FindInPage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D8104CB1BEC13E70020DA46 /* FindInPage.mm */; };
2D9A53AF1B31FA8D0074D5AA /* ShrinkToFit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */; };
@@ -518,6 +519,7 @@
29AB8A9F164C735800D49BEC /* CustomProtocolsTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CustomProtocolsTest.mm; path = WebKit2ObjC/CustomProtocolsTest.mm; sourceTree = "<group>"; };
29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestBrowsingContextLoadDelegate.mm; sourceTree = "<group>"; };
29AB8AA3164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestBrowsingContextLoadDelegate.h; sourceTree = "<group>"; };
2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPDFViewResizeCrash.mm; sourceTree = "<group>"; };
2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FixedLayoutSize.mm; sourceTree = "<group>"; };
2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollPinningBehaviors.cpp; sourceTree = "<group>"; };
2D8104CB1BEC13E70020DA46 /* FindInPage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindInPage.mm; sourceTree = "<group>"; };
@@ -946,6 +948,7 @@
37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */,
2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */,
7CC3E1FA197E234100BE6252 /* UserContentController.mm */,
2D00065D1C1F58940088E6A7 /* WKPDFViewResizeCrash.mm */,
0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */,
);
name = "WebKit2 Cocoa";
@@ -1727,6 +1730,7 @@
7CCE7F0F1A411AE600447C4C /* ResizeWindowAfterCrash.cpp in Sources */,
7CCE7F101A411AE600447C4C /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */,
7CCE7F111A411AE600447C4C /* RestoreSessionStateContainingFormData.cpp in Sources */,
2D00065F1C1F589A0088E6A7 /* WKPDFViewResizeCrash.mm in Sources */,
7CCE7F4E1A411BA400447C4C /* RetainPtr.cpp in Sources */,
7CCE7F4D1A411B9F00447C4C /* RetainPtr.mm in Sources */,
7CCE7F4F1A411BA400447C4C /* RetainPtrHashing.cpp in Sources */,
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2015 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.
*/

#include "config.h"

#import <WebKit/WKNavigationDelegate.h>
#import <WebKit/WKWebView.h>
#import <wtf/RetainPtr.h>
#import "PlatformUtilities.h"
#import "Test.h"

#if WK_API_ENABLED

static bool finishedLoading;
static bool finishedDispatch;

@interface WKPDFViewResizeNavigationDelegate : NSObject <WKNavigationDelegate>
@end

@implementation WKPDFViewResizeNavigationDelegate

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
finishedLoading = true;
}

@end

TEST(WebKit2, WKPDFViewResizeCrash)
{
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);

RetainPtr<WKPDFViewResizeNavigationDelegate> delegate = adoptNS([[WKPDFViewResizeNavigationDelegate alloc] init]);
[webView setNavigationDelegate:delegate.get()];

NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"]];
[webView loadRequest:request];

TestWebKitAPI::Util::run(&finishedLoading);

[webView setFrame:NSMakeRect(0, 0, 100, 100)];
webView = nil;

dispatch_async(dispatch_get_main_queue(), ^{
finishedDispatch = true;
});

TestWebKitAPI::Util::run(&finishedDispatch);
}

#endif

0 comments on commit fd2dd96

Please sign in to comment.