Title: [185799] trunk/Source/WebKit2
Revision
185799
Author
[email protected]
Date
2015-06-20 13:50:35 -0700 (Sat, 20 Jun 2015)

Log Message

[WK2][iOS] Avoid synchronous IPC on view state change when the content is not visible
https://bugs.webkit.org/show_bug.cgi?id=146179
<rdar://problem/20923432>

Reviewed by Tim Horton.

After r170787, viewStateChange() would cause a synchronous IPC between
the UIProcess and the WebProcess when the view becomes visible. This
was to avoid painting empty / black tiles when unsuspending the
WebProcess on tab switch, in the event volatile IOSurfaces were purged.

However, this sync IPC can have performance implications and is not
needed when the content is not actually visible yet (e.g.
hideContentUntilNextUpdate() was called, or the tab was killed).

This patch avoids the synchronous IPC when the content is hidden and
exposes a private API on WKWebView so that clients can ask for the
content to be hidden until the next update. This would allow for
clients to avoid the synchronous IPC if they don't need the content
to be displayed synchronously (e.g. the view is obscured).

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _hideContentUntilNextUpdate]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::hasVisibleContent):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchViewStateChange):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::isContentHidden):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (185798 => 185799)


--- trunk/Source/WebKit2/ChangeLog	2015-06-20 16:48:11 UTC (rev 185798)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-20 20:50:35 UTC (rev 185799)
@@ -1,3 +1,37 @@
+2015-06-20  Chris Dumez  <[email protected]>
+
+        [WK2][iOS] Avoid synchronous IPC on view state change when the content is not visible
+        https://bugs.webkit.org/show_bug.cgi?id=146179
+        <rdar://problem/20923432>
+
+        Reviewed by Tim Horton.
+
+        After r170787, viewStateChange() would cause a synchronous IPC between
+        the UIProcess and the WebProcess when the view becomes visible. This
+        was to avoid painting empty / black tiles when unsuspending the
+        WebProcess on tab switch, in the event volatile IOSurfaces were purged.
+
+        However, this sync IPC can have performance implications and is not
+        needed when the content is not actually visible yet (e.g.
+        hideContentUntilNextUpdate() was called, or the tab was killed).
+
+        This patch avoids the synchronous IPC when the content is hidden and
+        exposes a private API on WKWebView so that clients can ask for the
+        content to be hidden until the next update. This would allow for
+        clients to avoid the synchronous IPC if they don't need the content
+        to be displayed synchronously (e.g. the view is obscured).
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _hideContentUntilNextUpdate]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::hasVisibleContent):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::dispatchViewStateChange):
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::isContentHidden):
+
 2015-06-20  Michael Catanzaro  <[email protected]>
 
         Check for SHA1 certificates ignores subresources

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


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-06-20 16:48:11 UTC (rev 185798)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-06-20 20:50:35 UTC (rev 185799)
@@ -2591,6 +2591,12 @@
     [self _updateVisibleContentRects];
 }
 
+- (void)_hideContentUntilNextUpdate
+{
+    if (auto* area = _page->drawingArea())
+        area->hideContentUntilNextUpdate();
+}
+
 - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock
 {
     CGRect oldBounds = self.bounds;

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (185798 => 185799)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-06-20 16:48:11 UTC (rev 185798)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-06-20 20:50:35 UTC (rev 185799)
@@ -134,6 +134,7 @@
 
 - (void)_beginInteractiveObscuredInsetsChange;
 - (void)_endInteractiveObscuredInsetsChange;
+- (void)_hideContentUntilNextUpdate;
 
 - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock;
 - (void)_endAnimatedResize;

Modified: trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h (185798 => 185799)


--- trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h	2015-06-20 16:48:11 UTC (rev 185798)
+++ trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h	2015-06-20 20:50:35 UTC (rev 185799)
@@ -90,6 +90,7 @@
     virtual void dispatchAfterEnsuringDrawing(std::function<void (CallbackBase::Error)>) { ASSERT_NOT_REACHED(); }
 
     virtual void hideContentUntilNextUpdate() { ASSERT_NOT_REACHED(); }
+    virtual bool hasVisibleContent() const { return true; }
 
     virtual void willSendUpdateGeometry() { }
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (185798 => 185799)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-06-20 16:48:11 UTC (rev 185798)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-06-20 20:50:35 UTC (rev 185799)
@@ -1372,7 +1372,7 @@
     ViewState::Flags changed = m_viewState ^ previousViewState;
 
     // We always want to wait for the Web process to reply if we've been in-window before and are coming back in-window.
-    if (m_viewWasEverInWindow && (changed & ViewState::IsInWindow) && isInWindow())
+    if (m_viewWasEverInWindow && (changed & ViewState::IsInWindow) && isInWindow() && m_drawingArea->hasVisibleContent())
         m_viewStateChangeWantsSynchronousReply = true;
 
     // Don't wait synchronously if the view state is not visible. (This matters in particular on iOS, where a hidden page may be suspended.)

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h (185798 => 185799)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h	2015-06-20 16:48:11 UTC (rev 185798)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h	2015-06-20 20:50:35 UTC (rev 185799)
@@ -39,7 +39,7 @@
 class RemoteLayerTreeTransaction;
 class RemoteScrollingCoordinatorTransaction;
 
-class RemoteLayerTreeDrawingAreaProxy : public DrawingAreaProxy {
+class RemoteLayerTreeDrawingAreaProxy final : public DrawingAreaProxy {
 public:
     explicit RemoteLayerTreeDrawingAreaProxy(WebPageProxy&);
     virtual ~RemoteLayerTreeDrawingAreaProxy();
@@ -77,6 +77,7 @@
 
     virtual void waitForDidUpdateViewState() override;
     virtual void hideContentUntilNextUpdate() override;
+    virtual bool hasVisibleContent() const override;
     
     WebCore::FloatPoint indicatorLocation() const;
 

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm (185798 => 185799)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm	2015-06-20 16:48:11 UTC (rev 185798)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm	2015-06-20 20:50:35 UTC (rev 185799)
@@ -421,4 +421,9 @@
     m_remoteLayerTreeHost.detachRootLayer();
 }
 
+bool RemoteLayerTreeDrawingAreaProxy::hasVisibleContent() const
+{
+    return m_remoteLayerTreeHost.rootLayer();
+}
+
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to