Changeset 228634 in webkit


Ignore:
Timestamp:
Feb 19, 2018 2:12:07 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r228151 - Release assertion in inlineVideoFrame
https://bugs.webkit.org/show_bug.cgi?id=182513
<rdar://problem/37159363>

Reviewed by Zalan Bujtas.

Source/WebCore:

The bug was caused by the fact it's not always safe to invoke updateLayout even when isSafeToUpdateStyleOrLayout
on a document of a flattened frame on iOS. isSafeToUpdateStyleOrLayout returns true when the frame view is in
the frame-flattening mode to avoid hitting a release asssertion in updateLayout of the frame. However, it's still
not safe to invoke updateLayout on a parent frame in this case.

As a result, inlineVideoFrame (in Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm) invokes updateLayout
even when the top-level document is not safe to update when the video element is in a frame-flattened document.

Fixed this bug by explicitly checking that we still have a live render tree and document hasn't been stopped.
Also replaced other uses of isSafeToUpdateStyleOrLayout by more explicit checks.

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::updateBackingStore): Made the early exit condition added in r227006 more explicit.
Namely, InspectorDOMAgent::pseudoElementCreated is invoked during style recalc.

  • dom/Document.cpp:

(WebCore::isSafeToUpdateStyleOrLayout): Made this local to the file.
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::updateLayout):

  • dom/Document.h:
  • html/MediaElementSession.cpp:

(WebCore::isMainContentForPurposesOfAutoplay): Made the early exit condition added in r227529 more explicit. Don't
update the layout when the render tree had been destroyed or the active DOM objects had been stopped.

Source/WebKit:

Fixed the bug. Don't try to update the layout when there is no live render tree or active DOM objects
had been stopped: i.e. during a document destruction.

  • WebProcess/cocoa/VideoFullscreenManager.mm:

(WebKit::inlineVideoFrame):

Location:
releases/WebKitGTK/webkit-2.20/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog

    r228632 r228634  
     12018-02-05  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Release assertion in inlineVideoFrame
     4        https://bugs.webkit.org/show_bug.cgi?id=182513
     5        <rdar://problem/37159363>
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        The bug was caused by the fact it's not always safe to invoke updateLayout even when isSafeToUpdateStyleOrLayout
     10        on a document of a flattened frame on iOS. isSafeToUpdateStyleOrLayout returns true when the frame view is in
     11        the frame-flattening mode to avoid hitting a release asssertion in updateLayout of the frame. However, it's still
     12        not safe to invoke updateLayout on a parent frame in this case.
     13
     14        As a result, inlineVideoFrame (in Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm) invokes updateLayout
     15        even when the top-level document is not safe to update when the video element is in a frame-flattened document.
     16
     17        Fixed this bug by explicitly checking that we still have a live render tree and document hasn't been stopped.
     18        Also replaced other uses of isSafeToUpdateStyleOrLayout by more explicit checks.
     19
     20        * accessibility/AccessibilityObject.cpp:
     21        (WebCore::AccessibilityObject::updateBackingStore): Made the early exit condition added in r227006 more explicit.
     22        Namely, InspectorDOMAgent::pseudoElementCreated is invoked during style recalc.
     23        * dom/Document.cpp:
     24        (WebCore::isSafeToUpdateStyleOrLayout): Made this local to the file.
     25        (WebCore::Document::updateStyleIfNeeded):
     26        (WebCore::Document::updateLayout):
     27        * dom/Document.h:
     28        * html/MediaElementSession.cpp:
     29        (WebCore::isMainContentForPurposesOfAutoplay): Made the early exit condition added in r227529 more explicit. Don't
     30        update the layout when the render tree had been destroyed or the active DOM objects had been stopped.
     31
    1322018-02-05  Filip Pizlo  <fpizlo@apple.com>
    233
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/accessibility/AccessibilityObject.cpp

    r227344 r228634  
    17701770    RefPtr<AccessibilityObject> protectedThis(this);
    17711771    if (auto* document = this->document()) {
    1772         if (!document->view()->layoutContext().isInRenderTreeLayout() && !document->inRenderTreeUpdate() && document->isSafeToUpdateStyleOrLayout())
     1772        if (!document->view()->layoutContext().isInRenderTreeLayout() && !document->inRenderTreeUpdate() && !document->inStyleRecalc())
    17731773            document->updateLayoutIgnorePendingStylesheets();
    17741774    }
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/dom/Document.cpp

    r228632 r228634  
    19401940}
    19411941
    1942 bool Document::isSafeToUpdateStyleOrLayout() const
     1942static bool isSafeToUpdateStyleOrLayout(const Document& document)
    19431943{
    19441944    bool isSafeToExecuteScript = ScriptDisallowedScope::InMainThread::isScriptAllowed();
    1945     bool isInFrameFlattening = view() && view()->isInChildFrameWithFrameFlattening();
     1945    auto* frameView = document.view();
     1946    bool isInFrameFlattening = frameView && frameView->isInChildFrameWithFrameFlattening();
    19461947    bool isAssertionDisabled = ScriptDisallowedScope::LayoutAssertionDisableScope::shouldDisable();
    19471948    return isSafeToExecuteScript || isInFrameFlattening || !isInWebProcess() || isAssertionDisabled;
     
    19661967
    19671968    // The early exit above for !needsStyleRecalc() is needed when updateWidgetPositions() is called in runOrScheduleAsynchronousTasks().
    1968     RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUpdateStyleOrLayout());
     1969    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUpdateStyleOrLayout(*this));
    19691970
    19701971    resolveStyle();
     
    19821983        return;
    19831984    }
    1984     RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUpdateStyleOrLayout());
     1985    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(isSafeToUpdateStyleOrLayout(*this));
    19851986
    19861987    RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/dom/Document.h

    r228632 r228634  
    12531253    bool inStyleRecalc() const { return m_inStyleRecalc; }
    12541254    bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
    1255     WEBCORE_EXPORT bool isSafeToUpdateStyleOrLayout() const;
    12561255
    12571256    void updateTextRenderer(Text&, unsigned offsetOfReplacedText, unsigned lengthOfReplacedText);
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/html/MediaElementSession.cpp

    r227529 r228634  
    696696{
    697697    Document& document = element.document();
    698     if (element.isSuspended() || !element.hasAudio() || !element.hasVideo())
     698    if (!document.hasLivingRenderTree() || document.activeDOMObjectsAreStopped() || element.isSuspended() || !element.hasAudio() || !element.hasVideo())
    699699        return false;
    700700
     
    716716
    717717    // Main content elements must be in the main frame.
    718     if (!document.frame() || !document.frame()->isMainFrame() || !document.isSafeToUpdateStyleOrLayout())
     718    if (!document.frame() || !document.frame()->isMainFrame())
    719719        return false;
    720720
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog

    r228630 r228634  
     12018-02-05  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Release assertion in inlineVideoFrame
     4        https://bugs.webkit.org/show_bug.cgi?id=182513
     5        <rdar://problem/37159363>
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        Fixed the bug. Don't try to update the layout when there is no live render tree or active DOM objects
     10        had been stopped: i.e. during a document destruction.
     11
     12        * WebProcess/cocoa/VideoFullscreenManager.mm:
     13        (WebKit::inlineVideoFrame):
     14
    1152018-02-05  Youenn Fablet  <youenn@apple.com>
    216
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm

    r227272 r228634  
    6060{
    6161    auto& document = element.document();
    62     if (!document.isSafeToUpdateStyleOrLayout())
     62    if (!document.hasLivingRenderTree() || document.activeDOMObjectsAreStopped())
    6363        return { };
    6464
Note: See TracChangeset for help on using the changeset viewer.