Changeset 147592 in webkit


Ignore:
Timestamp:
Apr 3, 2013 3:54:51 PM (11 years ago)
Author:
mrowe@apple.com
Message:

Enable process suppression when no windows in the application have drawn recently.
<http://webkit.org/b/113854> / <rdar://problem/13540351>

Reviewed by Darin Adler.

  • UIProcess/mac/WebContextMac.mm:

(WebKit::applicationWindowModificationsStarted): Note that modifications are no longer stopped.
(WebKit::applicationWindowModificationsStopped): Note that modifications have stopped.
(WebKit::registerOcclusionNotificationHandlers): Register handlers for the start and stop notifications.
(WebKit::unregisterOcclusionNotificationHandlers): Unregister handlers for the start and stop notifications.
(WebKit::WebContext::canEnableProcessSuppressionForNetworkProcess): Allow suppression if the application is occluded
or the application has not drawn recently.
(WebKit::WebContext::canEnableProcessSuppressionForWebProcess): Ditto.
(WebKit::WebContext::canEnableProcessSuppressionForGlobalChildProcesses): Ditto.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r147579 r147592  
     12013-04-02  Mark Rowe  <mrowe@apple.com>
     2
     3        Enable process suppression when no windows in the application have drawn recently.
     4        <http://webkit.org/b/113854> / <rdar://problem/13540351>
     5
     6        Reviewed by Darin Adler.
     7
     8        * UIProcess/mac/WebContextMac.mm:
     9        (WebKit::applicationWindowModificationsStarted): Note that modifications are no longer stopped.
     10        (WebKit::applicationWindowModificationsStopped): Note that modifications have stopped.
     11        (WebKit::registerOcclusionNotificationHandlers): Register handlers for the start and stop notifications.
     12        (WebKit::unregisterOcclusionNotificationHandlers): Unregister handlers for the start and stop notifications.
     13        (WebKit::WebContext::canEnableProcessSuppressionForNetworkProcess): Allow suppression if the application is occluded
     14        or the application has not drawn recently.
     15        (WebKit::WebContext::canEnableProcessSuppressionForWebProcess): Ditto.
     16        (WebKit::WebContext::canEnableProcessSuppressionForGlobalChildProcesses): Ditto.
     17
    1182013-04-03  Dean Jackson  <dino@apple.com>
    219
  • trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm

    r141167 r147592  
    6767
    6868static bool s_applicationIsOccluded = false;
     69static bool s_applicationWindowModificationsHaveStopped = false;
    6970static bool s_occlusionNotificationHandlersRegistered = false;
    7071static bool s_processSuppressionEnabledForAllContexts = true;
     
    129130    applicationOcclusionStateChanged();
    130131}
     132
     133static void applicationWindowModificationsStarted(uint32_t, void*, uint32_t, void*, uint32_t)
     134{
     135    if (!s_applicationWindowModificationsHaveStopped)
     136        return;
     137    s_applicationWindowModificationsHaveStopped = false;
     138    applicationOcclusionStateChanged();
     139}
     140
     141static void applicationWindowModificationsStopped(uint32_t, void*, uint32_t, void*, uint32_t)
     142{
     143    if (s_applicationWindowModificationsHaveStopped)
     144        return;
     145    s_applicationWindowModificationsHaveStopped = true;
     146    applicationOcclusionStateChanged();
     147}
     148
    131149#endif
    132150
     
    139157    }
    140158   
    141     if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameOccluded))
     159    if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameOccluded)) {
    142160        WTFLogAlways("Registration of \"Application Became Occluded\" notification handler failed.\n");
     161        return;
     162    }
     163
     164    if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStarted, applicationWindowModificationsStarted)) {
     165        WTFLogAlways("Registration of \"Application Window Modifications Started\" notification handler failed.\n");
     166        return;
     167    }
     168   
     169    if (!WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStopped, applicationWindowModificationsStopped)) {
     170        WTFLogAlways("Registration of \"Application Window Modifications Stopped\" notification handler failed.\n");
     171        return;
     172    }
    143173#endif
    144174}
     
    152182    }
    153183   
    154     if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameVisible))
     184    if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationBecameOccluded, applicationBecameVisible)) {
    155185        WTFLogAlways("Unregistration of \"Application Became Visible\" notification handler failed.\n");
     186        return;
     187    }
     188
     189    if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStarted, applicationWindowModificationsStarted)) {
     190        WTFLogAlways("Unregistration of \"Application Window Modifications Started\" notification handler failed.\n");
     191        return;
     192    }
     193   
     194    if (!WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationTypeApplicationWindowModificationsStopped, applicationWindowModificationsStopped)) {
     195        WTFLogAlways("Unregistration of \"Application Window Modifications Stopped\" notification handler failed.\n");
     196        return;
     197    }
    156198#endif
    157199}
     
    447489bool WebContext::canEnableProcessSuppressionForNetworkProcess() const
    448490{
    449     return s_applicationIsOccluded && m_processSuppressionEnabled && !omitProcessSuppression();
     491    return (s_applicationIsOccluded || s_applicationWindowModificationsHaveStopped) && m_processSuppressionEnabled && !omitProcessSuppression();
    450492}
    451493
    452494bool WebContext::canEnableProcessSuppressionForWebProcess(const WebKit::WebProcessProxy *webProcess) const
    453495{
    454     return (s_applicationIsOccluded || webProcess->allPagesAreProcessSuppressible())
     496    return (s_applicationIsOccluded || s_applicationWindowModificationsHaveStopped || webProcess->allPagesAreProcessSuppressible())
    455497           && m_processSuppressionEnabled && !omitProcessSuppression();
    456498}
     
    458500bool WebContext::canEnableProcessSuppressionForGlobalChildProcesses()
    459501{
    460     return s_applicationIsOccluded && s_processSuppressionEnabledForAllContexts && !omitProcessSuppression();
     502    return (s_applicationIsOccluded || s_applicationWindowModificationsHaveStopped) && s_processSuppressionEnabledForAllContexts && !omitProcessSuppression();
    461503}
    462504
Note: See TracChangeset for help on using the changeset viewer.