Changeset 195790 in webkit


Ignore:
Timestamp:
Jan 28, 2016 3:30:45 PM (8 years ago)
Author:
Antti Koivisto
Message:

Tab suspension code hits asserts

Reviewed by Chris Dumez.

Enabling tab suspension and navigating around in a few tabs hits an assert in
ScriptExecutionContext::suspendActiveDOMObject. This is because suspend/resume reasons don't pair properly

  • dom/Document.cpp:

(WebCore::Document::documentWillBecomeInactive):
(WebCore::Document::suspend):
(WebCore::Document::resume):

Provide the reason as argument.

  • dom/Document.h:
  • history/CachedFrame.cpp:

(WebCore::CachedFrameBase::restore):

No need to call resumeActiveDOMObjects/resumeScriptedAnimationControllerCallbacks explicitly as Document::resume does that.

(WebCore::CachedFrame::CachedFrame):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::commitProvisionalLoad):

  • page/Page.cpp:

(WebCore::Page::canTabSuspend):
(WebCore::Page::setIsTabSuspended):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195787 r195790  
     12016-01-28  Antti Koivisto  <antti@apple.com>
     2
     3        Tab suspension code hits asserts
     4             
     5
     6        Reviewed by Chris Dumez.
     7
     8        Enabling tab suspension and navigating around in a few tabs hits an assert in
     9        ScriptExecutionContext::suspendActiveDOMObject. This is because suspend/resume reasons don't pair properly
     10
     11        * dom/Document.cpp:
     12        (WebCore::Document::documentWillBecomeInactive):
     13        (WebCore::Document::suspend):
     14        (WebCore::Document::resume):
     15
     16            Provide the reason as argument.
     17
     18        * dom/Document.h:
     19        * history/CachedFrame.cpp:
     20        (WebCore::CachedFrameBase::restore):
     21
     22            No need to call resumeActiveDOMObjects/resumeScriptedAnimationControllerCallbacks explicitly as Document::resume does that.
     23
     24        (WebCore::CachedFrame::CachedFrame):
     25        * loader/FrameLoader.cpp:
     26        (WebCore::FrameLoader::commitProvisionalLoad):
     27        * page/Page.cpp:
     28        (WebCore::Page::canTabSuspend):
     29        (WebCore::Page::setIsTabSuspended):
     30
    1312016-01-28  Brady Eidson  <beidson@apple.com>
    232
  • trunk/Source/WebCore/dom/Document.cpp

    r195743 r195790  
    46564656}
    46574657
    4658 void Document::suspend()
     4658void Document::suspend(ActiveDOMObject::ReasonForSuspension reason)
    46594659{
    46604660    if (m_isSuspended)
     
    46814681
    46824682    suspendScriptedAnimationControllerCallbacks();
    4683     suspendActiveDOMObjects(ActiveDOMObject::PageCache);
     4683    suspendActiveDOMObjects(reason);
    46844684
    46854685    ASSERT(m_frame);
     
    46924692}
    46934693
    4694 void Document::resume()
     4694void Document::resume(ActiveDOMObject::ReasonForSuspension reason)
    46954695{
    46964696    if (!m_isSuspended)
     
    47124712    m_frame->animation().resumeAnimationsForDocument(this);
    47134713
    4714     resumeActiveDOMObjects(ActiveDOMObject::PageWillBeSuspended);
     4714    resumeActiveDOMObjects(reason);
    47154715    resumeScriptedAnimationControllerCallbacks();
    47164716
  • trunk/Source/WebCore/dom/Document.h

    r195560 r195790  
    10121012
    10131013    void documentWillBecomeInactive();
    1014     void suspend();
    1015     void resume();
     1014    void suspend(ActiveDOMObject::ReasonForSuspension);
     1015    void resume(ActiveDOMObject::ReasonForSuspension);
    10161016
    10171017    void registerForMediaVolumeCallbacks(Element*);
  • trunk/Source/WebCore/history/CachedFrame.cpp

    r195605 r195790  
    9393
    9494    frame.animation().resumeAnimationsForDocument(m_document.get());
    95     m_document->resumeActiveDOMObjects(ActiveDOMObject::PageCache);
    96     m_document->resumeScriptedAnimationControllerCallbacks();
     95
     96    m_document->resume(ActiveDOMObject::PageCache);
    9797
    9898    // It is necessary to update any platform script objects after restoring the
     
    136136#endif
    137137
    138     m_document->resume();
    139138}
    140139
     
    162161
    163162    // Active DOM objects must be suspended before we cache the frame script data.
    164     m_document->suspend();
     163    m_document->suspend(ActiveDOMObject::PageCache);
    165164
    166165    m_cachedFrameScriptData = std::make_unique<ScriptCachedFrameData>(frame);
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r195722 r195790  
    18461846            m_frame.page()->chrome().didReceiveDocType(&m_frame);
    18471847#endif
    1848         m_frame.document()->resume();
     1848        m_frame.document()->resume(ActiveDOMObject::PageCache);
    18491849
    18501850        // Force a layout to update view size and thereby update scrollbars.
  • trunk/Source/WebCore/page/Page.cpp

    r195694 r195790  
    18641864bool Page::canTabSuspend()
    18651865{
    1866     return s_tabSuspensionIsEnabled && !m_isPrerender && (m_pageThrottler.activityState() == PageActivityState::NoFlags) && PageCache::singleton().canCache(*this);
     1866    if (!s_tabSuspensionIsEnabled)
     1867        return false;
     1868    if (m_isPrerender)
     1869        return false;
     1870    if (m_pageThrottler.activityState() != PageActivityState::NoFlags)
     1871        return false;
     1872    // FIXME: PageCache::canCache does a bunch of checks that are not needed for the tab suspension case. There should be a specific check.
     1873    if (!PageCache::singleton().canCache(*this))
     1874        return false;
     1875
     1876    return true;
    18671877}
    18681878
     
    18721882        if (auto* document = frame->document()) {
    18731883            if (shouldSuspend)
    1874                 document->suspend();
     1884                document->suspend(ActiveDOMObject::PageWillBeSuspended);
    18751885            else
    1876                 document->resume();
     1886                document->resume(ActiveDOMObject::PageWillBeSuspended);
    18771887        }
    18781888    }
Note: See TracChangeset for help on using the changeset viewer.