Title: [125770] trunk/Source
Revision
125770
Author
[email protected]
Date
2012-08-16 05:12:36 -0700 (Thu, 16 Aug 2012)

Log Message

[BlackBerry] WebGL and Canvas fail to display after being restored from page cache
https://bugs.webkit.org/show_bug.cgi?id=94105

Patch by Arvid Nilsson <[email protected]> on 2012-08-16
Reviewed by George Staikos.

The EGLImage was being destroyed when releasing layer resources on the
compositing thread, but the WebKit thread layer never found out and
failed to create a new image.

Fixed by extending the release layer resources mechanism to also make a
pass on the WebKit thread so that thread's layers have a chance to
delete their textures and related resources.

Source/WebCore:

WebGL and canvas layers now take this opportunity to release their
textures so the EGLImage gets recreated when compositing commits
resume.

The only detail that deserves extra explanation is the ownership of the
EGLImage.

Since the EGLImage is created in updateTextureContentsIfNeeded() and
that one is always followed by commitPendingTextureUploads() which
transfers the EGLImage to the compositing thread layer's custody, the
EGLImage currently referenced by EGLImageLayerWebKitThread::m_image
should never be deleted by the WebKit thread layer.

Thus all we have to do in deleteFrontBuffer() is to set the m_image
member to 0 so the image gets recreated on the next commit. It will be
deleted by the part of releaseLayerResources() that executes on the
compositing thread (which, if you recall, was the original source of
this bug).

Reviewed internally by Filip Spacek.

PR 192899

Not currently testable by the BlackBerry testing infrastructure.

* platform/graphics/blackberry/CanvasLayerWebKitThread.cpp:
(WebCore::CanvasLayerWebKitThread::deleteTextures):
(WebCore):
* platform/graphics/blackberry/CanvasLayerWebKitThread.h:
(CanvasLayerWebKitThread):
* platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp:
(WebCore::EGLImageLayerWebKitThread::~EGLImageLayerWebKitThread):
(WebCore::EGLImageLayerWebKitThread::deleteFrontBuffer):
* platform/graphics/blackberry/EGLImageLayerWebKitThread.h:
(EGLImageLayerWebKitThread):
* platform/graphics/blackberry/LayerWebKitThread.cpp:
(WebCore::LayerWebKitThread::releaseLayerResources):
(WebCore):
* platform/graphics/blackberry/LayerWebKitThread.h:
(LayerWebKitThread):
(WebCore::LayerWebKitThread::deleteTextures):
* platform/graphics/blackberry/WebGLLayerWebKitThread.cpp:
(WebCore::WebGLLayerWebKitThread::~WebGLLayerWebKitThread):
(WebCore::WebGLLayerWebKitThread::deleteTextures):
(WebCore):
* platform/graphics/blackberry/WebGLLayerWebKitThread.h:
(WebGLLayerWebKitThread):

Source/WebKit/blackberry:

Reviewed internally by Filip Spacek.

PR 192899

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::setLoadState):
(BlackBerry::WebKit::WebPagePrivate::releaseLayerResources):
(WebKit):
(BlackBerry::WebKit::WebPagePrivate::releaseLayerResourcesCompositingThread):
(BlackBerry::WebKit::WebPagePrivate::suspendRootLayerCommit):
* Api/WebPage_p.h:
(WebPagePrivate):
* WebKitSupport/FrameLayers.cpp:
(BlackBerry::WebKit::FrameLayers::releaseLayerResources):
(WebKit):
* WebKitSupport/FrameLayers.h:
(FrameLayers):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125769 => 125770)


--- trunk/Source/WebCore/ChangeLog	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/ChangeLog	2012-08-16 12:12:36 UTC (rev 125770)
@@ -1,3 +1,66 @@
+2012-08-16  Arvid Nilsson  <[email protected]>
+
+        [BlackBerry] WebGL and Canvas fail to display after being restored from page cache
+        https://bugs.webkit.org/show_bug.cgi?id=94105
+
+        Reviewed by George Staikos.
+
+        The EGLImage was being destroyed when releasing layer resources on the
+        compositing thread, but the WebKit thread layer never found out and
+        failed to create a new image.
+
+        Fixed by extending the release layer resources mechanism to also make a
+        pass on the WebKit thread so that thread's layers have a chance to
+        delete their textures and related resources.
+
+        WebGL and canvas layers now take this opportunity to release their
+        textures so the EGLImage gets recreated when compositing commits
+        resume.
+
+        The only detail that deserves extra explanation is the ownership of the
+        EGLImage.
+
+        Since the EGLImage is created in updateTextureContentsIfNeeded() and
+        that one is always followed by commitPendingTextureUploads() which
+        transfers the EGLImage to the compositing thread layer's custody, the
+        EGLImage currently referenced by EGLImageLayerWebKitThread::m_image
+        should never be deleted by the WebKit thread layer.
+
+        Thus all we have to do in deleteFrontBuffer() is to set the m_image
+        member to 0 so the image gets recreated on the next commit. It will be
+        deleted by the part of releaseLayerResources() that executes on the
+        compositing thread (which, if you recall, was the original source of
+        this bug).
+
+        Reviewed internally by Filip Spacek.
+
+        PR 192899
+
+        Not currently testable by the BlackBerry testing infrastructure.
+
+        * platform/graphics/blackberry/CanvasLayerWebKitThread.cpp:
+        (WebCore::CanvasLayerWebKitThread::deleteTextures):
+        (WebCore):
+        * platform/graphics/blackberry/CanvasLayerWebKitThread.h:
+        (CanvasLayerWebKitThread):
+        * platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp:
+        (WebCore::EGLImageLayerWebKitThread::~EGLImageLayerWebKitThread):
+        (WebCore::EGLImageLayerWebKitThread::deleteFrontBuffer):
+        * platform/graphics/blackberry/EGLImageLayerWebKitThread.h:
+        (EGLImageLayerWebKitThread):
+        * platform/graphics/blackberry/LayerWebKitThread.cpp:
+        (WebCore::LayerWebKitThread::releaseLayerResources):
+        (WebCore):
+        * platform/graphics/blackberry/LayerWebKitThread.h:
+        (LayerWebKitThread):
+        (WebCore::LayerWebKitThread::deleteTextures):
+        * platform/graphics/blackberry/WebGLLayerWebKitThread.cpp:
+        (WebCore::WebGLLayerWebKitThread::~WebGLLayerWebKitThread):
+        (WebCore::WebGLLayerWebKitThread::deleteTextures):
+        (WebCore):
+        * platform/graphics/blackberry/WebGLLayerWebKitThread.h:
+        (WebGLLayerWebKitThread):
+
 2012-08-16  Andrey Kosyakov  <[email protected]>
 
         Web Inspector: enable instrumentation of platform code

Modified: trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp	2012-08-16 12:12:36 UTC (rev 125770)
@@ -64,6 +64,12 @@
     updateFrontBuffer(IntSize(m_device->width(), m_device->height()), texture->getTextureHandle());
 }
 
+void CanvasLayerWebKitThread::deleteTextures()
+{
+    if (SharedGraphicsContext3D::get()->makeContextCurrent())
+        deleteFrontBuffer();
 }
 
+}
+
 #endif // USE(ACCELERATED_COMPOSITING) && ENABLE(ACCELERATED_2D_CANVAS)

Modified: trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h	2012-08-16 12:12:36 UTC (rev 125770)
@@ -42,6 +42,7 @@
 
 protected:
     virtual void updateTextureContentsIfNeeded();
+    virtual void deleteTextures();
 
 private:
     CanvasLayerWebKitThread(SkGpuDevice*);

Modified: trunk/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp	2012-08-16 12:12:36 UTC (rev 125770)
@@ -59,6 +59,7 @@
     ASSERT(!m_frontBufferTexture);
     ASSERT(!m_fbo);
     ASSERT(!m_shader);
+    ASSERT(!m_image);
 }
 
 void EGLImageLayerWebKitThread::setNeedsDisplay()
@@ -124,6 +125,13 @@
     m_fbo = 0;
     glDeleteShader(m_shader);
     m_shader = 0;
+
+    // The image is in our EGLImageLayerCompositingThreadClient's custody
+    // at this point, and that object is responsible for deleting it.
+    m_image = 0;
+
+    // If anyone tries to render us after this, we're certainly going to need display.
+    m_needsDisplay = true;
 }
 
 void EGLImageLayerWebKitThread::commitPendingTextureUploads()

Modified: trunk/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h	2012-08-16 12:12:36 UTC (rev 125770)
@@ -41,6 +41,7 @@
 
     virtual void updateTextureContentsIfNeeded() = 0;
     virtual void commitPendingTextureUploads();
+    virtual void deleteTextures() = 0;
 
     // The context must be current before you call any of these
     void updateFrontBuffer(const IntSize&, unsigned backBufferTexture);

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp	2012-08-16 12:12:36 UTC (rev 125770)
@@ -517,6 +517,21 @@
     setNeedsCommit();
 }
 
+void LayerWebKitThread::releaseLayerResources()
+{
+    deleteTextures();
+
+    size_t listSize = m_sublayers.size();
+    for (size_t i = 0; i < listSize; i++)
+        m_sublayers[i]->releaseLayerResources();
+
+    if (maskLayer())
+        maskLayer()->releaseLayerResources();
+
+    if (replicaLayer())
+        replicaLayer()->releaseLayerResources();
 }
 
+}
+
 #endif // USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h	2012-08-16 12:12:36 UTC (rev 125770)
@@ -160,6 +160,8 @@
     // Allows you to clear the LayerCompositingThread::overrides from the WK thread
     void clearOverride() { m_clearOverrideOnCommit = true; setNeedsCommit(); }
 
+    void releaseLayerResources();
+
 protected:
     LayerWebKitThread(LayerType, GraphicsLayerBlackBerry* owner);
 
@@ -174,6 +176,7 @@
     virtual void boundsChanged() { }
     virtual void updateTextureContentsIfNeeded();
     virtual void commitPendingTextureUploads();
+    virtual void deleteTextures() { }
 
 private:
     void updateLayerHierarchy();

Modified: trunk/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp	2012-08-16 12:12:36 UTC (rev 125770)
@@ -34,7 +34,7 @@
 
 WebGLLayerWebKitThread::~WebGLLayerWebKitThread()
 {
-    if (m_webGLContext->makeContextCurrent())
+    if (m_webGLContext && m_webGLContext->makeContextCurrent())
         deleteFrontBuffer();
 }
 
@@ -48,6 +48,12 @@
     updateFrontBuffer(m_webGLContext->getInternalFramebufferSize(), m_webGLContext->platformTexture());
 }
 
+void WebGLLayerWebKitThread::deleteTextures()
+{
+    if (m_webGLContext && m_webGLContext->makeContextCurrent())
+        deleteFrontBuffer();
+}
+
 } // namespace WebCore
 
 #endif // USE(ACCELERATED_COMPOSITING) && ENABLE(WEBGL)

Modified: trunk/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h (125769 => 125770)


--- trunk/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h	2012-08-16 12:12:36 UTC (rev 125770)
@@ -40,6 +40,7 @@
 
 protected:
     virtual void updateTextureContentsIfNeeded();
+    virtual void deleteTextures();
 
 private:
     WebGLLayerWebKitThread();

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (125769 => 125770)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-08-16 12:12:36 UTC (rev 125770)
@@ -1041,11 +1041,9 @@
 #endif
 
 #if USE(ACCELERATED_COMPOSITING)
-            if (isAcceleratedCompositingActive()) {
-                Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
-                    Platform::createMethodCallMessage(&WebPagePrivate::destroyLayerResources, this));
-            }
+            releaseLayerResources();
 #endif
+
             // Suspend screen update to avoid ui thread blitting while resetting backingstore.
             m_backingStore->d->suspendScreenAndBackingStoreUpdates();
 
@@ -5912,8 +5910,20 @@
             &WebPagePrivate::destroyCompositor, this));
 }
 
-void WebPagePrivate::destroyLayerResources()
+void WebPagePrivate::releaseLayerResources()
 {
+    if (!isAcceleratedCompositingActive())
+        return;
+
+    if (m_frameLayers)
+        m_frameLayers->releaseLayerResources();
+
+    Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
+        Platform::createMethodCallMessage(&WebPagePrivate::releaseLayerResourcesCompositingThread, this));
+}
+
+void WebPagePrivate::releaseLayerResourcesCompositingThread()
+{
      m_compositor->releaseLayerResources();
 }
 
@@ -5927,8 +5937,7 @@
     if (!m_compositor)
         return;
 
-    Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
-        Platform::createMethodCallMessage(&WebPagePrivate::destroyLayerResources, this));
+    releaseLayerResources();
 }
 
 void WebPagePrivate::resumeRootLayerCommit()

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (125769 => 125770)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-08-16 12:12:36 UTC (rev 125770)
@@ -419,7 +419,8 @@
     bool createCompositor();
     void destroyCompositor();
     void syncDestroyCompositorOnCompositingThread();
-    void destroyLayerResources();
+    void releaseLayerResources();
+    void releaseLayerResourcesCompositingThread();
     void suspendRootLayerCommit();
     void resumeRootLayerCommit();
     void blitVisibleContents();

Modified: trunk/Source/WebKit/blackberry/ChangeLog (125769 => 125770)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-08-16 12:12:36 UTC (rev 125770)
@@ -1,3 +1,36 @@
+2012-08-16  Arvid Nilsson  <[email protected]>
+
+        [BlackBerry] WebGL and Canvas fail to display after being restored from page cache
+        https://bugs.webkit.org/show_bug.cgi?id=94105
+
+        Reviewed by George Staikos.
+
+        The EGLImage was being destroyed when releasing layer resources on the
+        compositing thread, but the WebKit thread layer never found out and
+        failed to create a new image.
+
+        Fixed by extending the release layer resources mechanism to also make a
+        pass on the WebKit thread so that thread's layers have a chance to
+        delete their textures and related resources.
+
+        Reviewed internally by Filip Spacek.
+
+        PR 192899
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::setLoadState):
+        (BlackBerry::WebKit::WebPagePrivate::releaseLayerResources):
+        (WebKit):
+        (BlackBerry::WebKit::WebPagePrivate::releaseLayerResourcesCompositingThread):
+        (BlackBerry::WebKit::WebPagePrivate::suspendRootLayerCommit):
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+        * WebKitSupport/FrameLayers.cpp:
+        (BlackBerry::WebKit::FrameLayers::releaseLayerResources):
+        (WebKit):
+        * WebKitSupport/FrameLayers.h:
+        (FrameLayers):
+
 2012-08-16  Pierre Rossi  <[email protected]>
 
         [Qt] Remove FontQt4, HAVE_QRAWFONT flag and the related dead code

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/FrameLayers.cpp (125769 => 125770)


--- trunk/Source/WebKit/blackberry/WebKitSupport/FrameLayers.cpp	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/FrameLayers.cpp	2012-08-16 12:12:36 UTC (rev 125770)
@@ -119,6 +119,12 @@
         m_rootLayer = 0;
 }
 
+void FrameLayers::releaseLayerResources()
+{
+    if (m_rootLayer)
+        m_rootLayer->releaseLayerResources();
+}
+
 } // namespace BlackBerry
 } // namespace WebKit
 

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/FrameLayers.h (125769 => 125770)


--- trunk/Source/WebKit/blackberry/WebKitSupport/FrameLayers.h	2012-08-16 12:06:20 UTC (rev 125769)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/FrameLayers.h	2012-08-16 12:12:36 UTC (rev 125770)
@@ -57,6 +57,8 @@
     // But it's now also being called on the Compositing thread.
     WebCore::LayerWebKitThread* rootLayer() const { return m_rootLayer; }
 
+    void releaseLayerResources();
+
 private:
     WebPagePrivate* m_pagePrivate;
     OwnPtr<WebCore::GraphicsLayer> m_rootGraphicsLayer;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to