Modified: trunk/Source/WebKit2/ChangeLog (201921 => 201922)
--- trunk/Source/WebKit2/ChangeLog 2016-06-10 12:50:14 UTC (rev 201921)
+++ trunk/Source/WebKit2/ChangeLog 2016-06-10 12:52:38 UTC (rev 201922)
@@ -1,5 +1,36 @@
2016-06-10 Carlos Garcia Campos <[email protected]>
+ [Threaded Compositor] Make it clear that compositing thread operations are always scheduled from the main thread
+ https://bugs.webkit.org/show_bug.cgi?id=158562
+
+ Reviewed by Žan Doberšek.
+
+ The code is written as if the compositor thread could also call callOnCompositingRunLoop() which makes the code
+ confusing. This patch no longer checks if the task was scheduled in the compositing thread, and instead it adds
+ an ASSERT to ensure it's always called from the main thread as expected. It also adds some more ASSERTS to ensure
+ and clarify the methods are called from the expected thread.
+
+ * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
+ (WebKit::CompositingRunLoop::performTask):
+ (WebKit::CompositingRunLoop::callOnCompositingRunLoop): Deleted.
+ * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+ (WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing):
+ (WebKit::ThreadedCompositor::setDeviceScaleFactor):
+ (WebKit::ThreadedCompositor::didChangeViewportSize):
+ (WebKit::ThreadedCompositor::didChangeViewportAttribute):
+ (WebKit::ThreadedCompositor::didChangeContentsSize):
+ (WebKit::ThreadedCompositor::scrollTo):
+ (WebKit::ThreadedCompositor::scrollBy):
+ (WebKit::ThreadedCompositor::glContext):
+ (WebKit::ThreadedCompositor::didChangeVisibleRect):
+ (WebKit::ThreadedCompositor::renderLayerTree):
+ (WebKit::ThreadedCompositor::updateSceneState):
+ (WebKit::ThreadedCompositor::callOnCompositingThread): Deleted.
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+
+2016-06-10 Carlos Garcia Campos <[email protected]>
+
[GTK] Browser plugins crash under Wayland
https://bugs.webkit.org/show_bug.cgi?id=157605
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp (201921 => 201922)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp 2016-06-10 12:50:14 UTC (rev 201921)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp 2016-06-10 12:52:38 UTC (rev 201922)
@@ -29,6 +29,7 @@
#if USE(COORDINATED_GRAPHICS_THREADED)
#include <wtf/CurrentTime.h>
+#include <wtf/MainThread.h>
namespace WebKit {
@@ -40,13 +41,9 @@
{
}
-void CompositingRunLoop::callOnCompositingRunLoop(std::function<void ()>&& function)
+void CompositingRunLoop::performTask(std::function<void ()>&& function)
{
- if (&m_runLoop == &RunLoop::current()) {
- function();
- return;
- }
-
+ ASSERT(isMainThread());
m_runLoop.dispatch(WTFMove(function));
}
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h (201921 => 201922)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h 2016-06-10 12:50:14 UTC (rev 201921)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h 2016-06-10 12:52:38 UTC (rev 201922)
@@ -46,7 +46,7 @@
CompositingRunLoop(std::function<void ()>&&);
- void callOnCompositingRunLoop(std::function<void ()>&&);
+ void performTask(std::function<void ()>&&);
void setUpdateTimer(UpdateTiming timing = Immediate);
void stopUpdateTimer();
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (201921 => 201922)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-06-10 12:50:14 UTC (rev 201921)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-06-10 12:52:38 UTC (rev 201922)
@@ -64,7 +64,7 @@
void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
{
RefPtr<ThreadedCompositor> protector(this);
- callOnCompositingThread([protector, handle] {
+ m_compositingRunLoop->performTask([protector, handle] {
protector->m_nativeSurfaceHandle = handle;
protector->m_scene->setActive(true);
});
@@ -73,7 +73,7 @@
void ThreadedCompositor::setDeviceScaleFactor(float scale)
{
RefPtr<ThreadedCompositor> protector(this);
- callOnCompositingThread([protector, scale] {
+ m_compositingRunLoop->performTask([protector, scale] {
protector->m_deviceScaleFactor = scale;
protector->scheduleDisplayImmediately();
});
@@ -82,7 +82,7 @@
void ThreadedCompositor::didChangeViewportSize(const IntSize& size)
{
RefPtr<ThreadedCompositor> protector(this);
- callOnCompositingThread([protector, size] {
+ m_compositingRunLoop->performTask([protector, size] {
protector->viewportController()->didChangeViewportSize(size);
});
}
@@ -90,7 +90,7 @@
void ThreadedCompositor::didChangeViewportAttribute(const ViewportAttributes& attr)
{
RefPtr<ThreadedCompositor> protector(this);
- callOnCompositingThread([protector, attr] {
+ m_compositingRunLoop->performTask([protector, attr] {
protector->viewportController()->didChangeViewportAttribute(attr);
});
}
@@ -98,7 +98,7 @@
void ThreadedCompositor::didChangeContentsSize(const IntSize& size)
{
RefPtr<ThreadedCompositor> protector(this);
- callOnCompositingThread([protector, size] {
+ m_compositingRunLoop->performTask([protector, size] {
protector->viewportController()->didChangeContentsSize(size);
});
}
@@ -106,7 +106,7 @@
void ThreadedCompositor::scrollTo(const IntPoint& position)
{
RefPtr<ThreadedCompositor> protector(this);
- callOnCompositingThread([protector, position] {
+ m_compositingRunLoop->performTask([protector, position] {
protector->viewportController()->scrollTo(position);
});
}
@@ -114,7 +114,7 @@
void ThreadedCompositor::scrollBy(const IntSize& delta)
{
RefPtr<ThreadedCompositor> protector(this);
- callOnCompositingThread([protector, delta] {
+ m_compositingRunLoop->performTask([protector, delta] {
protector->viewportController()->scrollBy(delta);
});
}
@@ -159,6 +159,8 @@
GLContext* ThreadedCompositor::glContext()
{
+ ASSERT(&RunLoop::current() == &m_compositingRunLoop->runLoop());
+
if (m_context)
return m_context.get();
@@ -176,6 +178,8 @@
void ThreadedCompositor::didChangeVisibleRect()
{
+ ASSERT(&RunLoop::current() == &m_compositingRunLoop->runLoop());
+
RefPtr<ThreadedCompositor> protector(this);
FloatRect visibleRect = viewportController()->visibleContentsRect();
float scale = viewportController()->pageScaleFactor();
@@ -188,6 +192,7 @@
void ThreadedCompositor::renderLayerTree()
{
+ ASSERT(&RunLoop::current() == &m_compositingRunLoop->runLoop());
if (!m_scene)
return;
@@ -208,6 +213,7 @@
void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state)
{
+ ASSERT(isMainThread());
RefPtr<CoordinatedGraphicsScene> scene = m_scene;
m_scene->appendUpdate([scene, state] {
scene->commitSceneState(state);
@@ -216,11 +222,6 @@
scheduleDisplayImmediately();
}
-void ThreadedCompositor::callOnCompositingThread(std::function<void()>&& function)
-{
- m_compositingRunLoop->callOnCompositingRunLoop(WTFMove(function));
-}
-
void ThreadedCompositor::compositingThreadEntry(void* coordinatedCompositor)
{
static_cast<ThreadedCompositor*>(coordinatedCompositor)->runCompositingThread();
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (201921 => 201922)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-06-10 12:50:14 UTC (rev 201921)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-06-10 12:52:38 UTC (rev 201922)
@@ -92,7 +92,6 @@
WebCore::GLContext* glContext();
SimpleViewportController* viewportController() { return m_viewportController.get(); }
- void callOnCompositingThread(std::function<void()>&&);
void createCompositingThread();
void runCompositingThread();
void terminateCompositingThread();