Changeset 112178 in webkit


Ignore:
Timestamp:
Mar 26, 2012 5:09:12 PM (12 years ago)
Author:
fsamuel@chromium.org
Message:

[Chromium] Using WebViewPlugins with --force-compositing-mode causes an ASSERT to fail
https://bugs.webkit.org/show_bug.cgi?id=81954

Reviewed by James Robinson.

A static variable s_inPaintContents is set when painting, and it ensures
that we don't delete GraphicsLayers or create GraphicsLayers while painting.

However, because this variable is static, it does not permit the existence
of multiple WebViews in different stages (one laying out and one painting).

This manifests itself if one attempts to use the --force-compositing-mode
in Chromium and attempts to navigate to a page with a missing or old plugin
or a browser plugin (which uses a WebViewPlugin as a placeholder until it's
done loading).

The solution to simplify debugging is to make this flag per-Page.
We can access Page from RenderLayerBacking which is a GraphicsLayerClient.
We add a new method GraphicsLayerClient::verifyNotPainting with a default
(do nothing) implementation and override it in RenderLayerBacking to
test the flag set in Page.

  • page/Page.cpp:

(WebCore::Page::Page):

  • page/Page.h:

(Page):
(WebCore::Page::setIsPainting):
(WebCore::Page::isPainting):

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::GraphicsLayer::GraphicsLayer):
(WebCore::GraphicsLayer::~GraphicsLayer):
(WebCore::GraphicsLayer::paintGraphicsLayerContents):

  • platform/graphics/GraphicsLayerClient.h:

(GraphicsLayerClient):
(WebCore::GraphicsLayerClient::verifyNotPainting):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::paintContents):
(WebCore):
(WebCore::RenderLayerBacking::verifyNotPainting):

  • rendering/RenderLayerBacking.h:

(RenderLayerBacking):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112177 r112178  
     12012-03-26  Fady Samuel  <fsamuel@chromium.org>
     2
     3        [Chromium] Using WebViewPlugins with --force-compositing-mode causes an ASSERT to fail
     4        https://bugs.webkit.org/show_bug.cgi?id=81954
     5
     6        Reviewed by James Robinson.
     7
     8        A static variable s_inPaintContents is set when painting, and it ensures
     9        that we don't delete GraphicsLayers or create GraphicsLayers while painting.
     10
     11        However, because this variable is static, it does not permit the existence
     12        of multiple WebViews in different stages (one laying out and one painting).
     13
     14        This manifests itself if one attempts to use the --force-compositing-mode
     15        in Chromium and attempts to navigate to a page with a missing or old plugin
     16        or a browser plugin (which uses a WebViewPlugin as a placeholder until it's
     17        done loading).
     18
     19        The solution to simplify debugging is to make this flag per-Page.
     20        We can access Page from RenderLayerBacking which is a GraphicsLayerClient.
     21        We add a new method GraphicsLayerClient::verifyNotPainting with a default
     22        (do nothing) implementation and override it in RenderLayerBacking to
     23        test the flag set in Page.
     24
     25        * page/Page.cpp:
     26        (WebCore::Page::Page):
     27        * page/Page.h:
     28        (Page):
     29        (WebCore::Page::setIsPainting):
     30        (WebCore::Page::isPainting):
     31        * platform/graphics/GraphicsLayer.cpp:
     32        (WebCore::GraphicsLayer::GraphicsLayer):
     33        (WebCore::GraphicsLayer::~GraphicsLayer):
     34        (WebCore::GraphicsLayer::paintGraphicsLayerContents):
     35        * platform/graphics/GraphicsLayerClient.h:
     36        (GraphicsLayerClient):
     37        (WebCore::GraphicsLayerClient::verifyNotPainting):
     38        * rendering/RenderLayerBacking.cpp:
     39        (WebCore::RenderLayerBacking::paintContents):
     40        (WebCore):
     41        (WebCore::RenderLayerBacking::verifyNotPainting):
     42        * rendering/RenderLayerBacking.h:
     43        (RenderLayerBacking):
     44
    1452012-03-23  Ryosuke Niwa  <rniwa@webkit.org>
    246
  • trunk/Source/WebCore/page/Page.cpp

    r111593 r112178  
    161161    , m_displayID(0)
    162162    , m_isCountingRelevantRepaintedObjects(false)
     163#ifndef NDEBUG
     164    , m_isPainting(false)
     165#endif
    163166{
    164167    if (!allPages) {
  • trunk/Source/WebCore/page/Page.h

    r111593 r112178  
    332332        void suspendActiveDOMObjectsAndAnimations();
    333333        void resumeActiveDOMObjectsAndAnimations();
    334 
     334#ifndef NDEBUG
     335        void setIsPainting(bool painting) { m_isPainting = painting; }
     336        bool isPainting() const { return m_isPainting; }
     337#endif
    335338    private:
    336339        void initGroup();
     
    432435        Region m_relevantUnpaintedRegion;
    433436        bool m_isCountingRelevantRepaintedObjects;
     437#ifndef NDEBUG
     438        bool m_isPainting;
     439#endif
    434440    };
    435441
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r107461 r112178  
    6464}
    6565
    66 #ifndef NDEBUG
    67 static bool s_inPaintContents = false;
    68 #endif
    69 
    7066GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
    7167    : m_client(client)
     
    9288    , m_repaintCount(0)
    9389{
    94     ASSERT(!s_inPaintContents);
     90#ifndef NDEBUG
     91    if (m_client)
     92        m_client->verifyNotPainting();
     93#endif
    9594}
    9695
    9796GraphicsLayer::~GraphicsLayer()
    9897{
    99     ASSERT(!s_inPaintContents);
     98#ifndef NDEBUG
     99    if (m_client)
     100        m_client->verifyNotPainting();
     101#endif
    100102    removeAllChildren();
    101103    removeFromParent();
     
    289291void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const IntRect& clip)
    290292{
    291 #ifndef NDEBUG
    292     s_inPaintContents = true;
    293 #endif
    294293    if (m_client) {
    295294        LayoutSize offset = offsetFromRenderer();
     
    301300        m_client->paintContents(this, context, m_paintingPhase, pixelSnappedIntRect(clipRect));
    302301    }
    303 #ifndef NDEBUG
    304     s_inPaintContents = false;
    305 #endif
    306302}
    307303
  • trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h

    r107422 r112178  
    7575    virtual bool showDebugBorders(const GraphicsLayer*) const = 0;
    7676    virtual bool showRepaintCounter(const GraphicsLayer*) const = 0;
     77
     78#ifndef NDEBUG
     79    // RenderLayerBacking overrides this to verify that it is not
     80    // currently painting contents. An ASSERT fails, if it is.
     81    // This is executed in GraphicsLayer construction and destruction
     82    // to verify that we don't create or destroy GraphicsLayers
     83    // while painting.
     84    virtual void verifyNotPainting() { }
     85#endif
    7786};
    7887
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r111908 r112178  
    11611161void RenderLayerBacking::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase paintingPhase, const IntRect& clip)
    11621162{
     1163#ifndef NDEBUG
     1164    if (Page* page = renderer()->frame()->page())
     1165        page->setIsPainting(true);
     1166#endif
    11631167    if (graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_foregroundLayer.get() || graphicsLayer == m_maskLayer.get()) {
    11641168        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_owningLayer->renderer()->frame(), &context, clip);
     
    11861190        context.restore();
    11871191    }
     1192#ifndef NDEBUG
     1193    if (Page* page = renderer()->frame()->page())
     1194        page->setIsPainting(false);
     1195#endif
    11881196}
    11891197
     
    12121220    return compositor() ? compositor()->compositorShowRepaintCounter() : false;
    12131221}
     1222
     1223#ifndef NDEBUG
     1224void RenderLayerBacking::verifyNotPainting()
     1225{
     1226    ASSERT(!renderer()->frame()->page() || !renderer()->frame()->page()->isPainting());
     1227}
     1228#endif
    12141229
    12151230bool RenderLayerBacking::startAnimation(double timeOffset, const Animation* anim, const KeyframeList& keyframes)
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r110601 r112178  
    137137    virtual bool showRepaintCounter(const GraphicsLayer*) const;
    138138
     139#ifndef NDEBUG
     140    virtual void verifyNotPainting();
     141#endif
     142
    139143    IntRect contentsBox() const;
    140144   
Note: See TracChangeset for help on using the changeset viewer.