Title: [120830] branches/safari-536-branch/Source/WebKit2

Diff

Modified: branches/safari-536-branch/Source/WebKit2/ChangeLog (120829 => 120830)


--- branches/safari-536-branch/Source/WebKit2/ChangeLog	2012-06-20 16:33:27 UTC (rev 120829)
+++ branches/safari-536-branch/Source/WebKit2/ChangeLog	2012-06-20 17:14:23 UTC (rev 120830)
@@ -1,3 +1,45 @@
+2012-06-20  Lucas Forschler  <[email protected]>
+
+    Merge 120376
+
+    2012-06-14  Tim Horton  <[email protected]>
+
+            DrawingArea: Painting is being resumed while the view is not visible
+            https://bugs.webkit.org/show_bug.cgi?id=88940
+            <rdar://problem/11652545>
+
+            Reviewed by Dean Jackson.
+
+            Using requestAnimationFrame and the fullscreen API on a DrawingArea-backed window would cause
+            rAF to permanently suspend animations after entering full-screen mode, because of the following:
+
+            0. _javascript_ causes fullscreen transition to start.
+            1. Painting (and rAF) are suspended.
+            2. The page changes size.
+                a. DrawingAreaProxyImpl::sizeDidChange() calls DrawingAreaImpl::updateBackingStoreState, which calls DrawingAreaImpl::resumePainting.
+                b. DrawingAreaImpl::resumePainting resumes painting, but does *not* resume rAF, because windowIsVisible is (legitimately) false.
+            3. The view becomes visible, windowIsVisible is updated to true.
+            4. visibilityDidChange() calls resumePainting again, but this time it early exits because painting is not suspended.
+
+            Notice that because of the early exit in 4, rAF is never resumed.
+
+            To solve this and prevent any further bugs caused by these unnecessary calls to resume/suspendPainting,
+            temporarily stop sending SuspendPainting/ResumePainting messages from DrawingAreaProxyImpl::visibilityDidChange
+            during the window animations that occur while entering and exiting full-screen.
+
+            * UIProcess/API/mac/WKViewInternal.h:
+            * UIProcess/API/mac/WKView.mm:
+            (-[WKView setAutomaticallySuspendAndResumePainting:]):
+            (-[WKView automaticallySuspendAndResumePainting]):
+            * UIProcess/DrawingAreaProxyImpl.cpp:
+            (WebKit::DrawingAreaProxyImpl::visibilityDidChange):
+            * UIProcess/WebPageProxy.h:
+            (WebKit::WebPageProxy::setShouldSuspendAndResumePainting):
+            (WebKit::WebPageProxy::shouldSuspendAndResumePainting):
+            * UIProcess/mac/WKFullScreenWindowController.mm:
+            (-[WKFullScreenWindowController enterFullScreen:]):
+            (-[WKFullScreenWindowController _startEnterFullScreenAnimationWithDuration:]):
+
 2012-06-12  Lucas Forschler  <[email protected]>
 
     Merge 120329

Modified: branches/safari-536-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (120829 => 120830)


--- branches/safari-536-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm	2012-06-20 16:33:27 UTC (rev 120829)
+++ branches/safari-536-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm	2012-06-20 17:14:23 UTC (rev 120830)
@@ -2898,6 +2898,16 @@
     _data->_page->handleAlternativeTextUIResult(text);
 }
 
+- (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates
+{
+    _data->_page->setSuppressVisibilityUpdates(suppressVisibilityUpdates);
+}
+
+- (BOOL)_suppressVisibilityUpdates
+{
+    return _data->_page->suppressVisibilityUpdates();
+}
+
 @end
 
 @implementation WKView (Private)

Modified: branches/safari-536-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (120829 => 120830)


--- branches/safari-536-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2012-06-20 16:33:27 UTC (rev 120829)
+++ branches/safari-536-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h	2012-06-20 17:14:23 UTC (rev 120830)
@@ -98,5 +98,7 @@
 - (NSInteger)spellCheckerDocumentTag;
 - (void)handleAcceptedAlternativeText:(NSString*)text;
 
+- (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates;
+- (BOOL)_suppressVisibilityUpdates;
 
 @end

Modified: branches/safari-536-branch/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp (120829 => 120830)


--- branches/safari-536-branch/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp	2012-06-20 16:33:27 UTC (rev 120829)
+++ branches/safari-536-branch/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp	2012-06-20 17:14:23 UTC (rev 120830)
@@ -134,15 +134,17 @@
 
 void DrawingAreaProxyImpl::visibilityDidChange()
 {
-    if (!m_webPageProxy->isViewVisible()) {
-        // Suspend painting.
-        m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID());
-        return;
+    if (!m_webPageProxy->suppressVisibilityUpdates()) {
+        if (!m_webPageProxy->isViewVisible()) {
+            // Suspend painting.
+            m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID());
+            return;
+        }
+
+        // Resume painting.
+        m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID());
     }
 
-    // Resume painting.
-    m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID());
-
 #if USE(ACCELERATED_COMPOSITING)
     // If we don't have a backing store, go ahead and mark the backing store as being changed so
     // that when paint we'll actually wait for something to paint and not flash white.

Modified: branches/safari-536-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (120829 => 120830)


--- branches/safari-536-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-06-20 16:33:27 UTC (rev 120829)
+++ branches/safari-536-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-06-20 17:14:23 UTC (rev 120830)
@@ -210,6 +210,7 @@
     , m_pageCount(0)
     , m_renderTreeSize(0)
     , m_shouldSendEventsSynchronously(false)
+    , m_suppressVisibilityUpdates(false)
     , m_mediaVolume(1)
 #if ENABLE(PAGE_VISIBILITY_API)
     , m_visibilityState(PageVisibilityStateVisible)

Modified: branches/safari-536-branch/Source/WebKit2/UIProcess/WebPageProxy.h (120829 => 120830)


--- branches/safari-536-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2012-06-20 16:33:27 UTC (rev 120829)
+++ branches/safari-536-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2012-06-20 17:14:23 UTC (rev 120830)
@@ -654,6 +654,9 @@
     // WebPopupMenuProxy::Client
     virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
 
+    void setSuppressVisibilityUpdates(bool flag) { m_suppressVisibilityUpdates = flag; }
+    bool suppressVisibilityUpdates() { return m_suppressVisibilityUpdates; }
+
 private:
     WebPageProxy(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
 
@@ -1088,7 +1091,9 @@
     static WKPageDebugPaintFlags s_debugPaintFlags;
 
     bool m_shouldSendEventsSynchronously;
-    
+
+    bool m_suppressVisibilityUpdates;
+
     float m_mediaVolume;
 
 #if PLATFORM(QT)

Modified: branches/safari-536-branch/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm (120829 => 120830)


--- branches/safari-536-branch/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm	2012-06-20 16:33:27 UTC (rev 120829)
+++ branches/safari-536-branch/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm	2012-06-20 17:14:23 UTC (rev 120830)
@@ -231,13 +231,19 @@
     // future overhead.
     webViewContents = createImageWithCopiedData(webViewContents.get());
 
-    // Screen updates to be re-enabled in beganEnterFullScreenWithInitialFrame:finalFrame:
+    // Screen updates to be re-enabled in _startEnterFullScreenAnimationWithDuration:
     NSDisableScreenUpdates();
     [[self window] setAutodisplay:NO];
 
     NSResponder *webWindowFirstResponder = [[_webView window] firstResponder];
     [[self window] setFrame:screenFrame display:NO];
 
+    // Painting is normally suspended when the WKView is removed from the window, but this is
+    // unnecessary in the full-screen animation case, and can cause bugs; see
+    // https://bugs.webkit.org/show_bug.cgi?id=88940 and https://bugs.webkit.org/show_bug.cgi?id=88374
+    // We will resume the normal behavior in _startEnterFullScreenAnimationWithDuration:
+    [_webView _setSuppressVisibilityUpdates:YES];
+
     // Swap the webView placeholder into place.
     if (!_webViewPlaceholder) {
         _webViewPlaceholder.adoptNS([[NSImageView alloc] init]);
@@ -322,10 +328,14 @@
         return;
     _isFullScreen = NO;
 
-    // Screen updates to be re-enabled in beganExitFullScreenWithInitialFrame:finalFrame:
+    // Screen updates to be re-enabled in _startExitFullScreenAnimationWithDuration:
     NSDisableScreenUpdates();
     [[self window] setAutodisplay:NO];
 
+    // See the related comment in enterFullScreen:
+    // We will resume the normal behavior in _startExitFullScreenAnimationWithDuration:
+    [_webView _setSuppressVisibilityUpdates:YES];
+
     [self _manager]->setAnimatingFullScreen(true);
     [self _manager]->willExitFullScreen();
 }
@@ -566,6 +576,7 @@
 
     [_backgroundWindow.get() orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]];
 
+    [_webView _setSuppressVisibilityUpdates:NO];
     [[self window] setAutodisplay:YES];
     [[self window] displayIfNeeded];
     NSEnableScreenUpdates();
@@ -610,6 +621,7 @@
     finalBounds.origin = [[self window] convertScreenToBase:finalBounds.origin];
     WKWindowSetClipRect([self window], finalBounds);
 
+    [_webView _setSuppressVisibilityUpdates:NO];
     [[self window] setAutodisplay:YES];
     [[self window] displayIfNeeded];
     NSEnableScreenUpdates();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to