Title: [232632] trunk/Source/WebKit
Revision
232632
Author
pvol...@apple.com
Date
2018-06-08 11:30:01 -0700 (Fri, 08 Jun 2018)

Log Message

Send display link IPC message from display link thread.
https://bugs.webkit.org/show_bug.cgi?id=186429

Reviewed by Geoffrey Garen.

When the display link callback is firing on the display link thread in the UI process,
we schedule a function to be called on the main thread to send the IPC message to the
WebContent process. Since Connection::send is thread-safe, we can just send the message
from the display link thread, instead. This should be a small performance improvement.

* UIProcess/mac/DisplayLink.cpp:
(WebKit::DisplayLink::DisplayLink):
(WebKit::DisplayLink::displayLinkCallback):
* UIProcess/mac/DisplayLink.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (232631 => 232632)


--- trunk/Source/WebKit/ChangeLog	2018-06-08 18:29:50 UTC (rev 232631)
+++ trunk/Source/WebKit/ChangeLog	2018-06-08 18:30:01 UTC (rev 232632)
@@ -1,3 +1,20 @@
+2018-06-08  Per Arne Vollan  <pvol...@apple.com>
+
+        Send display link IPC message from display link thread.
+        https://bugs.webkit.org/show_bug.cgi?id=186429
+
+        Reviewed by Geoffrey Garen.
+
+        When the display link callback is firing on the display link thread in the UI process,
+        we schedule a function to be called on the main thread to send the IPC message to the
+        WebContent process. Since Connection::send is thread-safe, we can just send the message
+        from the display link thread, instead. This should be a small performance improvement.
+
+        * UIProcess/mac/DisplayLink.cpp:
+        (WebKit::DisplayLink::DisplayLink):
+        (WebKit::DisplayLink::displayLinkCallback):
+        * UIProcess/mac/DisplayLink.h:
+
 2018-06-07  Chris Dumez  <cdu...@apple.com>
 
         Add base class to get WeakPtrFactory member and avoid some boilerplate code

Modified: trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp (232631 => 232632)


--- trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2018-06-08 18:29:50 UTC (rev 232631)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2018-06-08 18:30:01 UTC (rev 232632)
@@ -36,6 +36,8 @@
 namespace WebKit {
     
 DisplayLink::DisplayLink(WebCore::PlatformDisplayID displayID, WebPageProxy& webPageProxy)
+    : m_connection(webPageProxy.process().connection())
+    , m_pageID(webPageProxy.pageID())
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     CVReturn error = CVDisplayLinkCreateWithCGDisplay(displayID, &m_displayLink);
@@ -44,7 +46,7 @@
         return;
     }
     
-    error = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, &webPageProxy);
+    error = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this);
     if (error) {
         WTFLogAlways("Could not set the display link output callback: %d", error);
         return;
@@ -97,11 +99,8 @@
 
 CVReturn DisplayLink::displayLinkCallback(CVDisplayLinkRef displayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data)
 {
-    WebPageProxy* webPageProxy = reinterpret_cast<WebPageProxy*>(data);
-    RunLoop::main().dispatch([weakPtr = makeWeakPtr(*webPageProxy)] {
-        if (auto* proxy = weakPtr.get())
-            proxy->process().send(Messages::DrawingArea::DisplayWasRefreshed(), proxy->pageID());
-    });
+    DisplayLink* displayLink = static_cast<DisplayLink*>(data);
+    displayLink->m_connection->send(Messages::DrawingArea::DisplayWasRefreshed(), displayLink->m_pageID);
     return kCVReturnSuccess;
 }
 

Modified: trunk/Source/WebKit/UIProcess/mac/DisplayLink.h (232631 => 232632)


--- trunk/Source/WebKit/UIProcess/mac/DisplayLink.h	2018-06-08 18:29:50 UTC (rev 232631)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayLink.h	2018-06-08 18:30:01 UTC (rev 232632)
@@ -32,6 +32,10 @@
 #include <WebCore/PlatformScreen.h>
 #include <wtf/HashSet.h>
 
+namespace IPC {
+class Connection;
+}
+
 namespace WebKit {
 
 class WebPageProxy;
@@ -53,6 +57,8 @@
     
     CVDisplayLinkRef m_displayLink { nullptr };
     HashSet<unsigned> m_observers;
+    RefPtr<IPC::Connection> m_connection;
+    uint64_t m_pageID { 0 };
 };
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to