Add more accurate activity state tracking
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 May 2013 23:17:59 +0000 (23:17 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 May 2013 23:17:59 +0000 (23:17 +0000)
commit8240ce53e8344d5b0bcd32454e40bf20f9eca7e2
treebcab0602085aa2a9a986906061977dc22281d7c7
parent8dd2d1c56d33a949cbf27d9382b66a823223d52c
Add more accurate activity state tracking
https://bugs.webkit.org/show_bug.cgi?id=116893

Reviewed by Gavin Barraclough.

Source/WebCore:

Add a hysteresis to Page activity throttling.  We do this
through a PageThrottler class that now handles entering and
exiting throttling state, and adds a hysteresis to we can
limit the amount of on/off bouncing on the throttle.

Media elements now make use of this to disable timer throttling
while they are playing, and plugins use it to momentarily bounce
from throttled to unthrottled state.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::pageThrottlerIfPossible):
(WebCore):
(WebCore::HTMLMediaElement::playInternal):
(WebCore::HTMLMediaElement::pauseInternal):
* html/HTMLMediaElement.h:
(WebCore):
* html/MediaController.cpp:
(MediaController::unpause):
* page/ChromeClient.h:
(WebCore::ChromeClient::incrementActivePageCount):
(WebCore::ChromeClient::decrementActivePageCount):
(ChromeClient):
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::~Page):
(WebCore::Page::setThrottled):
* page/Page.h:
(WebCore):
(Page):
(WebCore::Page::pageThrottler):
* page/PageThrottleState.h: Added.
* page/PageThrottler.cpp: Added.
(WebCore):
(WebCore::PageThrottler::PageThrottler):
(WebCore::PageThrottler::~PageThrottler):
(WebCore::PageThrottler::clearPage):
(WebCore::PageThrottler::throttlePage):
(WebCore::PageThrottler::unthrottlePage):
(WebCore::PageThrottler::setThrottled):
(WebCore::PageThrottler::preventThrottling):
(WebCore::PageThrottler::allowThrottling):
(WebCore::PageThrottler::stopThrottleHysteresisTimer):
(WebCore::PageThrottler::reportInterestingEvent):
(WebCore::PageThrottler::startThrottleHysteresisTimer):
(WebCore::PageThrottler::throttleHysteresisTimerFired):
* page/PageThrottler.h: Added.
(WebCore):
(PageThrottler):
(WebCore::PageThrottler::create):
(WebCore::PageThrottler::shouldThrottleAnimations):
(WebCore::PageThrottler::shouldThrottleTimers):

Source/WebKit2:

This extends the logic in WebCore from a Page to Process
granularity, so we will avoid lowering the child process
priority if there is active content.  This also plumbs in
the logic to allow plugins to report that they have done
something "interesting".  Currently this is somewhat conservative
but even this is sufficient to fix some stuttering issues
that we've seen.

* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::ChildProcess):
* Shared/ChildProcess.h:
(ChildProcess):
(WebKit::ChildProcess::processSuppressionEnabled):
(WebKit::ChildProcess::incrementActiveTaskCount):
(WebKit::ChildProcess::decrementActiveTaskCount):
* Shared/mac/ChildProcessMac.mm:
(WebKit):
(WebKit::ChildProcess::setProcessSuppressionEnabledInternal):
(WebKit::ChildProcess::setProcessSuppressionEnabled):
(WebKit::ChildProcess::incrementActiveTaskCount):
(WebKit::ChildProcess::decrementActiveTaskCount):
(WebKit::ChildProcess::suspensionHysteresisTimerFired):
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::NPRuntimeObjectMap):
(WebKit::NPRuntimeObjectMap::evaluate):
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h:
(WebCore):
(NPRuntimeObjectMap):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::PluginView):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::incrementActivePageCount):
(WebKit):
(WebKit::WebChromeClient::decrementActivePageCount):
* WebProcess/WebCoreSupport/WebChromeClient.h:
(WebChromeClient):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@150935 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/MediaController.cpp
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PageThrottler.cpp [new file with mode: 0644]
Source/WebCore/page/PageThrottler.h [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/ChildProcess.cpp
Source/WebKit2/Shared/ChildProcess.h
Source/WebKit2/Shared/mac/ChildProcessMac.mm
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h