Title: [169326] trunk/Source/WebKit2
Revision
169326
Author
[email protected]
Date
2014-05-25 17:04:43 -0700 (Sun, 25 May 2014)

Log Message

[iOS][WK2] Fix some state reset on crash on the WKWebView
https://bugs.webkit.org/show_bug.cgi?id=133039

Reviewed by Sam Weinig.

This is in no way complete, but this should reduce the undefined states on crash.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _processDidExit]):
If the view is animating, nuke the resize animation. That should be invisible to the user
because the background color is reset to white below.

Reset the contentView frame and scrollview state.

Reset the runtime states. We do not strictly need to reset _needsResetViewStateAfterCommitLoadForMainFrame,
_delayUpdateVisibleContentRects and _hadDelayedUpdateVisibleContentRects but it seems better to have
a clean slate.

(-[WKWebView _beginAnimatedResizeWithUpdates:]):
(-[WKWebView _endAnimatedResize]):
We could have crashes during rotation. To simplify the reset code, the animated resize code
no longer change any state when WKWebView is using a custom content view.

* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::processDidExit):
Send a _processDidExit on the WKWebView too.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (169325 => 169326)


--- trunk/Source/WebKit2/ChangeLog	2014-05-25 22:30:25 UTC (rev 169325)
+++ trunk/Source/WebKit2/ChangeLog	2014-05-26 00:04:43 UTC (rev 169326)
@@ -1,3 +1,33 @@
+2014-05-25  Benjamin Poulain  <[email protected]>
+
+        [iOS][WK2] Fix some state reset on crash on the WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=133039
+
+        Reviewed by Sam Weinig.
+
+        This is in no way complete, but this should reduce the undefined states on crash.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _processDidExit]):
+        If the view is animating, nuke the resize animation. That should be invisible to the user
+        because the background color is reset to white below.
+
+        Reset the contentView frame and scrollview state.
+
+        Reset the runtime states. We do not strictly need to reset _needsResetViewStateAfterCommitLoadForMainFrame,
+        _delayUpdateVisibleContentRects and _hadDelayedUpdateVisibleContentRects but it seems better to have
+        a clean slate.
+
+        (-[WKWebView _beginAnimatedResizeWithUpdates:]):
+        (-[WKWebView _endAnimatedResize]):
+        We could have crashes during rotation. To simplify the reset code, the animated resize code
+        no longer change any state when WKWebView is using a custom content view.
+
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::processDidExit):
+        Send a _processDidExit on the WKWebView too.
+
 2014-05-25  Anders Carlsson  <[email protected]>
 
         Use the right paths for website data

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (169325 => 169326)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-05-25 22:30:25 UTC (rev 169325)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-05-26 00:04:43 UTC (rev 169326)
@@ -554,6 +554,29 @@
     return _usesMinimalUI;
 }
 
+- (void)_processDidExit
+{
+    if (!_customContentView && _isAnimatingResize) {
+        NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()];
+        [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView];
+        [_resizeAnimationView removeFromSuperview];
+        _resizeAnimationView = nil;
+
+        _isAnimatingResize = NO;
+        _resizeAnimationTransformAdjustments = CATransform3DIdentity;
+    }
+    [_contentView setFrame:self.bounds];
+    [_scrollView setBackgroundColor:[UIColor whiteColor]];
+    [_scrollView setContentOffset:CGPointMake(-_obscuredInsets.left, -_obscuredInsets.top)];
+    [_scrollView setZoomScale:1];
+
+    _viewportMetaTagWidth = -1;
+    _needsResetViewStateAfterCommitLoadForMainFrame = NO;
+    _scrollViewBackgroundColor = WebCore::Color();
+    _delayUpdateVisibleContentRects = NO;
+    _hadDelayedUpdateVisibleContentRects = NO;
+}
+
 - (void)_didCommitLoadForMainFrame
 {
     _needsResetViewStateAfterCommitLoadForMainFrame = YES;
@@ -1662,6 +1685,12 @@
 - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock
 {
     _isAnimatingResize = YES;
+
+    if (_customContentView) {
+        updateBlock();
+        return;
+    }
+
     _resizeAnimationTransformAdjustments = CATransform3DIdentity;
 
     NSUInteger indexOfContentView = [[_scrollView subviews] indexOfObject:_contentView.get()];
@@ -1672,9 +1701,6 @@
 
     updateBlock();
 
-    if (_customContentView)
-        return;
-
     CGRect newBounds = self.bounds;
     CGSize newMinimumLayoutSize = newBounds.size;
 
@@ -1740,7 +1766,7 @@
 
 - (void)_endAnimatedResize
 {
-    if (!_customContentView) {
+    if (!_customContentView && _isAnimatingResize) {
         NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()];
         [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView];
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (169325 => 169326)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2014-05-25 22:30:25 UTC (rev 169325)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2014-05-26 00:04:43 UTC (rev 169326)
@@ -65,6 +65,8 @@
 
 @property (nonatomic, setter=_setUsesMinimalUI:) BOOL _usesMinimalUI;
 
+- (void)_processDidExit;
+
 - (void)_didCommitLoadForMainFrame;
 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction;
 

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (169325 => 169326)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-05-25 22:30:25 UTC (rev 169325)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-05-26 00:04:43 UTC (rev 169326)
@@ -145,6 +145,7 @@
 void PageClientImpl::processDidExit()
 {
     [m_contentView _processDidExit];
+    [m_webView _processDidExit];
 }
 
 void PageClientImpl::didRelaunchProcess()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to