Title: [238184] trunk
Revision
238184
Author
[email protected]
Date
2018-11-14 10:43:21 -0800 (Wed, 14 Nov 2018)

Log Message

REGRESSION (WEBPROCESS_WINDOWSERVER_BLOCKING): requestAnimationFrame Stops Completing
https://bugs.webkit.org/show_bug.cgi?id=190884

Reviewed by Dean Jackson.

Source/WebCore:

Only notify display refresh monitors with matching display ID.

Test: fast/animation/request-animation-frame-in-two-pages.html

* platform/graphics/DisplayRefreshMonitorManager.cpp:
(WebCore::DisplayRefreshMonitorManager::displayWasUpdated):
* platform/graphics/DisplayRefreshMonitorManager.h:

Source/WebKit:

Since the Web page currently owns the display link on the UI process side, the display link will be
deleted in the UI process when a Web page is closed. This is incorrect, since a display link can be
reused between Web pages in the WebContent process. This patch moves the ownership of the UI process
display links to the Web process object to address this issue. Also, the display ID of the display
being updated is included in the message to the WebContent process.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:
* UIProcess/mac/DisplayLink.cpp:
(WebKit::DisplayLink::DisplayLink):
(WebKit::DisplayLink::displayLinkCallback):
* UIProcess/mac/DisplayLink.h:
(WebKit::DisplayLink::displayID const):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::startDisplayLink): Deleted.
(WebKit::WebPageProxy::stopDisplayLink): Deleted.
* UIProcess/mac/WebProcessProxyMac.mm:
(WebKit::WebProcessProxy::startDisplayLink):
(WebKit::WebProcessProxy::stopDisplayLink):
* WebProcess/WebPage/DrawingArea.h:
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/mac/DrawingAreaMac.cpp:
(WebKit::DisplayRefreshMonitorMac::create):
(WebKit::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
(WebKit::DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac):
(WebKit::DisplayRefreshMonitorMac::requestRefreshCallback):
(WebKit::DrawingArea::createDisplayRefreshMonitor):
(WebKit::DrawingArea::displayWasRefreshed): Deleted.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::displayWasRefreshed):

LayoutTests:

* TestExpectations:
* fast/animation/request-animation-frame-in-two-pages-expected.txt: Added.
* fast/animation/request-animation-frame-in-two-pages.html: Added.
* platform/mac-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (238183 => 238184)


--- trunk/LayoutTests/ChangeLog	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/LayoutTests/ChangeLog	2018-11-14 18:43:21 UTC (rev 238184)
@@ -1,3 +1,15 @@
+2018-11-14  Per Arne Vollan  <[email protected]>
+
+        REGRESSION (WEBPROCESS_WINDOWSERVER_BLOCKING): requestAnimationFrame Stops Completing
+        https://bugs.webkit.org/show_bug.cgi?id=190884
+
+        Reviewed by Dean Jackson.
+
+        * TestExpectations:
+        * fast/animation/request-animation-frame-in-two-pages-expected.txt: Added.
+        * fast/animation/request-animation-frame-in-two-pages.html: Added.
+        * platform/mac-wk2/TestExpectations:
+
 2018-11-14  Youenn Fablet  <[email protected]>
 
         Calling removeTrack on different RTCPeerConnection should throw InvalidAccessError

Modified: trunk/LayoutTests/TestExpectations (238183 => 238184)


--- trunk/LayoutTests/TestExpectations	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/LayoutTests/TestExpectations	2018-11-14 18:43:21 UTC (rev 238184)
@@ -420,6 +420,9 @@
 # The Web Share API is currently only implemented for modern WebKit on iOS and macOS
 fast/web-share [ Skip ]
 
+# This test was created to test a mac-wk2 bugfix
+fast/animation/request-animation-frame-in-two-pages.html [ Skip ]
+
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific tests.
 #//////////////////////////////////////////////////////////////////////////////////////////

Added: trunk/LayoutTests/fast/animation/request-animation-frame-in-two-pages-expected.txt (0 => 238184)


--- trunk/LayoutTests/fast/animation/request-animation-frame-in-two-pages-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/animation/request-animation-frame-in-two-pages-expected.txt	2018-11-14 18:43:21 UTC (rev 238184)
@@ -0,0 +1,4 @@
+This test succeeds if RAF is resumed in a page from where another page with RAF was opened and then closed.
+Window closed.
+PASS
+

Added: trunk/LayoutTests/fast/animation/request-animation-frame-in-two-pages.html (0 => 238184)


--- trunk/LayoutTests/fast/animation/request-animation-frame-in-two-pages.html	                        (rev 0)
+++ trunk/LayoutTests/fast/animation/request-animation-frame-in-two-pages.html	2018-11-14 18:43:21 UTC (rev 238184)
@@ -0,0 +1,55 @@
+<html>
+<head>
+<script>
+function onload()
+{
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.setCanOpenWindows(true);
+        testRunner.waitUntilDone();
+    }
+
+    function log(msg)
+    {
+        document.getElementById("logger").innerHTML += msg + "<br>";
+    }
+
+    function checkWindow()
+    {
+        if(newWindow.closed) {
+            log("Window closed.");
+            clearInterval(timer);
+            if (window.testRunner)
+                testRunner.setPageVisibility("visible");
+        }
+    }
+
+    log("This test succeeds if RAF is resumed in a page from where another page with RAF was opened and then closed.");
+
+    c = 0;
+
+    function raf()
+    {
+        requestAnimationFrame(raf);
+        if (c == 10) {
+            src = "" <script> c = 0; function raf() { requestAnimationFrame(raf); if (c++ == 10) window.close(); } requestAnimationFrame(raf); <\/script>";
+            newWindow = window.open(src, "_blank");
+            timer = setInterval(checkWindow, 100);
+            if (window.testRunner)
+                testRunner.setPageVisibility("hidden");
+        }
+        if (c == 20) {
+            log("PASS");
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }
+        c++;
+    }
+    requestAnimationFrame(raf)
+}
+</script>
+</head>
+<body _onload_="onload();">
+    <div id="logger"></div>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (238183 => 238184)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2018-11-14 18:43:21 UTC (rev 238184)
@@ -70,6 +70,8 @@
 
 fast/events/inactive-window-no-mouse-event.html [ Pass ]
 
+fast/animation/request-animation-frame-in-two-pages.html [ Pass ]
+
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific directories.
 #//////////////////////////////////////////////////////////////////////////////////////////
@@ -901,4 +903,4 @@
 http/wpt/credential-management/credentialscontainer-store-basics.https.html [ Skip ]
 http/wpt/webauthn/idl.https.html [ Skip ]
 
-webkit.org/b/183878 media/modern-media-controls/tracks-panel/tracks-panel-up-click-over-media-does-not-dimiss-media-controls-when-media-is-playing.html [ Pass Timeout ] 
\ No newline at end of file
+webkit.org/b/183878 media/modern-media-controls/tracks-panel/tracks-panel-up-click-over-media-does-not-dimiss-media-controls-when-media-is-playing.html [ Pass Timeout ] 

Modified: trunk/Source/WebCore/ChangeLog (238183 => 238184)


--- trunk/Source/WebCore/ChangeLog	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebCore/ChangeLog	2018-11-14 18:43:21 UTC (rev 238184)
@@ -1,3 +1,18 @@
+2018-11-14  Per Arne Vollan  <[email protected]>
+
+        REGRESSION (WEBPROCESS_WINDOWSERVER_BLOCKING): requestAnimationFrame Stops Completing
+        https://bugs.webkit.org/show_bug.cgi?id=190884
+
+        Reviewed by Dean Jackson.
+
+        Only notify display refresh monitors with matching display ID.
+
+        Test: fast/animation/request-animation-frame-in-two-pages.html
+
+        * platform/graphics/DisplayRefreshMonitorManager.cpp:
+        (WebCore::DisplayRefreshMonitorManager::displayWasUpdated):
+        * platform/graphics/DisplayRefreshMonitorManager.h:
+
 2018-11-14  Youenn Fablet  <[email protected]>
 
         Convert libwebrtc error types to DOM exceptions

Modified: trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp (238183 => 238184)


--- trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.cpp	2018-11-14 18:43:21 UTC (rev 238184)
@@ -125,10 +125,10 @@
         scheduleAnimation(client);
 }
 
-void DisplayRefreshMonitorManager::displayWasUpdated()
+void DisplayRefreshMonitorManager::displayWasUpdated(PlatformDisplayID displayID)
 {
     for (auto monitor : m_monitors) {
-        if (monitor->hasRequestedRefreshCallback())
+        if (displayID == monitor->displayID() && monitor->hasRequestedRefreshCallback())
             monitor->displayLinkFired();
     }
 }

Modified: trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h (238183 => 238184)


--- trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitorManager.h	2018-11-14 18:43:21 UTC (rev 238184)
@@ -46,7 +46,7 @@
     bool scheduleAnimation(DisplayRefreshMonitorClient&);
     void windowScreenDidChange(PlatformDisplayID, DisplayRefreshMonitorClient&);
 
-    WEBCORE_EXPORT void displayWasUpdated();
+    WEBCORE_EXPORT void displayWasUpdated(PlatformDisplayID);
     
 private:
     friend class DisplayRefreshMonitor;

Modified: trunk/Source/WebKit/ChangeLog (238183 => 238184)


--- trunk/Source/WebKit/ChangeLog	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/ChangeLog	2018-11-14 18:43:21 UTC (rev 238184)
@@ -1,3 +1,48 @@
+2018-11-14  Per Arne Vollan  <[email protected]>
+
+        REGRESSION (WEBPROCESS_WINDOWSERVER_BLOCKING): requestAnimationFrame Stops Completing
+        https://bugs.webkit.org/show_bug.cgi?id=190884
+
+        Reviewed by Dean Jackson.
+
+        Since the Web page currently owns the display link on the UI process side, the display link will be
+        deleted in the UI process when a Web page is closed. This is incorrect, since a display link can be
+        reused between Web pages in the WebContent process. This patch moves the ownership of the UI process
+        display links to the Web process object to address this issue. Also, the display ID of the display
+        being updated is included in the message to the WebContent process.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::close):
+        (WebKit::WebPageProxy::resetStateAfterProcessExited):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebProcessProxy.messages.in:
+        * UIProcess/mac/DisplayLink.cpp:
+        (WebKit::DisplayLink::DisplayLink):
+        (WebKit::DisplayLink::displayLinkCallback):
+        * UIProcess/mac/DisplayLink.h:
+        (WebKit::DisplayLink::displayID const):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::startDisplayLink): Deleted.
+        (WebKit::WebPageProxy::stopDisplayLink): Deleted.
+        * UIProcess/mac/WebProcessProxyMac.mm:
+        (WebKit::WebProcessProxy::startDisplayLink):
+        (WebKit::WebProcessProxy::stopDisplayLink):
+        * WebProcess/WebPage/DrawingArea.h:
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        * WebProcess/WebPage/mac/DrawingAreaMac.cpp:
+        (WebKit::DisplayRefreshMonitorMac::create):
+        (WebKit::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
+        (WebKit::DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac):
+        (WebKit::DisplayRefreshMonitorMac::requestRefreshCallback):
+        (WebKit::DrawingArea::createDisplayRefreshMonitor):
+        (WebKit::DrawingArea::displayWasRefreshed): Deleted.
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::displayWasRefreshed):
+
 2018-11-14  Chris Dumez  <[email protected]>
 
         Client should be able to disable PSON even if the experimental feature is on by default

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-11-14 18:43:21 UTC (rev 238184)
@@ -955,10 +955,6 @@
     m_activityToken = nullptr;
 #endif
 
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    m_displayLink = nullptr;
-#endif
-
     stopAllURLSchemeTasks();
 }
 
@@ -6309,10 +6305,6 @@
     m_activityToken = nullptr;
 #endif
 
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    m_displayLink = nullptr;
-#endif
-
     m_pageIsUserObservableCount = nullptr;
     m_visiblePageToken = nullptr;
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-11-14 18:43:21 UTC (rev 238184)
@@ -126,10 +126,6 @@
 #include <WebCore/WebMediaSessionManagerClient.h>
 #endif
 
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-#include "DisplayLink.h"
-#endif
-
 #if ENABLE(MEDIA_SESSION)
 namespace WebCore {
 class MediaSessionMetadata;
@@ -1850,11 +1846,6 @@
     void invalidateAllAttachments();
 #endif
 
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    void startDisplayLink(unsigned observerID);
-    void stopDisplayLink(unsigned observerID);
-#endif
-
     void reportPageLoadResult(const WebCore::ResourceError& = { });
 
     void continueNavigationInNewProcess(API::Navigation&, Ref<WebProcessProxy>&&);
@@ -2259,10 +2250,6 @@
     HashMap<String, Ref<API::Attachment>> m_attachmentIdentifierToAttachmentMap;
 #endif
         
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    std::unique_ptr<DisplayLink> m_displayLink;
-#endif
-
     std::optional<SpellDocumentTag> m_spellDocumentTag;
 
     std::optional<MonotonicTime> m_pageLoadStart;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-11-14 18:43:21 UTC (rev 238184)
@@ -541,11 +541,6 @@
     SerializedAttachmentDataForIdentifiers(Vector<String> identifiers) -> (Vector<WebCore::SerializedAttachmentData> seralizedData) LegacySync
 #endif
 
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    StartDisplayLink(unsigned observerID)
-    StopDisplayLink(unsigned observerID)
-#endif
-
     SignedPublicKeyAndChallengeString(unsigned keySizeIndex, String challengeString, WebCore::URL url) -> (String result) LegacySync
 
 }

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-11-14 18:43:21 UTC (rev 238184)
@@ -50,6 +50,10 @@
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+#include "DisplayLink.h"
+#endif
+
 namespace API {
 class Navigation;
 class PageConfiguration;
@@ -227,6 +231,11 @@
     void releaseHighPerformanceGPU();
 #endif
 
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    void startDisplayLink(unsigned observerID, uint32_t displayID);
+    void stopDisplayLink(unsigned observerID, uint32_t displayID);
+#endif
+
     // Called when the web process has crashed or we know that it will terminate soon.
     // Will potentially cause the WebProcessProxy object to be freed.
     void shutDown();
@@ -398,6 +407,10 @@
 #if PLATFORM(WATCHOS)
     ProcessThrottler::BackgroundActivityToken m_backgroundActivityTokenForFullscreenFormControls;
 #endif
+
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    Vector<std::unique_ptr<DisplayLink>> m_displayLinks;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in	2018-11-14 18:43:21 UTC (rev 238184)
@@ -74,4 +74,9 @@
     RequestHighPerformanceGPU()
     ReleaseHighPerformanceGPU()
 #endif
+
+#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+    StartDisplayLink(unsigned observerID, uint32_t displayID)
+    StopDisplayLink(unsigned observerID, uint32_t displayID)
+#endif
 }

Modified: trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2018-11-14 18:43:21 UTC (rev 238184)
@@ -29,15 +29,14 @@
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
 
 #include "DrawingAreaMessages.h"
-#include "WebPageProxy.h"
 #include "WebProcessProxy.h"
 #include <wtf/ProcessPrivilege.h>
 
 namespace WebKit {
     
-DisplayLink::DisplayLink(WebCore::PlatformDisplayID displayID, WebPageProxy& webPageProxy)
-    : m_connection(webPageProxy.process().connection())
-    , m_pageID(webPageProxy.pageID())
+DisplayLink::DisplayLink(WebCore::PlatformDisplayID displayID, WebProcessProxy& webProcessProxy)
+    : m_connection(webProcessProxy.connection())
+    , m_displayID(displayID)
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID, &m_displayLink);
@@ -86,7 +85,7 @@
 CVReturn DisplayLink::displayLinkCallback(CVDisplayLinkRef displayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data)
 {
     DisplayLink* displayLink = static_cast<DisplayLink*>(data);
-    displayLink->m_connection->send(Messages::DrawingArea::DisplayWasRefreshed(), displayLink->m_pageID);
+    displayLink->m_connection->send(Messages::WebProcess::DisplayWasRefreshed(displayLink->m_displayID), 0);
     return kCVReturnSuccess;
 }
 

Modified: trunk/Source/WebKit/UIProcess/mac/DisplayLink.h (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/mac/DisplayLink.h	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayLink.h	2018-11-14 18:43:21 UTC (rev 238184)
@@ -38,11 +38,11 @@
 
 namespace WebKit {
 
-class WebPageProxy;
+class WebProcessProxy;
     
 class DisplayLink {
 public:
-    DisplayLink(WebCore::PlatformDisplayID, WebPageProxy&);
+    DisplayLink(WebCore::PlatformDisplayID, WebProcessProxy&);
     ~DisplayLink();
     
     void addObserver(unsigned observerID);
@@ -49,6 +49,8 @@
     void removeObserver(unsigned observerID);
     bool hasObservers() const;
 
+    WebCore::PlatformDisplayID displayID() const { return m_displayID; }
+
 private:
     static CVReturn displayLinkCallback(CVDisplayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data);
     
@@ -55,7 +57,7 @@
     CVDisplayLinkRef m_displayLink { nullptr };
     HashSet<unsigned> m_observers;
     RefPtr<IPC::Connection> m_connection;
-    uint64_t m_pageID { 0 };
+    WebCore::PlatformDisplayID m_displayID { 0 };
 };
 
 }

Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2018-11-14 18:43:21 UTC (rev 238184)
@@ -678,28 +678,6 @@
 }
 #endif
 
-#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-void WebPageProxy::startDisplayLink(unsigned observerID)
-{
-    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
-    if (!m_displayLink) {
-        uint32_t displayID = [[[[platformWindow() screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
-        m_displayLink = std::make_unique<DisplayLink>(displayID, *this);
-    }
-    m_displayLink->addObserver(observerID);
-}
-
-void WebPageProxy::stopDisplayLink(unsigned observerID)
-{
-    if (!m_displayLink)
-        return;
-    
-    m_displayLink->removeObserver(observerID);
-    if (!m_displayLink->hasObservers())
-        m_displayLink = nullptr;
-}
-#endif
-
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)

Modified: trunk/Source/WebKit/UIProcess/mac/WebProcessProxyMac.mm (238183 => 238184)


--- trunk/Source/WebKit/UIProcess/mac/WebProcessProxyMac.mm	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/UIProcess/mac/WebProcessProxyMac.mm	2018-11-14 18:43:21 UTC (rev 238184)
@@ -69,6 +69,36 @@
 #endif
 }
 
+#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+void WebProcessProxy::startDisplayLink(unsigned observerID, uint32_t displayID)
+{
+    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
+    for (auto& displayLink : m_displayLinks) {
+        if (displayLink->displayID() == displayID) {
+            displayLink->addObserver(observerID);
+            return;
+        }
+    }
+    auto displayLink = std::make_unique<DisplayLink>(displayID, *this);
+    displayLink->addObserver(observerID);
+    m_displayLinks.append(WTFMove(displayLink));
+}
+
+void WebProcessProxy::stopDisplayLink(unsigned observerID, uint32_t displayID)
+{
+    size_t pos = 0;
+    for (auto& displayLink : m_displayLinks) {
+        if (displayLink->displayID() == displayID) {
+            displayLink->removeObserver(observerID);
+            if (!displayLink->hasObservers())
+                m_displayLinks.remove(pos);
+            return;
+        }
+        pos++;
+    }
+}
+#endif
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)

Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h (238183 => 238184)


--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2018-11-14 18:43:21 UTC (rev 238184)
@@ -149,10 +149,6 @@
     virtual void deviceOrPageScaleFactorChanged() = 0;
 #endif
 
-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    void displayWasRefreshed();
-#endif
-
     virtual void attach() { };
 
 protected:

Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in (238183 => 238184)


--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in	2018-11-14 18:43:21 UTC (rev 238184)
@@ -44,10 +44,4 @@
     SetNativeSurfaceHandleForCompositing(uint64_t handle)
     DestroyNativeSurfaceHandleForCompositing() -> (bool handled)
 #endif
-
-#if PLATFORM(MAC)
-#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
-    DisplayWasRefreshed()
-#endif
-#endif
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/DrawingAreaMac.cpp (238183 => 238184)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/DrawingAreaMac.cpp	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/DrawingAreaMac.cpp	2018-11-14 18:43:21 UTC (rev 238184)
@@ -26,12 +26,11 @@
 #include "config.h"
 #include "DrawingArea.h"
 
-#include "WebPage.h"
-#include "WebPageProxy.h"
-#include "WebPageProxyMessages.h"
+#include "WebProcess.h"
+#include "WebProcessProxy.h"
+#include "WebProcessProxyMessages.h"
 
 #include <WebCore/DisplayRefreshMonitor.h>
-#include <WebCore/DisplayRefreshMonitorManager.h>
 #include <WebCore/RunLoopObserver.h>
 
 namespace WebKit {
@@ -41,9 +40,9 @@
 
 class DisplayRefreshMonitorMac : public DisplayRefreshMonitor {
 public:
-    static Ref<DisplayRefreshMonitorMac> create(PlatformDisplayID displayID, WebPage& webPage)
+    static Ref<DisplayRefreshMonitorMac> create(PlatformDisplayID displayID)
     {
-        return adoptRef(*new DisplayRefreshMonitorMac(displayID, webPage));
+        return adoptRef(*new DisplayRefreshMonitorMac(displayID));
     }
     
     virtual ~DisplayRefreshMonitorMac();
@@ -52,11 +51,10 @@
     bool requestRefreshCallback() override;
     
 private:
-    explicit DisplayRefreshMonitorMac(PlatformDisplayID, WebPage&);
+    explicit DisplayRefreshMonitorMac(PlatformDisplayID);
     
     bool hasRequestedRefreshCallback() const override { return m_hasSentMessage; }
 
-    WeakPtr<WebPage> m_webPage;
     bool m_hasSentMessage { false };
     unsigned m_observerID;
     static unsigned m_counterID;
@@ -66,9 +64,8 @@
 
 unsigned DisplayRefreshMonitorMac::m_counterID = 0;
 
-DisplayRefreshMonitorMac::DisplayRefreshMonitorMac(PlatformDisplayID displayID, WebPage& webPage)
+DisplayRefreshMonitorMac::DisplayRefreshMonitorMac(PlatformDisplayID displayID)
     : DisplayRefreshMonitor(displayID)
-    , m_webPage(makeWeakPtr(webPage))
     , m_observerID(++m_counterID)
 {
 }
@@ -75,23 +72,16 @@
 
 DisplayRefreshMonitorMac::~DisplayRefreshMonitorMac()
 {
-    if (!m_webPage)
-        return;
-    
-    m_webPage->send(Messages::WebPageProxy::StopDisplayLink(m_observerID));
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::StopDisplayLink(m_observerID, displayID()), 0);
 }
 
 bool DisplayRefreshMonitorMac::requestRefreshCallback()
 {
-    ASSERT(m_webPage);
-    if (!m_webPage)
-        return false;
-
     if (!isActive())
         return false;
 
     if (!m_hasSentMessage) {
-        m_webPage->send(Messages::WebPageProxy::StartDisplayLink(m_observerID));
+        WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::StartDisplayLink(m_observerID, displayID()), 0);
         m_hasSentMessage = true;
         m_runLoopObserver = std::make_unique<RunLoopObserver>(kCFRunLoopEntry, [this]() {
             this->m_firstCallbackInCurrentRunloop = true;
@@ -115,14 +105,9 @@
     handleDisplayRefreshedNotificationOnMainThread(this);
 }
 
-void DrawingArea::displayWasRefreshed()
-{
-    DisplayRefreshMonitorManager::sharedManager().displayWasUpdated();
-}
-
 RefPtr<WebCore::DisplayRefreshMonitor> DrawingArea::createDisplayRefreshMonitor(PlatformDisplayID displayID)
 {
-    return DisplayRefreshMonitorMac::create(displayID, m_webPage);
+    return DisplayRefreshMonitorMac::create(displayID);
 }
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (238183 => 238184)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2018-11-14 18:43:21 UTC (rev 238184)
@@ -385,6 +385,7 @@
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     void scrollerStylePreferenceChanged(bool useOverlayScrollbars);
     void displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags);
+    void displayWasRefreshed(CGDirectDisplayID);
 #endif
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (238183 => 238184)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-11-14 18:43:21 UTC (rev 238184)
@@ -136,6 +136,7 @@
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     ScrollerStylePreferenceChanged(bool useOvelayScrollbars)
     DisplayConfigurationChanged(CGDirectDisplayID displayID, CGDisplayChangeSummaryFlags flags)
+    DisplayWasRefreshed(uint32_t displayID)
 #endif
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (238183 => 238184)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-11-14 18:13:13 UTC (rev 238183)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2018-11-14 18:43:21 UTC (rev 238184)
@@ -51,6 +51,7 @@
 #import <WebCore/AVFoundationMIMETypeCache.h>
 #import <WebCore/AXObjectCache.h>
 #import <WebCore/CPUMonitor.h>
+#import <WebCore/DisplayRefreshMonitorManager.h>
 #import <WebCore/FileSystem.h>
 #import <WebCore/FontCache.h>
 #import <WebCore/FontCascade.h>
@@ -651,6 +652,11 @@
 {
     GraphicsContext3DManager::displayWasReconfigured(displayID, flags, nullptr);
 }
+    
+void WebProcess::displayWasRefreshed(CGDirectDisplayID displayID)
+{
+    DisplayRefreshMonitorManager::sharedManager().displayWasUpdated(displayID);
+}
 #endif
 
 void WebProcess::setMediaMIMETypes(const Vector<String> types)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to