Title: [196753] trunk/Source/WebCore
- Revision
- 196753
- Author
- [email protected]
- Date
- 2016-02-18 03:13:02 -0800 (Thu, 18 Feb 2016)
Log Message
Reduce tiling coverage immediately when memory pressure hits.
<https://webkit.org/b/154374>
Reviewed by Simon Fraser.
We already had a policy that reduced tiling coverage to a minimum while the system
is under memory pressure. However, that policy wouldn't kick in immediately after
receiving the pressure notification, but the next time we flush compositing state.
This change makes it happen sooner, improving our chances to escape death!
* page/Page.h:
* page/Page.cpp:
(WebCore::Page::forEachPage):
Add a little helper for visiting every Page.
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::releaseCriticalMemory):
When under critical memory pressure, schedule a compositing flush in all Pages.
This ensures that the reduced tiling coverage policy takes effect, allowing us to
immediately drop several tiles in each visible web view.
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::install):
To ensure that this behavior is testable with the fake memory pressure notification,
make the fake handler set the "in memory pressure" state just like the real one would.
I don't know why we were not doing this previously, it was just an oversight.
After the simulation completes, it schedules a runloop callback that resets the
"in memory pressure" state.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (196752 => 196753)
--- trunk/Source/WebCore/ChangeLog 2016-02-18 10:34:47 UTC (rev 196752)
+++ trunk/Source/WebCore/ChangeLog 2016-02-18 11:13:02 UTC (rev 196753)
@@ -1,3 +1,38 @@
+2016-02-18 Andreas Kling <[email protected]>
+
+ Reduce tiling coverage immediately when memory pressure hits.
+ <https://webkit.org/b/154374>
+
+ Reviewed by Simon Fraser.
+
+ We already had a policy that reduced tiling coverage to a minimum while the system
+ is under memory pressure. However, that policy wouldn't kick in immediately after
+ receiving the pressure notification, but the next time we flush compositing state.
+
+ This change makes it happen sooner, improving our chances to escape death!
+
+ * page/Page.h:
+ * page/Page.cpp:
+ (WebCore::Page::forEachPage):
+
+ Add a little helper for visiting every Page.
+
+ * platform/MemoryPressureHandler.cpp:
+ (WebCore::MemoryPressureHandler::releaseCriticalMemory):
+
+ When under critical memory pressure, schedule a compositing flush in all Pages.
+ This ensures that the reduced tiling coverage policy takes effect, allowing us to
+ immediately drop several tiles in each visible web view.
+
+ * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+ (WebCore::MemoryPressureHandler::install):
+
+ To ensure that this behavior is testable with the fake memory pressure notification,
+ make the fake handler set the "in memory pressure" state just like the real one would.
+ I don't know why we were not doing this previously, it was just an oversight.
+ After the simulation completes, it schedules a runloop callback that resets the
+ "in memory pressure" state.
+
2016-02-17 Myles C. Maxfield <[email protected]>
[Font Loading] Implement FontFaceSet
Modified: trunk/Source/WebCore/page/Page.cpp (196752 => 196753)
--- trunk/Source/WebCore/page/Page.cpp 2016-02-18 10:34:47 UTC (rev 196752)
+++ trunk/Source/WebCore/page/Page.cpp 2016-02-18 11:13:02 UTC (rev 196753)
@@ -126,6 +126,14 @@
DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page"));
+void Page::forEachPage(std::function<void(Page&)> function)
+{
+ if (!allPages)
+ return;
+ for (Page* page : *allPages)
+ function(*page);
+}
+
static void networkStateChanged(bool isOnLine)
{
Vector<Ref<Frame>> frames;
Modified: trunk/Source/WebCore/page/Page.h (196752 => 196753)
--- trunk/Source/WebCore/page/Page.h 2016-02-18 10:34:47 UTC (rev 196752)
+++ trunk/Source/WebCore/page/Page.h 2016-02-18 11:13:02 UTC (rev 196753)
@@ -176,6 +176,8 @@
PageGroup& group();
PageGroup* groupPtr() { return m_group; } // can return 0
+ static void forEachPage(std::function<void(Page&)>);
+
void incrementSubframeCount() { ++m_subframeCount; }
void decrementSubframeCount() { ASSERT(m_subframeCount); --m_subframeCount; }
int subframeCount() const { checkSubframeCountConsistency(); return m_subframeCount; }
Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (196752 => 196753)
--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2016-02-18 10:34:47 UTC (rev 196752)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2016-02-18 11:13:02 UTC (rev 196753)
@@ -27,6 +27,8 @@
#include "MemoryPressureHandler.h"
#include "CSSValuePool.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
#include "DOMWindow.h"
#include "Document.h"
#include "FontCache.h"
@@ -156,6 +158,11 @@
GCController::singleton().garbageCollectNow();
} else
GCController::singleton().garbageCollectNowIfNotDoneRecently();
+
+ // We reduce tiling coverage while under memory pressure, so make sure to drop excess tiles ASAP.
+ Page::forEachPage([](Page& page) {
+ page.chrome().client().scheduleCompositingLayerFlush();
+ });
}
void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous)
Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (196752 => 196753)
--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm 2016-02-18 10:34:47 UTC (rev 196752)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm 2016-02-18 11:13:02 UTC (rev 196753)
@@ -128,11 +128,19 @@
// Allow simulation of memory pressure with "notifyutil -p org.WebKit.lowMemory"
notify_register_dispatch("org.WebKit.lowMemory", &_notifyToken, dispatch_get_main_queue(), ^(int) {
+ bool wasUnderMemoryPressure = m_underMemoryPressure;
+ m_underMemoryPressure = true;
+
MemoryPressureHandler::singleton().respondToMemoryPressure(Critical::Yes, Synchronous::Yes);
WTF::releaseFastMallocFreeMemory();
malloc_zone_pressure_relief(nullptr, 0);
+
+ // Since this is a simulation, unset the "under memory pressure" flag on next runloop.
+ dispatch_async(dispatch_get_main_queue(), ^{
+ MemoryPressureHandler::singleton().setUnderMemoryPressure(wasUnderMemoryPressure);
+ });
});
m_installed = true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes