Title: [289346] branches/safari-613-branch/Source
Revision
289346
Author
[email protected]
Date
2022-02-07 18:58:00 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r289062. rdar://problem/87617695

    Crash at com.apple.WebKit: WebKit::RemoteLayerBackingStore::display
    https://bugs.webkit.org/show_bug.cgi?id=236003
    Source/WebCore:

    Patch by Kimmo Kinnunen <[email protected]> on 2022-02-03
    Reviewed by Simon Fraser.

    * platform/graphics/GraphicsLayerContentsDisplayDelegate.h:
    Add a comment not to call PlatformCALayer::setBackingStoreAttached()

    * platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm:
    Clear the PlatformCALayer contents in more explicit way.

    Source/WebKit:

    <rdar://87617695>

    Patch by Kimmo Kinnunen <[email protected]> on 2022-02-03
    Reviewed by Simon Fraser.

    Using UI-side compositing, following chain would be the cause a crash:
    PlatformCALayerRemote::recursiveBuildTransaction
    RemoteLayerBackingStore::display
    PlatformCALayer::platformCALayerLayerDisplay
    WebProcessGraphicsContextGLCocoa.mm DisplayBufferDisplayDelegate::display
    PlatformCALayer::setContents(nullptr)

    The nullptr contents happens when the WebGL context does not have
    display buffer yet or when the display buffer creation would fail.

    Setting empty layer contents would destroy the RemoteLayerBackingStore,
    even though the callstack is in process of displaying the layer to the
    backing store.

    When setting PlatformCALayer contents "empty", clear the backing store instead
    of removing the backing store.

    Tested by LayoutTests/webgl (under ASAN, ios simulator)

    * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
    * WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm:
    * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
    (WebKit::PlatformCALayerRemote::setContents):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289062 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (289345 => 289346)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:57:55 UTC (rev 289345)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:58:00 UTC (rev 289346)
@@ -1,5 +1,68 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r289062. rdar://problem/87617695
+
+    Crash at com.apple.WebKit: WebKit::RemoteLayerBackingStore::display
+    https://bugs.webkit.org/show_bug.cgi?id=236003
+    Source/WebCore:
+    
+    Patch by Kimmo Kinnunen <[email protected]> on 2022-02-03
+    Reviewed by Simon Fraser.
+    
+    * platform/graphics/GraphicsLayerContentsDisplayDelegate.h:
+    Add a comment not to call PlatformCALayer::setBackingStoreAttached()
+    
+    * platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm:
+    Clear the PlatformCALayer contents in more explicit way.
+    
+    Source/WebKit:
+    
+    <rdar://87617695>
+    
+    Patch by Kimmo Kinnunen <[email protected]> on 2022-02-03
+    Reviewed by Simon Fraser.
+    
+    Using UI-side compositing, following chain would be the cause a crash:
+    PlatformCALayerRemote::recursiveBuildTransaction
+    RemoteLayerBackingStore::display
+    PlatformCALayer::platformCALayerLayerDisplay
+    WebProcessGraphicsContextGLCocoa.mm DisplayBufferDisplayDelegate::display
+    PlatformCALayer::setContents(nullptr)
+    
+    The nullptr contents happens when the WebGL context does not have
+    display buffer yet or when the display buffer creation would fail.
+    
+    Setting empty layer contents would destroy the RemoteLayerBackingStore,
+    even though the callstack is in process of displaying the layer to the
+    backing store.
+    
+    When setting PlatformCALayer contents "empty", clear the backing store instead
+    of removing the backing store.
+    
+    Tested by LayoutTests/webgl (under ASAN, ios simulator)
+    
+    * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+    * WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm:
+    * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+    (WebKit::PlatformCALayerRemote::setContents):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289062 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-03  Kimmo Kinnunen  <[email protected]>
+
+            Crash at com.apple.WebKit: WebKit::RemoteLayerBackingStore::display
+            https://bugs.webkit.org/show_bug.cgi?id=236003
+
+            Reviewed by Simon Fraser.
+
+            * platform/graphics/GraphicsLayerContentsDisplayDelegate.h:
+            Add a comment not to call PlatformCALayer::setBackingStoreAttached()
+
+            * platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm:
+            Clear the PlatformCALayer contents in more explicit way.
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r289060. rdar://problem/86337125
 
     null ptr deref in RenderTreeBuilder::Block::attachIgnoringContinuation

Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/GraphicsLayerContentsDisplayDelegate.h (289345 => 289346)


--- branches/safari-613-branch/Source/WebCore/platform/graphics/GraphicsLayerContentsDisplayDelegate.h	2022-02-08 02:57:55 UTC (rev 289345)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/GraphicsLayerContentsDisplayDelegate.h	2022-02-08 02:58:00 UTC (rev 289346)
@@ -45,6 +45,7 @@
 
 #if USE(CA)
     virtual void prepareToDelegateDisplay(PlatformCALayer&);
+    // Must not detach the platform layer backing store.
     virtual void display(PlatformCALayer&) = 0;
     virtual GraphicsLayer::CompositingCoordinatesOrientation orientation() const;
 #else

Modified: branches/safari-613-branch/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm (289345 => 289346)


--- branches/safari-613-branch/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm	2022-02-08 02:57:55 UTC (rev 289345)
+++ branches/safari-613-branch/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm	2022-02-08 02:58:00 UTC (rev 289346)
@@ -58,7 +58,7 @@
         if (m_displayBuffer)
             layer.setContents(*m_displayBuffer);
         else
-            layer.setContents(nullptr);
+            layer.clearContents();
     }
 
     GraphicsLayer::CompositingCoordinatesOrientation orientation() const final

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (289345 => 289346)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:57:55 UTC (rev 289345)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:58:00 UTC (rev 289346)
@@ -1,5 +1,87 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r289062. rdar://problem/87617695
+
+    Crash at com.apple.WebKit: WebKit::RemoteLayerBackingStore::display
+    https://bugs.webkit.org/show_bug.cgi?id=236003
+    Source/WebCore:
+    
+    Patch by Kimmo Kinnunen <[email protected]> on 2022-02-03
+    Reviewed by Simon Fraser.
+    
+    * platform/graphics/GraphicsLayerContentsDisplayDelegate.h:
+    Add a comment not to call PlatformCALayer::setBackingStoreAttached()
+    
+    * platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm:
+    Clear the PlatformCALayer contents in more explicit way.
+    
+    Source/WebKit:
+    
+    <rdar://87617695>
+    
+    Patch by Kimmo Kinnunen <[email protected]> on 2022-02-03
+    Reviewed by Simon Fraser.
+    
+    Using UI-side compositing, following chain would be the cause a crash:
+    PlatformCALayerRemote::recursiveBuildTransaction
+    RemoteLayerBackingStore::display
+    PlatformCALayer::platformCALayerLayerDisplay
+    WebProcessGraphicsContextGLCocoa.mm DisplayBufferDisplayDelegate::display
+    PlatformCALayer::setContents(nullptr)
+    
+    The nullptr contents happens when the WebGL context does not have
+    display buffer yet or when the display buffer creation would fail.
+    
+    Setting empty layer contents would destroy the RemoteLayerBackingStore,
+    even though the callstack is in process of displaying the layer to the
+    backing store.
+    
+    When setting PlatformCALayer contents "empty", clear the backing store instead
+    of removing the backing store.
+    
+    Tested by LayoutTests/webgl (under ASAN, ios simulator)
+    
+    * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+    * WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm:
+    * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+    (WebKit::PlatformCALayerRemote::setContents):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289062 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-03  Kimmo Kinnunen  <[email protected]>
+
+            Crash at com.apple.WebKit: WebKit::RemoteLayerBackingStore::display
+            https://bugs.webkit.org/show_bug.cgi?id=236003
+            <rdar://87617695>
+
+            Reviewed by Simon Fraser.
+
+            Using UI-side compositing, following chain would be the cause a crash:
+            PlatformCALayerRemote::recursiveBuildTransaction
+            RemoteLayerBackingStore::display
+            PlatformCALayer::platformCALayerLayerDisplay
+            WebProcessGraphicsContextGLCocoa.mm DisplayBufferDisplayDelegate::display
+            PlatformCALayer::setContents(nullptr)
+
+            The nullptr contents happens when the WebGL context does not have
+            display buffer yet or when the display buffer creation would fail.
+
+            Setting empty layer contents would destroy the RemoteLayerBackingStore,
+            even though the callstack is in process of displaying the layer to the
+            backing store.
+
+            When setting PlatformCALayer contents "empty", clear the backing store instead
+            of removing the backing store.
+
+            Tested by LayoutTests/webgl (under ASAN, ios simulator)
+
+            * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+            * WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm:
+            * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+            (WebKit::PlatformCALayerRemote::setContents):
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r289052. rdar://problem/88382949
 
     [GPUP] Add read access to sysctl properties

Modified: branches/safari-613-branch/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h (289345 => 289346)


--- branches/safari-613-branch/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-02-08 02:57:55 UTC (rev 289345)
+++ branches/safari-613-branch/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h	2022-02-08 02:58:00 UTC (rev 289346)
@@ -100,9 +100,10 @@
 
     MonotonicTime lastDisplayTime() const { return m_lastDisplayTime; }
 
+    void clearBackingStore();
+
 private:
     void drawInContext(WebCore::GraphicsContext&);
-    void clearBackingStore();
     void swapToValidFrontBuffer();
 
     bool supportsPartialRepaint();

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm (289345 => 289346)


--- branches/safari-613-branch/Source/WebKit/WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm	2022-02-08 02:57:55 UTC (rev 289345)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/GPU/graphics/cocoa/RemoteGraphicsContextGLProxyCocoa.mm	2022-02-08 02:58:00 UTC (rev 289346)
@@ -60,7 +60,7 @@
         if (m_displayBuffer)
             layer.setContents(m_displayBuffer);
         else
-            layer.setContents(nullptr);
+            layer.clearContents();
     }
 
     WebCore::GraphicsLayer::CompositingCoordinatesOrientation orientation() const final

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp (289345 => 289346)


--- branches/safari-613-branch/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2022-02-08 02:57:55 UTC (rev 289345)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2022-02-08 02:58:00 UTC (rev 289346)
@@ -683,8 +683,10 @@
 
 void PlatformCALayerRemote::setContents(CFTypeRef value)
 {
+    if (!m_properties.backingStore)
+        return;
     if (!value)
-        m_properties.backingStore = nullptr;
+        m_properties.backingStore->clearBackingStore();
 }
 
 #if HAVE(IOSURFACE)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to