Changeset 176097 in webkit


Ignore:
Timestamp:
Nov 13, 2014, 3:27:26 PM (10 years ago)
Author:
Simon Fraser
Message:

[WK2] Fire a layout milestone on session restore based on render tree size
https://bugs.webkit.org/show_bug.cgi?id=138711
rdar://problem/16033854

Reviewed by Anders Carlsson.
Source/WebCore:

New layout milestone for session restore based on render tree size. Only used
in WK2 at present.

  • page/LayoutMilestones.h:

Source/WebKit2:

Add a session-restore layout milestone which fires after restoring a session,
when the render tree size reaches 50% of the size saved in the session state.

  • Shared/SessionState.h: Add renderTreeSize.
  • UIProcess/API/Cocoa/WKWebView.mm:

(layoutMilestones): Translate from SPI to WebCore milestones.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h: New iOS-only milestone, er, event.
  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::renderingProgressEvents): Translate from WebCore milestone to rendering event.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::WebPageProxy): Init stuff.
(WebKit::WebPageProxy::sessionState):
(WebKit::WebPageProxy::restoreFromSessionState): Zero out the target render tree size,
then get it out of session state and set the flag to say that we haven't reached it yet.
(WebKit::WebPageProxy::listenForLayoutMilestones): Set a flag to know that we should fire
the milestone. The other milestones get sent directly to WebCore.

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::exceedsRenderTreeSizeSizeThreshold): Return true when we've reached 50%.
(WebKit::WebPageProxy::didCommitLayerTree): Fire the milestone when appropriate.

  • UIProcess/mac/LegacySessionStateCoding.cpp: Rev the session state data for iOS

(where doing so is less disruptive). Standardize some CFString constants.
(WebKit::encodeSessionHistory): Wrap for legibility.
(WebKit::encodeLegacySessionState): Make a CFNumber for render tree size, and store
it in the root dictionary.
(WebKit::decodeBackForwardTreeNode): Move a comment to match another similar block.
(WebKit::decodeLegacySessionState): Decode render tree size and store it.

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176096 r176097  
     12014-11-13  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [WK2] Fire a layout milestone on session restore based on render tree size
     4        https://bugs.webkit.org/show_bug.cgi?id=138711
     5        rdar://problem/16033854
     6
     7        Reviewed by Anders Carlsson.
     8
     9        New layout milestone for session restore based on render tree size. Only used
     10        in WK2 at present.
     11
     12        * page/LayoutMilestones.h:
     13
    1142014-11-13  Dan Bernstein  <mitz@apple.com>
    215
  • trunk/Source/WebCore/page/LayoutMilestones.h

    r149317 r176097  
    3838    DidFirstFlushForHeaderLayer = 1 << 3,
    3939    DidFirstLayoutAfterSuppressedIncrementalRendering = 1 << 4,
    40     DidFirstPaintAfterSuppressedIncrementalRendering = 1 << 5
     40    DidFirstPaintAfterSuppressedIncrementalRendering = 1 << 5,
     41    ReachedSessionRestorationRenderTreeSizeThreshold = 1 << 6 // FIXME: only implemented by WK2 currently.
    4142};
    4243
  • trunk/Source/WebKit2/ChangeLog

    r176086 r176097  
     12014-11-13  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [WK2] Fire a layout milestone on session restore based on render tree size
     4        https://bugs.webkit.org/show_bug.cgi?id=138711
     5        rdar://problem/16033854
     6
     7        Reviewed by Anders Carlsson.
     8       
     9        Add a session-restore layout milestone which fires after restoring a session,
     10        when the render tree size reaches 50% of the size saved in the session state.
     11
     12        * Shared/SessionState.h: Add renderTreeSize.
     13        * UIProcess/API/Cocoa/WKWebView.mm:
     14        (layoutMilestones): Translate from SPI to WebCore milestones.
     15        * UIProcess/API/Cocoa/WKWebViewPrivate.h: New iOS-only milestone, er, event.
     16        * UIProcess/Cocoa/NavigationState.mm:
     17        (WebKit::renderingProgressEvents): Translate from WebCore milestone to rendering event.
     18        * UIProcess/WebPageProxy.cpp:
     19        (WebKit::WebPageProxy::WebPageProxy): Init stuff.
     20        (WebKit::WebPageProxy::sessionState):
     21        (WebKit::WebPageProxy::restoreFromSessionState): Zero out the target render tree size,
     22        then get it out of session state and set the flag to say that we haven't reached it yet.
     23        (WebKit::WebPageProxy::listenForLayoutMilestones): Set a flag to know that we should fire
     24        the milestone. The other milestones get sent directly to WebCore.
     25        * UIProcess/WebPageProxy.h:
     26        * UIProcess/ios/WebPageProxyIOS.mm:
     27        (WebKit::exceedsRenderTreeSizeSizeThreshold): Return true when we've reached 50%.
     28        (WebKit::WebPageProxy::didCommitLayerTree): Fire the milestone when appropriate.
     29        * UIProcess/mac/LegacySessionStateCoding.cpp: Rev the session state data for iOS
     30        (where doing so is less disruptive). Standardize some CFString constants.
     31        (WebKit::encodeSessionHistory): Wrap for legibility.
     32        (WebKit::encodeLegacySessionState): Make a CFNumber for render tree size, and store
     33        it in the root dictionary.
     34        (WebKit::decodeBackForwardTreeNode): Move a comment to match another similar block.
     35        (WebKit::decodeLegacySessionState): Decode render tree size and store it.
     36
    1372014-11-13  Tim Horton  <timothy_horton@apple.com>
    238
  • trunk/Source/WebKit2/Shared/SessionState.h

    r170989 r176097  
    141141struct SessionState {
    142142    BackForwardListState backForwardListState;
     143    uint64_t renderTreeSize;
    143144    WebCore::URL provisionalURL;
    144145};
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r175980 r176097  
    18091809        milestones |= WebCore::DidHitRelevantRepaintedObjectsAreaThreshold;
    18101810
     1811    if (events & _WKRenderingProgressEventReachedSessionRestorationRenderTreeSizeThreshold)
     1812        milestones |= WebCore::ReachedSessionRestorationRenderTreeSizeThreshold;
     1813
    18111814    return milestones;
    18121815}
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r173233 r176097  
    3131    _WKRenderingProgressEventFirstLayout = 1 << 0,
    3232    _WKRenderingProgressEventFirstPaintWithSignificantArea = 1 << 2,
     33    _WKRenderingProgressEventReachedSessionRestorationRenderTreeSizeThreshold WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA) = 1 << 3
    3334} WK_ENUM_AVAILABLE(10_10, 8_0);
    3435
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm

    r171858 r176097  
    674674        events |= _WKRenderingProgressEventFirstPaintWithSignificantArea;
    675675
     676    if (milestones & WebCore::ReachedSessionRestorationRenderTreeSizeThreshold)
     677        events |= _WKRenderingProgressEventReachedSessionRestorationRenderTreeSizeThreshold;
     678
    676679    return events;
    677680}
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r176011 r176097  
    362362    , m_pageCount(0)
    363363    , m_renderTreeSize(0)
     364    , m_sessionRestorationRenderTreeSize(0)
     365    , m_wantsSessionRestorationRenderTreeSizeThresholdEvent(false)
     366    , m_hitRenderTreeSizeThreshold(false)
    364367    , m_shouldSendEventsSynchronously(false)
    365368    , m_suppressVisibilityUpdates(false)
     
    19321935        sessionState.provisionalURL = URL(URL(), provisionalURLString);
    19331936
     1937    sessionState.renderTreeSize = renderTreeSize();
    19341938    return sessionState;
    19351939}
     
    19371941uint64_t WebPageProxy::restoreFromSessionState(SessionState sessionState, bool navigate)
    19381942{
     1943    m_sessionRestorationRenderTreeSize = 0;
     1944    m_hitRenderTreeSizeThreshold = false;
     1945
    19391946    bool hasBackForwardList = !!sessionState.backForwardListState.currentIndex;
    19401947
     
    19481955    }
    19491956
     1957    // FIXME: Navigating should be separate from state restoration.
    19501958    if (navigate) {
    1951         // FIXME: Navigating should be separate from state restoration.
     1959        m_sessionRestorationRenderTreeSize = sessionState.renderTreeSize;
     1960        if (!m_sessionRestorationRenderTreeSize)
     1961            m_hitRenderTreeSizeThreshold = true; // If we didn't get data on renderTreeSize, just don't fire the milestone.
    19521962
    19531963        if (!sessionState.provisionalURL.isNull())
     
    21082118    if (!isValid())
    21092119        return;
     2120   
     2121    m_wantsSessionRestorationRenderTreeSizeThresholdEvent = milestones & WebCore::ReachedSessionRestorationRenderTreeSizeThreshold;
    21102122
    21112123    m_process->send(Messages::WebPage::ListenForLayoutMilestones(milestones), m_pageID);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r176011 r176097  
    15581558
    15591559    uint64_t m_renderTreeSize;
     1560    uint64_t m_sessionRestorationRenderTreeSize;
     1561    bool m_wantsSessionRestorationRenderTreeSizeThresholdEvent;
     1562    bool m_hitRenderTreeSizeThreshold;
    15601563
    15611564    bool m_shouldSendEventsSynchronously;
  • trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r175153 r176097  
    333333}
    334334
     335static bool exceedsRenderTreeSizeSizeThreshold(uint64_t thresholdSize, uint64_t committedSize)
     336{
     337    const double thesholdSizeFraction = 0.5; // Empirically-derived.
     338    return committedSize > thresholdSize * thesholdSizeFraction;
     339}
     340
    335341void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction& layerTreeTransaction)
    336342{
     
    350356
    351357    m_pageClient.didCommitLayerTree(layerTreeTransaction);
     358
     359    if (m_wantsSessionRestorationRenderTreeSizeThresholdEvent && !m_hitRenderTreeSizeThreshold
     360        && exceedsRenderTreeSizeSizeThreshold(m_sessionRestorationRenderTreeSize, layerTreeTransaction.renderTreeSize())) {
     361        m_hitRenderTreeSizeThreshold = true;
     362        m_loaderClient->didLayout(this, WebCore::ReachedSessionRestorationRenderTreeSizeThreshold, nullptr);
     363    }
    352364}
    353365
  • trunk/Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp

    r174400 r176097  
    4141static const CFStringRef sessionHistoryKey = CFSTR("SessionHistory");
    4242static const CFStringRef provisionalURLKey = CFSTR("ProvisionalURL");
     43static const CFStringRef renderTreeSizeKey = CFSTR("RenderTreeSize");
    4344
    4445// Session history keys.
     
    5152// Session history entry keys.
    5253static const CFStringRef sessionHistoryEntryURLKey = CFSTR("SessionHistoryEntryURL");
    53 static CFStringRef sessionHistoryEntryTitleKey = CFSTR("SessionHistoryEntryTitle");
    54 static CFStringRef sessionHistoryEntryOriginalURLKey = CFSTR("SessionHistoryEntryOriginalURL");
    55 static CFStringRef sessionHistoryEntryDataKey = CFSTR("SessionHistoryEntryData");
     54static const CFStringRef sessionHistoryEntryTitleKey = CFSTR("SessionHistoryEntryTitle");
     55static const CFStringRef sessionHistoryEntryOriginalURLKey = CFSTR("SessionHistoryEntryOriginalURL");
     56static const CFStringRef sessionHistoryEntryDataKey = CFSTR("SessionHistoryEntryData");
    5657
    5758// Session history entry data.
     
    427428        auto data = encodeSessionHistoryEntryData(item.pageState.mainFrameState);
    428429
    429         auto entryDictionary = createDictionary({ { sessionHistoryEntryURLKey, url.get() }, { sessionHistoryEntryTitleKey, title.get() }, { sessionHistoryEntryOriginalURLKey, originalURL.get() }, { sessionHistoryEntryDataKey, data.get() } });
     430        auto entryDictionary = createDictionary({
     431            { sessionHistoryEntryURLKey, url.get() },
     432            { sessionHistoryEntryTitleKey, title.get() },
     433            { sessionHistoryEntryOriginalURLKey, originalURL.get() },
     434            { sessionHistoryEntryDataKey, data.get() },
     435        });
    430436
    431437        CFArrayAppendValue(entries.get(), entryDictionary.get());
     
    442448    auto sessionHistoryDictionary = encodeSessionHistory(sessionState.backForwardListState);
    443449    auto provisionalURLString = sessionState.provisionalURL.isNull() ? nullptr : sessionState.provisionalURL.string().createCFString();
     450    RetainPtr<CFNumberRef> renderTreeSizeNumber(adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sessionState.renderTreeSize)));
    444451
    445452    RetainPtr<CFDictionaryRef> stateDictionary;
    446     if (provisionalURLString)
    447         stateDictionary = createDictionary({ { sessionHistoryKey, sessionHistoryDictionary.get() }, { provisionalURLKey, provisionalURLString.get() } });
    448     else
    449         stateDictionary = createDictionary({ { sessionHistoryKey, sessionHistoryDictionary.get() } });
     453    if (provisionalURLString) {
     454        stateDictionary = createDictionary({
     455            { sessionHistoryKey, sessionHistoryDictionary.get() },
     456            { provisionalURLKey, provisionalURLString.get() },
     457            { renderTreeSizeKey, renderTreeSizeNumber.get() }
     458        });
     459    } else {
     460        stateDictionary = createDictionary({
     461            { sessionHistoryKey, sessionHistoryDictionary.get() },
     462            { renderTreeSizeKey, renderTreeSizeNumber.get() }
     463        });
     464    }
    450465
    451466    auto writeStream = adoptCF(CFWriteStreamCreateWithAllocatedBuffers(kCFAllocatorDefault, nullptr));
     
    903918    decoder >> frameState.target;
    904919
     920#if PLATFORM(IOS)
    905921    // FIXME: iOS should not use the legacy session state decoder.
    906 #if PLATFORM(IOS)
    907922    decoder >> frameState.exposedContentRect;
    908923    decoder >> frameState.unobscuredContentRect;
     
    10881103    }
    10891104
     1105    if (auto renderTreeSize = dynamic_cf_cast<CFNumberRef>(CFDictionaryGetValue(sessionStateDictionary.get(), renderTreeSizeKey)))
     1106        CFNumberGetValue(renderTreeSize, kCFNumberSInt64Type, &sessionState.renderTreeSize);
     1107    else
     1108        sessionState.renderTreeSize = 0;
     1109
    10901110    return true;
    10911111}
Note: See TracChangeset for help on using the changeset viewer.