CRASH at WebKit: WebKit::WebFullScreenManagerProxy::saveScrollPosition
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2018 23:29:57 +0000 (23:29 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2018 23:29:57 +0000 (23:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187769
<rdar://problem/42160666>

Reviewed by Tim Horton.

Null-check all uses of _page and _manager in WKFullScreenWindowControllerIOS.

* UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
(WebKit::WKWebViewState::applyTo):
(WebKit::WKWebViewState::store):
(-[WKFullScreenWindowController enterFullScreen]):
(-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]):
(-[WKFullScreenWindowController _completedExitFullScreen]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233940 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm

index 7b61da9..b9ae83c 100644 (file)
@@ -1,3 +1,20 @@
+2018-07-18  Jer Noble  <jer.noble@apple.com>
+
+        CRASH at WebKit: WebKit::WebFullScreenManagerProxy::saveScrollPosition
+        https://bugs.webkit.org/show_bug.cgi?id=187769
+        <rdar://problem/42160666>
+
+        Reviewed by Tim Horton.
+
+        Null-check all uses of _page and _manager in WKFullScreenWindowControllerIOS.
+
+        * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
+        (WebKit::WKWebViewState::applyTo):
+        (WebKit::WKWebViewState::store):
+        (-[WKFullScreenWindowController enterFullScreen]):
+        (-[WKFullScreenWindowController beganExitFullScreenWithInitialFrame:finalFrame:]):
+        (-[WKFullScreenWindowController _completedExitFullScreen]):
+
 2018-07-18  Chris Dumez  <cdumez@apple.com>
 
         WebContent crash in WebProcess::ensureNetworkProcessConnection
index 51d0a5a..8e87aff 100644 (file)
@@ -115,8 +115,10 @@ struct WKWebViewState {
         [[webView scrollView] setContentInset:_savedEdgeInset];
         [[webView scrollView] setContentOffset:_savedContentOffset];
         [[webView scrollView] setScrollIndicatorInsets:_savedScrollIndicatorInsets];
-        [webView _page]->setTopContentInset(_savedTopContentInset);
-        [webView _page]->setForceAlwaysUserScalable(_savedForceAlwaysUserScalable);
+        if (auto* page = webView._page) {
+            page->setTopContentInset(_savedTopContentInset);
+            page->setForceAlwaysUserScalable(_savedForceAlwaysUserScalable);
+        }
         [webView _setViewScale:_savedViewScale];
         [[webView scrollView] setZoomScale:_savedZoomScale];
         webView.scrollView.minimumZoomScale = _savedMinimumZoomScale;
@@ -131,8 +133,10 @@ struct WKWebViewState {
         _savedEdgeInset = [[webView scrollView] contentInset];
         _savedContentOffset = [[webView scrollView] contentOffset];
         _savedScrollIndicatorInsets = [[webView scrollView] scrollIndicatorInsets];
-        _savedTopContentInset = [webView _page]->topContentInset();
-        _savedForceAlwaysUserScalable = [webView _page]->forceAlwaysUserScalable();
+        if (auto* page = webView._page) {
+            _savedTopContentInset = page->topContentInset();
+            _savedForceAlwaysUserScalable = page->forceAlwaysUserScalable();
+        }
         _savedViewScale = [webView _viewScale];
         _savedZoomScale = [[webView scrollView] zoomScale];
         _savedMinimumZoomScale = webView.scrollView.minimumZoomScale;
@@ -488,6 +492,12 @@ static const NSTimeInterval kAnimationDuration = 0.2;
     if ([self isFullScreen])
         return;
 
+    RetainPtr<WKWebView> webView = self._webView;
+    auto* page = [webView _page];
+    auto* manager = self._manager;
+    if (!page || !manager)
+        return;
+
     [self _invalidateEVOrganizationName];
 
     _fullScreenState = WaitingToEnterFullScreen;
@@ -506,8 +516,6 @@ static const NSTimeInterval kAnimationDuration = 0.2;
 
     _window.get().rootViewController = _rootViewController.get();
 
-    RetainPtr<WKWebView> webView = self._webView;
-
     _fullscreenViewController = adoptNS([[WKFullScreenViewController alloc] initWithWebView:webView.get()]);
     [_fullscreenViewController setModalPresentationStyle:UIModalPresentationCustom];
     [_fullscreenViewController setTransitioningDelegate:self];
@@ -534,9 +542,9 @@ static const NSTimeInterval kAnimationDuration = 0.2;
     [_interactivePinchDismissGestureRecognizer setCancelsTouchesInView:NO];
     [_fullscreenViewController.get().view addGestureRecognizer:_interactivePinchDismissGestureRecognizer.get()];
 
-    [self _manager]->saveScrollPosition();
+    manager->saveScrollPosition();
 
-    [webView _page]->setSuppressVisibilityUpdates(true);
+    page->setSuppressVisibilityUpdates(true);
 
     _viewState.store(webView.get());
 
@@ -547,7 +555,8 @@ static const NSTimeInterval kAnimationDuration = 0.2;
     WKSnapshotConfiguration* config = nil;
     [webView takeSnapshotWithConfiguration:config completionHandler:^(UIImage * snapshotImage, NSError * error) {
         RetainPtr<WKWebView> webView = self._webView;
-        if (![webView _page])
+        auto* page = [self._webView _page];
+        if (!page)
             return;
 
         [CATransaction begin];
@@ -565,14 +574,15 @@ static const NSTimeInterval kAnimationDuration = 0.2;
         [webView setNeedsLayout];
         [webView layoutIfNeeded];
         
-        [self _manager]->setAnimatingFullScreen(true);
+        if (auto* manager = self._manager)
+            manager->setAnimatingFullScreen(true);
 
         ViewportArguments arguments { ViewportArguments::CSSDeviceAdaptation };
         arguments.zoom = 1;
         arguments.minZoom = 1;
         arguments.maxZoom = 1;
         arguments.userZoom = 1;
-        [webView _page]->setOverrideViewportArguments(arguments);
+        page->setOverrideViewportArguments(arguments);
 
         _repaintCallback = VoidCallback::create([protectedSelf = retainPtr(self), self](WebKit::CallbackBase::Error) {
             _repaintCallback = nullptr;
@@ -584,7 +594,7 @@ static const NSTimeInterval kAnimationDuration = 0.2;
             ASSERT_NOT_REACHED();
             [self _exitFullscreenImmediately];
         });
-        [webView _page]->forceRepaint(_repaintCallback.copyRef());
+        page->forceRepaint(_repaintCallback.copyRef());
 
         [CATransaction commit];
     }];
@@ -674,7 +684,8 @@ static const NSTimeInterval kAnimationDuration = 0.2;
     _finalFrame.size = sizeExpandedToSize(_finalFrame.size, CGSizeMake(1, 1));
     _finalFrame = safeInlineRect(_finalFrame, [_rootViewController view].frame.size);
 
-    [self._webView _page]->setSuppressVisibilityUpdates(true);
+    if (auto* page = [self._webView _page])
+        page->setSuppressVisibilityUpdates(true);
 
     [_fullscreenViewController setPrefersStatusBarHidden:NO];
 
@@ -705,7 +716,8 @@ static const NSTimeInterval kAnimationDuration = 0.2;
     [webView becomeFirstResponder];
 
     _viewState.applyTo(webView.get());
-    [webView _page]->setOverrideViewportArguments(std::nullopt);
+    if (auto* page = [webView _page])
+        page->setOverrideViewportArguments(std::nullopt);
 
     [webView setNeedsLayout];
     [webView layoutIfNeeded];