Commit 15745130 authored by timothy_horton@apple.com's avatar timothy_horton@apple.com
Browse files

[ca] Tell CA to clean up unused resources if a given WebProcess won't be drawing

https://bugs.webkit.org/show_bug.cgi?id=107539
<rdar://problem/13032692>

Reviewed by Simon Fraser.

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Update WebCoreSystemInterface.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initially move the Page out of the window if necessary;
Page defaults to in-window, which is wrong in many cases - we depend on
Page::isInWindow being accurate to decide whether WebPage::setIsInWindow is actually
a state change or not.
(WebKit::WebPage::setIsInWindow):
* WebProcess/WebProcess.cpp: Inform WebProcess when we go on/off screen.
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::pageDidMoveOnscreen): Keep track of the number of on-screen pages in this process.
(WebKit::WebProcess::pageWillMoveOffscreen): If the number of on-screen pages drops to zero,  clean up unused rendering resources.
* WebProcess/WebProcess.h:

Update WebSystemInterface.

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4f141bf6
2013-03-26 Tim Horton <timothy_horton@apple.com>
[ca] Tell CA to clean up unused resources if a given WebProcess won't be drawing
https://bugs.webkit.org/show_bug.cgi?id=107539
<rdar://problem/13032692>
Reviewed by Simon Fraser.
Update WebCoreSystemInterface.
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:
2013-03-26 Antti Koivisto <antti@apple.com>
 
Test if non-immediate descendants obscure background
......@@ -1615,6 +1615,7 @@ _suggestedFilenameWithMIMEType
__ZN7WebCore15ResourceRequest13partitionNameERKN3WTF6StringE
_wkCachePartitionKey
#endif
_wkDestroyRenderingResources
_wkCGContextGetShouldSmoothFonts
_wkCGContextResetClip
#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
......
......@@ -307,6 +307,8 @@ extern CFHTTPMessageRef (*wkGetCFURLResponseHTTPResponse)(CFURLResponseRef);
extern CFStringRef (*wkCopyCFURLResponseSuggestedFilename)(CFURLResponseRef);
extern void (*wkSetCFURLResponseMIMEType)(CFURLResponseRef, CFStringRef mimeType);
extern void(*wkDestroyRenderingResources)(void);
#if USE(CFNETWORK)
extern CFHTTPCookieStorageRef (*wkGetDefaultHTTPCookieStorage)();
extern WKCFURLCredentialRef (*wkCopyCredentialFromCFPersistentStorage)(CFURLProtectionSpaceRef protectionSpace);
......
......@@ -192,6 +192,8 @@ CFStringRef (*wkCopyCFURLResponseSuggestedFilename)(CFURLResponseRef);
void (*wkSetCFURLResponseMIMEType)(CFURLResponseRef, CFStringRef mimeType);
void (*wkSetMetadataURL)(NSString *urlString, NSString *referrer, NSString *path);
void(*wkDestroyRenderingResources)(void);
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
dispatch_source_t (*wkCreateVMPressureDispatchOnMainQueue)(void);
#endif
......
2013-03-26 Tim Horton <timothy_horton@apple.com>
[ca] Tell CA to clean up unused resources if a given WebProcess won't be drawing
https://bugs.webkit.org/show_bug.cgi?id=107539
<rdar://problem/13032692>
Reviewed by Simon Fraser.
Update WebSystemInterface.
* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):
2013-03-26 Sergio Villar Senin <svillar@igalia.com>
Implement overtype mode for editable content
......
......@@ -186,6 +186,8 @@ void InitWebCoreSystemInterface(void)
INIT(SetMetadataURL);
INIT(DestroyRenderingResources);
#if PLATFORM(MAC)
// FIXME: We should stop using this file in Chromium.
......
2013-03-26 Tim Horton <timothy_horton@apple.com>
[ca] Tell CA to clean up unused resources if a given WebProcess won't be drawing
https://bugs.webkit.org/show_bug.cgi?id=107539
<rdar://problem/13032692>
Reviewed by Simon Fraser.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Update WebCoreSystemInterface.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initially move the Page out of the window if necessary;
Page defaults to in-window, which is wrong in many cases - we depend on
Page::isInWindow being accurate to decide whether WebPage::setIsInWindow is actually
a state change or not.
(WebKit::WebPage::setIsInWindow):
* WebProcess/WebProcess.cpp: Inform WebProcess when we go on/off screen.
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::pageDidMoveOnscreen): Keep track of the number of on-screen pages in this process.
(WebKit::WebProcess::pageWillMoveOffscreen): If the number of on-screen pages drops to zero, clean up unused rendering resources.
* WebProcess/WebProcess.h:
2013-03-26 Dean Jackson <dino@apple.com>
 
When a primary plugin is restarted, also start similar plugins
......@@ -161,6 +161,8 @@ void InitWebCoreSystemInterface(void)
INIT(CreateVMPressureDispatchOnMainQueue);
INIT(DestroyRenderingResources);
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
INIT(ExecutableWasLinkedOnOrBeforeLion);
#endif
......
......@@ -365,6 +365,11 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
setActive(parameters.isActive);
setFocused(parameters.isFocused);
// Page defaults to in-window, but setIsInWindow depends on it being a valid indicator of actually having been put into a window.
if (!parameters.isInWindow)
m_page->setIsInWindow(false);
setIsInWindow(parameters.isInWindow);
m_userAgent = parameters.userAgent;
......@@ -1957,10 +1962,15 @@ inline bool WebPage::canHandleUserEvents() const
void WebPage::setIsInWindow(bool isInWindow)
{
bool pageWasInWindow = m_page->isInWindow();
if (!isInWindow) {
m_setCanStartMediaTimer.stop();
m_page->setCanStartMedia(false);
m_page->willMoveOffscreen();
if (pageWasInWindow)
WebProcess::shared().pageWillLeaveWindow(this);
} else {
// Defer the call to Page::setCanStartMedia() since it ends up sending a synchronous message to the UI process
// in order to get plug-in connections, and the UI process will be waiting for the Web process to update the backing
......@@ -1969,6 +1979,9 @@ void WebPage::setIsInWindow(bool isInWindow)
m_setCanStartMediaTimer.startOneShot(0);
m_page->didMoveOnscreen();
if (!pageWasInWindow)
WebProcess::shared().pageDidEnterWindow(this);
}
m_page->setIsInWindow(isInWindow);
......
......@@ -131,6 +131,9 @@ using namespace WebCore;
// This should be less than plugInAutoStartExpirationTimeThreshold in PlugInAutoStartProvider.
static const double plugInAutoStartExpirationTimeUpdateThreshold = 29 * 24 * 60 * 60;
// This should be greater than tileRevalidationTimeout in TileController.
static const double nonVisibleProcessCleanupDelay = 10;
namespace WebKit {
WebProcess& WebProcess::shared()
......@@ -173,6 +176,8 @@ WebProcess::WebProcess()
#if USE(SOUP)
, m_soupRequestManager(this)
#endif
, m_inWindowPageCount(0)
, m_nonVisibleProcessCleanupTimer(this, &WebProcess::nonVisibleProcessCleanupTimerFired)
{
#if USE(PLATFORM_STRATEGIES)
// Initialize our platform strategies.
......@@ -1098,5 +1103,31 @@ void WebProcess::platformInitializeProcess(const ChildProcessInitializationParam
{
}
#endif
void WebProcess::pageDidEnterWindow(WebPage*)
{
m_inWindowPageCount++;
m_nonVisibleProcessCleanupTimer.stop();
}
void WebProcess::pageWillLeaveWindow(WebPage*)
{
ASSERT(m_inWindowPageCount > 0);
if (m_inWindowPageCount <= 0)
return;
m_inWindowPageCount--;
if (!m_inWindowPageCount)
m_nonVisibleProcessCleanupTimer.startOneShot(nonVisibleProcessCleanupDelay);
}
void WebProcess::nonVisibleProcessCleanupTimerFired(Timer<WebProcess>*)
{
ASSERT(!m_inWindowPageCount);
#if PLATFORM(MAC)
wkDestroyRenderingResources();
#endif
}
} // namespace WebKit
......@@ -36,6 +36,7 @@
#include "TextCheckerState.h"
#include "VisitedLinkTable.h"
#include <WebCore/LinkHash.h>
#include <WebCore/Timer.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
......@@ -178,6 +179,11 @@ public:
void ensurePrivateBrowsingSession();
void destroyPrivateBrowsingSession();
void pageDidEnterWindow(WebPage*);
void pageWillLeaveWindow(WebPage*);
void nonVisibleProcessCleanupTimerFired(WebCore::Timer<WebProcess>*);
private:
WebProcess();
......@@ -329,6 +335,9 @@ private:
#if USE(SOUP)
WebSoupRequestManager m_soupRequestManager;
#endif
int m_inWindowPageCount;
WebCore::Timer<WebProcess> m_nonVisibleProcessCleanupTimer;
};
} // namespace WebKit
......
......@@ -351,7 +351,7 @@ void WKCAContextSetLayer(WKCAContextRef, CALayer *);
CALayer *WKCAContextGetLayer(WKCAContextRef);
void WKCAContextSetColorSpace(WKCAContextRef, CGColorSpaceRef);
CGColorSpaceRef WKCAContextGetColorSpace(WKCAContextRef);
void WKCABackingStoreCollectBlocking(void);
void WKDestroyRenderingResources(void);
void WKCALayerEnumerateRectsBeingDrawnWithBlock(CALayer *layer, CGContextRef context, void (^block)(CGRect rect));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment