Changeset 207424 in webkit


Ignore:
Timestamp:
Oct 17, 2016 1:18:38 PM (8 years ago)
Author:
barraclough@apple.com
Message:

UIProcess should determine throttle state for WebContent process
https://bugs.webkit.org/show_bug.cgi?id=163556

Reviewed by Anders Carlsson.

This is a step towards merging page/process throttling code for mac & iOS.

Previously WebPage determined whether to start a UserActivity based on page activity,
visibility and the preference to disable. Now WebPage passes the activity state across
to WebPageProxy, which makes the decision & explicitly instructs WebPage to start/stop
the UserActivity.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::WebPageProxy):

  • updateActivityToken + updateProccessSuppressionState -> updateThrottleState

(WebKit::WebPageProxy::reattachToWebProcess):

  • updateActivityToken -> updateThrottleState

(WebKit::WebPageProxy::dispatchViewStateChange):

  • updateActivityToken -> updateThrottleState

(WebKit::WebPageProxy::setPageActivityState):

  • Record activity state passed from WebPage, and update.

(WebKit::WebPageProxy::preferencesDidChange):

  • updateProccessSuppressionState -> updateThrottleState

(WebKit::WebPageProxy::updateActivityToken): Deleted.
(WebKit::WebPageProxy::updateProccessSuppressionState): Deleted.
(WebKit::WebPageProxy::updateThrottleState):

  • Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
  • Compute whether page should be suppressed, and send SetPageSuppressed message accordingly.
  • UIProcess/WebPageProxy.h:
    • Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
    • Added setPageActivityState/m_activityState to report/record page activity.
    • Added m_pageSuppressed to prevent redundant message sends.
  • UIProcess/WebPageProxy.messages.in:
    • Expose SetPageActivityState message (called by WebPage).
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::WebPage):

  • removed m_processSuppressionEnabled
  • updateUserActivity -> setPageSuppressed - explicitly set the page to not be suppressed, until WebPageProxy tells us to do so.

(WebKit::WebPage::setPageActivityState):

  • post activity state on to WebPageProxy.

(WebKit::WebPage::setPageSuppressed):

  • Start/stop USerActivity accordingly.

(WebKit::WebPage::setViewState):

  • No longer need to monitor ViewState changes on the WebProcess side.

(WebKit::WebPage::updatePreferences):

  • No longer need to monitor preference changes on the WebProcess side.

(WebKit::WebPage::updateUserActivity): Deleted.

  • Only updated on reciept of setPageSuppressed message.
  • WebProcess/WebPage/WebPage.h:
    • Removed m_activityState, m_processSuppressionEnabled, updateUserActivity.
    • Added setPageSuppressed message.
  • WebProcess/WebPage/WebPage.messages.in:
    • Added SetPageSuppressed message.
Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r207414 r207424  
     12016-10-17  Gavin Barraclough  <barraclough@apple.com>
     2
     3        UIProcess should determine throttle state for WebContent process
     4        https://bugs.webkit.org/show_bug.cgi?id=163556
     5
     6        Reviewed by Anders Carlsson.
     7
     8        This is a step towards merging page/process throttling code for mac & iOS.
     9
     10        Previously WebPage determined whether to start a UserActivity based on page activity,
     11        visibility and the preference to disable. Now WebPage passes the activity state across
     12        to WebPageProxy, which makes the decision & explicitly instructs WebPage to start/stop
     13        the UserActivity.
     14
     15        * UIProcess/WebPageProxy.cpp:
     16        (WebKit::WebPageProxy::WebPageProxy):
     17            - updateActivityToken + updateProccessSuppressionState -> updateThrottleState
     18        (WebKit::WebPageProxy::reattachToWebProcess):
     19            - updateActivityToken -> updateThrottleState
     20        (WebKit::WebPageProxy::dispatchViewStateChange):
     21            - updateActivityToken -> updateThrottleState
     22        (WebKit::WebPageProxy::setPageActivityState):
     23            - Record activity state passed from WebPage, and update.
     24        (WebKit::WebPageProxy::preferencesDidChange):
     25            - updateProccessSuppressionState -> updateThrottleState
     26        (WebKit::WebPageProxy::updateActivityToken): Deleted.
     27        (WebKit::WebPageProxy::updateProccessSuppressionState): Deleted.
     28        (WebKit::WebPageProxy::updateThrottleState):
     29            - Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
     30            - Compute whether page should be suppressed, and send SetPageSuppressed message accordingly.
     31        * UIProcess/WebPageProxy.h:
     32            - Merged existing updateActivityToken/updateProccessSuppressionState to unified updateThrottleState.
     33            - Added setPageActivityState/m_activityState to report/record page activity.
     34            - Added m_pageSuppressed to prevent redundant message sends.
     35        * UIProcess/WebPageProxy.messages.in:
     36            - Expose SetPageActivityState message (called by WebPage).
     37        * WebProcess/WebPage/WebPage.cpp:
     38        (WebKit::WebPage::WebPage):
     39            - removed m_processSuppressionEnabled
     40            - updateUserActivity -> setPageSuppressed - explicitly set the page to not be suppressed, until WebPageProxy tells us to do so.
     41        (WebKit::WebPage::setPageActivityState):
     42            - post activity state on to WebPageProxy.
     43        (WebKit::WebPage::setPageSuppressed):
     44            - Start/stop USerActivity accordingly.
     45        (WebKit::WebPage::setViewState):
     46            - No longer need to monitor ViewState changes on the WebProcess side.
     47        (WebKit::WebPage::updatePreferences):
     48            - No longer need to monitor preference changes on the WebProcess side.
     49        (WebKit::WebPage::updateUserActivity): Deleted.
     50            - Only updated on reciept of setPageSuppressed message.
     51        * WebProcess/WebPage/WebPage.h:
     52            - Removed m_activityState, m_processSuppressionEnabled, updateUserActivity.
     53            - Added setPageSuppressed message.
     54        * WebProcess/WebPage/WebPage.messages.in:
     55            - Added SetPageSuppressed message.
     56
    1572016-10-17  Michael Catanzaro  <mcatanzaro@igalia.com>
    258
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r207298 r207424  
    458458
    459459    updateViewState();
    460     updateActivityToken();
    461     updateProccessSuppressionState();
     460    updateThrottleState();
    462461    updateHiddenPageThrottlingAutoIncreases();
    463462   
     
    716715
    717716    updateViewState();
    718     updateActivityToken();
     717    updateThrottleState();
    719718
    720719    m_inspector = WebInspectorProxy::create(this);
     
    15391538
    15401539    // This must happen after the SetViewState message is sent, to ensure the page visibility event can fire.
    1541     updateActivityToken();
     1540    updateThrottleState();
    15421541
    15431542    // If we've started the responsiveness timer as part of telling the web process to update the backing store
     
    15641563}
    15651564
     1565void WebPageProxy::setPageActivityState(WebCore::PageActivityState::Flags activityState)
     1566{
     1567    m_activityState = activityState;
     1568    updateThrottleState();
     1569}
     1570
    15661571bool WebPageProxy::isAlwaysOnLoggingAllowed() const
    15671572{
     
    15691574}
    15701575
    1571 void WebPageProxy::updateActivityToken()
    1572 {
     1576void WebPageProxy::updateThrottleState()
     1577{
     1578    bool processSuppressionEnabled = m_preferences->pageVisibilityBasedProcessSuppressionEnabled();
     1579
     1580    // If process suppression is not enabled take a token on the process pool to disable suppression of support processes.
     1581    if (!processSuppressionEnabled)
     1582        m_preventProcessSuppressionCount = m_process->processPool().processSuppressionDisabledForPageCount();
     1583    else if (!m_preventProcessSuppressionCount)
     1584        m_preventProcessSuppressionCount = nullptr;
     1585
     1586    // We should suppress if the page is not active, is visually idle, and supression is enabled.
     1587    bool pageShouldBeSuppressed = !m_activityState && processSuppressionEnabled && (m_viewState & ViewState::IsVisuallyIdle);
     1588    if (m_pageSuppressed != pageShouldBeSuppressed) {
     1589        m_pageSuppressed = pageShouldBeSuppressed;
     1590        m_process->send(Messages::WebPage::SetPageSuppressed(m_pageSuppressed), m_pageID);
     1591    }
     1592
    15731593    if (m_viewState & ViewState::IsVisuallyIdle)
    15741594        m_pageIsUserObservableCount = nullptr;
     
    15901610    }
    15911611#endif
    1592 }
    1593 
    1594 void WebPageProxy::updateProccessSuppressionState()
    1595 {
    1596     if (m_preferences->pageVisibilityBasedProcessSuppressionEnabled())
    1597         m_preventProcessSuppressionCount = nullptr;
    1598     else if (!m_preventProcessSuppressionCount)
    1599         m_preventProcessSuppressionCount = m_process->processPool().processSuppressionDisabledForPageCount();
    16001612}
    16011613
     
    30133025#endif
    30143026
    3015     updateProccessSuppressionState();
     3027    updateThrottleState();
    30163028    updateHiddenPageThrottlingAutoIncreases();
    30173029
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r207298 r207424  
    11381138
    11391139    void updateViewState(WebCore::ViewState::Flags flagsToUpdate = WebCore::ViewState::AllFlags);
    1140     void updateActivityToken();
    1141     void updateProccessSuppressionState();
     1140    void updateThrottleState();
    11421141    void updateHiddenPageThrottlingAutoIncreases();
    11431142
     
    15211520    void viewDidLeaveWindow();
    15221521    void viewDidEnterWindow();
     1522    void setPageActivityState(WebCore::PageActivityState::Flags);
    15231523
    15241524#if PLATFORM(MAC)
     
    17141714    DownloadID m_syncNavigationActionPolicyDownloadID;
    17151715    bool m_shouldSuppressAppLinksInNextNavigationPolicyDecision { false };
     1716    WebCore::PageActivityState::Flags m_activityState { WebCore::PageActivityState::NoFlags };
     1717    bool m_pageSuppressed { false };
    17161718
    17171719    Deque<NativeWebKeyboardEvent> m_keyEventQueue;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r206771 r207424  
    409409
    410410    DidUpdateViewState()
    411    
     411    SetPageActivityState(int32_t pageActivityState)
     412
    412413    DidSaveToPageCache()
    413414
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r207159 r207424  
    377377    , m_useAsyncScrolling(false)
    378378    , m_viewState(parameters.viewState)
    379     , m_processSuppressionEnabled(true)
    380379    , m_userActivity("Process suppression disabled for page.")
    381380    , m_pendingNavigationID(0)
     
    496495    if (!isVisible())
    497496        m_page->setIsPrerender();
    498     updateUserActivity();
     497    setPageSuppressed(false);
    499498
    500499    updateIsInWindow(true);
     
    583582void WebPage::setPageActivityState(PageActivityState::Flags activityState)
    584583{
    585     PageActivityState::Flags changed = m_activityState ^ activityState;
    586     m_activityState = activityState;
    587 
    588     if (changed)
    589         updateUserActivity();
    590 }
    591 
    592 void WebPage::updateUserActivity()
    593 {
    594     // Start the activity to prevent AppNap if the page activity is in progress,
    595     // the page is visible and non-idle, or process suppression is disabled.
    596     if (m_activityState || !(m_viewState & ViewState::IsVisuallyIdle) || !m_processSuppressionEnabled)
     584    send(Messages::WebPageProxy::SetPageActivityState(activityState));
     585}
     586
     587void WebPage::setPageSuppressed(bool pageSuppressed)
     588{
     589    // The UserActivity keeps the processes runnable. So if the page should be suppressed, stop the activity.
     590    // If the page should not be supressed, start it.
     591    if (pageSuppressed)
     592        m_userActivity.stop();
     593    else
    597594        m_userActivity.start();
    598     else
    599         m_userActivity.stop();
    600595}
    601596
     
    25962591    m_viewState = viewState;
    25972592
    2598     if (changed)
    2599         updateUserActivity();
    2600 
    26012593    m_page->setViewState(viewState);
    26022594    for (auto* pluginView : m_pluginViews)
     
    32343226    RuntimeEnabledFeatures::sharedFeatures().setModernMediaControlsEnabled(store.getBoolValueForKey(WebPreferencesKey::modernMediaControlsEnabledKey()));
    32353227
    3236     bool processSuppressionEnabled = store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey());
    3237     if (m_processSuppressionEnabled != processSuppressionEnabled) {
    3238         m_processSuppressionEnabled = processSuppressionEnabled;
    3239         updateUserActivity();
    3240     }
    3241 
    32423228    platformPreferencesDidChange(store);
    32433229
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r206626 r207424  
    927927
    928928    void setPageActivityState(WebCore::PageActivityState::Flags);
     929    void setPageSuppressed(bool);
    929930
    930931    void postMessage(const String& messageName, API::Object* messageBody);
     
    10401041    void setEditable(bool);
    10411042
    1042     void updateUserActivity();
    1043 
    10441043    void mouseEvent(const WebMouseEvent&);
    10451044    void keyEvent(const WebKeyboardEvent&);
     
    14771476
    14781477    WebCore::ViewState::Flags m_viewState;
    1479     WebCore::PageActivityState::Flags m_activityState;
    1480 
    1481     bool m_processSuppressionEnabled;
     1478
    14821479    UserActivity m_userActivity;
    14831480
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r206929 r207424  
    2525    SetViewState(unsigned viewState, bool wantsDidUpdateViewState, Vector<uint64_t> callbackIDs)
    2626    SetLayerHostingMode(enum WebKit::LayerHostingMode layerHostingMode)
     27    SetPageSuppressed(bool pageSuppressed)
    2728
    2829    SetDrawsBackground(bool drawsBackground)
Note: See TracChangeset for help on using the changeset viewer.