From: akling@apple.com Date: Wed, 5 Apr 2017 22:55:25 +0000 (+0000) Subject: Make inactive web processes behave as though under memory pressure. X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=73daa8a4423092f91da0243bab8a1606261ffc15 Make inactive web processes behave as though under memory pressure. https://bugs.webkit.org/show_bug.cgi?id=170042 Reviewed by Antti Koivisto. Source/WebCore: Prevent PerformanceMonitor from marking the process as inactive at startup. This fixes the API test failure that caused this patch to get rolled out. * page/PerformanceMonitor.h: Source/WTF: Once a web process becomes inactive, let's try to reduce its impact on memory usage by treating it as if it's under memory pressure until it becomes active. * wtf/MemoryPressureHandler.cpp: (WTF::MemoryPressureHandler::setProcessState): (WTF::MemoryPressureHandler::isUnderMemoryPressure): * wtf/MemoryPressureHandler.h: (WTF::MemoryPressureHandler::isUnderMemoryPressure): Deleted. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214974 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog index 14e0936..7f513cc 100644 --- a/Source/WTF/ChangeLog +++ b/Source/WTF/ChangeLog @@ -1,3 +1,21 @@ +2017-04-05 Andreas Kling + + Make inactive web processes behave as though under memory pressure. + https://bugs.webkit.org/show_bug.cgi?id=170042 + + + Reviewed by Antti Koivisto. + + Once a web process becomes inactive, let's try to reduce its impact + on memory usage by treating it as if it's under memory pressure until + it becomes active. + + * wtf/MemoryPressureHandler.cpp: + (WTF::MemoryPressureHandler::setProcessState): + (WTF::MemoryPressureHandler::isUnderMemoryPressure): + * wtf/MemoryPressureHandler.h: + (WTF::MemoryPressureHandler::isUnderMemoryPressure): Deleted. + 2017-04-05 Yusuke Suzuki [JSC] Suppress warnings in GCC diff --git a/Source/WTF/wtf/MemoryPressureHandler.cpp b/Source/WTF/wtf/MemoryPressureHandler.cpp index 4663302..bf9a075 100644 --- a/Source/WTF/wtf/MemoryPressureHandler.cpp +++ b/Source/WTF/wtf/MemoryPressureHandler.cpp @@ -171,6 +171,9 @@ void MemoryPressureHandler::setProcessState(WebsamProcessState state) if (m_processState == state) return; m_processState = state; + memoryPressureStatusChanged(); + if (m_processState == WebsamProcessState::Inactive) + respondToMemoryPressure(Critical::Yes, Synchronous::No); } void MemoryPressureHandler::beginSimulatedMemoryPressure() @@ -190,6 +193,17 @@ void MemoryPressureHandler::endSimulatedMemoryPressure() memoryPressureStatusChanged(); } +bool MemoryPressureHandler::isUnderMemoryPressure() +{ + auto& memoryPressureHandler = singleton(); + return memoryPressureHandler.m_underMemoryPressure +#if PLATFORM(MAC) + || memoryPressureHandler.m_memoryUsagePolicy >= MemoryUsagePolicy::Strict + || memoryPressureHandler.m_processState == WebsamProcessState::Inactive +#endif + || memoryPressureHandler.m_isSimulatingMemoryPressure; +} + void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous) { if (!m_lowMemoryHandler) diff --git a/Source/WTF/wtf/MemoryPressureHandler.h b/Source/WTF/wtf/MemoryPressureHandler.h index 44dbc56..61751b1 100644 --- a/Source/WTF/wtf/MemoryPressureHandler.h +++ b/Source/WTF/wtf/MemoryPressureHandler.h @@ -79,14 +79,7 @@ public: m_lowMemoryHandler = WTFMove(handler); } - bool isUnderMemoryPressure() const - { - return m_underMemoryPressure -#if PLATFORM(MAC) - || m_memoryUsagePolicy >= MemoryUsagePolicy::Strict -#endif - || m_isSimulatingMemoryPressure; - } + WTF_EXPORT_PRIVATE static bool isUnderMemoryPressure(); void setUnderMemoryPressure(bool); #if OS(LINUX) @@ -184,7 +177,7 @@ private: }; #endif - WebsamProcessState m_processState { WebsamProcessState::Inactive }; + WebsamProcessState m_processState { WebsamProcessState::Active }; bool m_installed { false }; LowMemoryHandler m_lowMemoryHandler; diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 065380d..6547f81 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,16 @@ +2017-04-05 Andreas Kling + + Make inactive web processes behave as though under memory pressure. + https://bugs.webkit.org/show_bug.cgi?id=170042 + + + Reviewed by Antti Koivisto. + + Prevent PerformanceMonitor from marking the process as inactive at startup. + This fixes the API test failure that caused this patch to get rolled out. + + * page/PerformanceMonitor.h: + 2017-04-05 Youenn Fablet Switch to kCVPixelFormatType_420YpCbCr8BiPlanarFullRange for Mac video capture format diff --git a/Source/WebCore/page/PerformanceMonitor.h b/Source/WebCore/page/PerformanceMonitor.h index c4b4cea..afc2924 100644 --- a/Source/WebCore/page/PerformanceMonitor.h +++ b/Source/WebCore/page/PerformanceMonitor.h @@ -65,7 +65,7 @@ private: Timer m_postBackgroundingMemoryUsageTimer; Timer m_processMayBecomeInactiveTimer; - bool m_processMayBecomeInactive { true }; + bool m_processMayBecomeInactive { false }; }; }