Changeset 102611 in webkit


Ignore:
Timestamp:
Dec 12, 2011 12:53:30 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Remove assumption that empty surface is always at end of list
https://bugs.webkit.org/show_bug.cgi?id=74037

Patch by Shawn Singh <shawnsingh@chromium.org> on 2011-12-12
Reviewed by James Robinson.

Source/WebCore:

Test case added to CCLayerTreeHostCommonTest.cpp, which reproduces
a crash reported in http://code.google.com/p/chromium/issues/detail?id=106734

This patch fixes the crash in a less risky way to be merged into
m17, but the root of the issue needs to be addressed in a
follow-up patch.

  • platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:

(WebCore::calculateDrawTransformsAndVisibilityInternal):

Source/WebKit/chromium:

  • tests/CCLayerTreeHostCommonTest.cpp:

(WebCore::TEST):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102608 r102611  
     12011-12-12  Shawn Singh  <shawnsingh@chromium.org>
     2
     3        [chromium] Remove assumption that empty surface is always at end of list
     4        https://bugs.webkit.org/show_bug.cgi?id=74037
     5
     6        Reviewed by James Robinson.
     7
     8        Test case added to CCLayerTreeHostCommonTest.cpp, which reproduces
     9        a crash reported in http://code.google.com/p/chromium/issues/detail?id=106734
     10
     11        This patch fixes the crash in a less risky way to be merged into
     12        m17, but the root of the issue needs to be addressed in a
     13        follow-up patch.
     14
     15        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
     16        (WebCore::calculateDrawTransformsAndVisibilityInternal):
     17
    1182011-12-12  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp

    r101702 r102611  
    435435        }
    436436
    437         // If a render surface has no layer list, then it and none of its
    438         // children needed to get drawn. Therefore, it should be the last layer
    439         // in the render surface list and we can trivially remove it.
     437        // If a render surface has no layer list, then it and none of its children needed to get drawn.
    440438        if (!layer->renderSurface()->layerList().size()) {
     439            // FIXME: Originally we asserted that this layer was already at the end of the
     440            //        list, and only needed to remove that layer. For now, we remove the
     441            //        entire subtree of surfaces to fix a crash bug. The root cause is
     442            //        https://bugs.webkit.org/show_bug.cgi?id=74147 and we should be able
     443            //        to put the original assert after fixing that.
     444            while (renderSurfaceLayerList.last() != layer) {
     445                renderSurfaceLayerList.last()->clearRenderSurface();
     446                renderSurfaceLayerList.removeLast();
     447            }
    441448            ASSERT(renderSurfaceLayerList.last() == layer);
    442449            renderSurfaceLayerList.removeLast();
  • trunk/Source/WebKit/chromium/ChangeLog

    r102610 r102611  
     12011-12-12  Shawn Singh  <shawnsingh@chromium.org>
     2
     3        [chromium] Remove assumption that empty surface is always at end of list
     4        https://bugs.webkit.org/show_bug.cgi?id=74037
     5
     6        Reviewed by James Robinson.
     7
     8        * tests/CCLayerTreeHostCommonTest.cpp:
     9        (WebCore::TEST):
     10
    1112011-12-09  Daniel Cheng  <dcheng@chromium.org>
    212
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp

    r101702 r102611  
    510510}
    511511
     512TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces)
     513{
     514    // The entire subtree of layers that are outside the clipRect should be culled away,
     515    // and should not affect the renderSurfaceLayerList.
     516    //
     517    // The test tree is set up as follows:
     518    //  - all layers except the leafNodes are forced to be a new renderSurface that have something to draw.
     519    //  - parent is a large container layer.
     520    //  - child has masksToBounds=true to cause clipping.
     521    //  - grandChild is positioned outside of the child's bounds
     522    //  - greatGrandChild is also kept outside child's bounds.
     523    //
     524    // In this configuration, grandChild and greatGrandChild are completely outside the
     525    // clipRect, and they should never get scheduled on the list of renderSurfaces.
     526    //
     527
     528    const TransformationMatrix identityMatrix;
     529    RefPtr<LayerChromium> parent = LayerChromium::create(0);
     530    RefPtr<LayerChromium> child = LayerChromium::create(0);
     531    RefPtr<LayerChromium> grandChild = LayerChromium::create(0);
     532    RefPtr<LayerChromium> greatGrandChild = LayerChromium::create(0);
     533    RefPtr<LayerChromiumWithForcedDrawsContent> leafNode1 = adoptRef(new LayerChromiumWithForcedDrawsContent(0));
     534    RefPtr<LayerChromiumWithForcedDrawsContent> leafNode2 = adoptRef(new LayerChromiumWithForcedDrawsContent(0));
     535    parent->createRenderSurface();
     536    parent->addChild(child);
     537    child->addChild(grandChild);
     538    grandChild->addChild(greatGrandChild);
     539
     540    // leafNode1 ensures that parent and child are kept on the renderSurfaceLayerList,
     541    // even though grandChild and greatGrandChild should be clipped.
     542    child->addChild(leafNode1);
     543    greatGrandChild->addChild(leafNode2);
     544
     545    setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false);
     546    setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false);
     547    setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(45, 45), IntSize(10, 10), false);
     548    setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false);
     549    setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false);
     550    setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false);
     551
     552    child->setMasksToBounds(true);
     553    child->setOpacity(0.4);
     554    grandChild->setOpacity(0.5);
     555    greatGrandChild->setOpacity(0.4);
     556
     557    // Contaminate the grandChild and greatGrandChild's clipRect to reproduce the crash
     558    // bug found in http://code.google.com/p/chromium/issues/detail?id=106734. In this
     559    // bug, the clipRect was not re-computed for layers that create RenderSurfaces, and
     560    // therefore leafNode2 thinks it should draw itself. As a result, an extra
     561    // renderSurface remains on the renderSurfaceLayerList, which violates the assumption
     562    // that an empty renderSurface will always be the last item on the list, which
     563    // ultimately caused the crash.
     564    //
     565    // FIXME: it is also useful to test with this commented out. Eventually we should
     566    // create several test cases that test clipRect/drawableContentRect computation.
     567    child->setClipRect(IntRect(IntPoint::zero(), IntSize(20, 20)));
     568    greatGrandChild->setClipRect(IntRect(IntPoint::zero(), IntSize(1234, 1234)));
     569
     570    Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
     571    Vector<RefPtr<LayerChromium> > dummyLayerList;
     572    int dummyMaxTextureSize = 512;
     573
     574    // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too.
     575    parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds()));
     576    renderSurfaceLayerList.append(parent);
     577
     578    CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);
     579
     580    ASSERT_EQ(2U, renderSurfaceLayerList.size());
     581    EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
     582    EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id());
     583}
     584
    512585// FIXME:
    513586// continue working on https://bugs.webkit.org/show_bug.cgi?id=68942
Note: See TracChangeset for help on using the changeset viewer.