Title: [202040] trunk/Source/WebKit2
- Revision
- 202040
- Author
- [email protected]
- Date
- 2016-06-14 02:58:06 -0700 (Tue, 14 Jun 2016)
Log Message
[ThreadedCompositor] Opening the inspector in a window causes a crash.
https://bugs.webkit.org/show_bug.cgi?id=154444
Reviewed by Žan Doberšek.
The threaded compositor doesn't handle the case of changing or removing the native surface handle. When the web
view is reparented, the current native surface handle is destroyed when the view is removed from the parent, and
a new one is created when added to the new parent. We need to handle this case in the threaded compositor.
* Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
(WebKit::CompositingRunLoop::stopUpdateTimer): Allow users to stop the update timer.
* Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Use performTaskSync because this is called
from a synchronous IPC message and right after it returns, the current native surface is destroyed by the UI
process. So we need to ensure we finish all pending operations for the current native surface in the compositing
thread before it's destroyed. Then we enable or disable the scene depending on whether the native surface has
been created or destroyed and destroy the current context in case the new handle is 0.
(WebKit::ThreadedCompositor::tryEnsureGLContext): Just renamed to make it clear that it can fail.
(WebKit::ThreadedCompositor::glContext):
(WebKit::ThreadedCompositor::renderLayerTree): Return early if scene is not active.
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing): Schedule a new layer flush
after the native surface handle changed.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (202039 => 202040)
--- trunk/Source/WebKit2/ChangeLog 2016-06-14 08:08:43 UTC (rev 202039)
+++ trunk/Source/WebKit2/ChangeLog 2016-06-14 09:58:06 UTC (rev 202040)
@@ -1,5 +1,32 @@
2016-06-14 Carlos Garcia Campos <[email protected]>
+ [ThreadedCompositor] Opening the inspector in a window causes a crash.
+ https://bugs.webkit.org/show_bug.cgi?id=154444
+
+ Reviewed by Žan Doberšek.
+
+ The threaded compositor doesn't handle the case of changing or removing the native surface handle. When the web
+ view is reparented, the current native surface handle is destroyed when the view is removed from the parent, and
+ a new one is created when added to the new parent. We need to handle this case in the threaded compositor.
+
+ * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
+ (WebKit::CompositingRunLoop::stopUpdateTimer): Allow users to stop the update timer.
+ * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+ (WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing): Use performTaskSync because this is called
+ from a synchronous IPC message and right after it returns, the current native surface is destroyed by the UI
+ process. So we need to ensure we finish all pending operations for the current native surface in the compositing
+ thread before it's destroyed. Then we enable or disable the scene depending on whether the native surface has
+ been created or destroyed and destroy the current context in case the new handle is 0.
+ (WebKit::ThreadedCompositor::tryEnsureGLContext): Just renamed to make it clear that it can fail.
+ (WebKit::ThreadedCompositor::glContext):
+ (WebKit::ThreadedCompositor::renderLayerTree): Return early if scene is not active.
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+ (WebKit::ThreadedCoordinatedLayerTreeHost::setNativeSurfaceHandleForCompositing): Schedule a new layer flush
+ after the native surface handle changed.
+
+2016-06-14 Carlos Garcia Campos <[email protected]>
+
[Threaded Compositor] Modernize and simplify threaded compositor code
https://bugs.webkit.org/show_bug.cgi?id=158615
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp (202039 => 202040)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp 2016-06-14 08:08:43 UTC (rev 202039)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp 2016-06-14 09:58:06 UTC (rev 202040)
@@ -71,6 +71,11 @@
m_updateTimer.startOneShot(nextUpdateTime);
}
+void CompositingRunLoop::stopUpdateTimer()
+{
+ m_updateTimer.stop();
+}
+
void CompositingRunLoop::updateTimerFired()
{
m_updateFunction();
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h (202039 => 202040)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h 2016-06-14 08:08:43 UTC (rev 202039)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h 2016-06-14 09:58:06 UTC (rev 202040)
@@ -50,6 +50,7 @@
void performTaskSync(NoncopyableFunction<void ()>&&);
void startUpdateTimer(UpdateTiming = Immediate);
+ void stopUpdateTimer();
void run();
void stop();
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (202039 => 202040)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-06-14 08:08:43 UTC (rev 202039)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2016-06-14 09:58:06 UTC (rev 202040)
@@ -61,9 +61,15 @@
void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
{
- m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), handle] {
+ m_compositingRunLoop->stopUpdateTimer();
+ m_compositingRunLoop->performTaskSync([this, protectedThis = Ref<ThreadedCompositor>(*this), handle] {
+ m_scene->setActive(!!handle);
+
+ // A new native handle can't be set without destroying the previous one first if any.
+ ASSERT(!!handle ^ !!m_nativeSurfaceHandle);
m_nativeSurfaceHandle = handle;
- m_scene->setActive(true);
+ if (!m_nativeSurfaceHandle)
+ m_context = nullptr;
});
}
@@ -130,7 +136,7 @@
m_client->commitScrollOffset(layerID, offset);
}
-bool ThreadedCompositor::ensureGLContext()
+bool ThreadedCompositor::tryEnsureGLContext()
{
if (!glContext())
return false;
@@ -156,7 +162,7 @@
return m_context.get();
if (!m_nativeSurfaceHandle)
- return 0;
+ return nullptr;
m_context = GLContext::createContextForWindow(reinterpret_cast<GLNativeWindowType>(m_nativeSurfaceHandle), GLContext::sharingContext());
return m_context.get();
@@ -181,10 +187,10 @@
void ThreadedCompositor::renderLayerTree()
{
ASSERT(&RunLoop::current() == &m_compositingRunLoop->runLoop());
- if (!m_scene)
+ if (!m_scene || !m_scene->isActive())
return;
- if (!ensureGLContext())
+ if (!tryEnsureGLContext())
return;
FloatRect clipRect(0, 0, m_viewportSize.width(), m_viewportSize.height());
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (202039 => 202040)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-06-14 08:08:43 UTC (rev 202039)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2016-06-14 09:58:06 UTC (rev 202040)
@@ -88,7 +88,7 @@
void scheduleDisplayImmediately();
void didChangeVisibleRect() override;
- bool ensureGLContext();
+ bool tryEnsureGLContext();
WebCore::GLContext* glContext();
void createCompositingThread();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (202039 => 202040)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-06-14 08:08:43 UTC (rev 202039)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2016-06-14 09:58:06 UTC (rev 202040)
@@ -198,6 +198,7 @@
{
m_layerTreeContext.contextID = handle;
m_compositor->setNativeSurfaceHandleForCompositing(handle);
+ scheduleLayerFlush();
}
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes