Title: [233480] trunk/Source/WebKit
- Revision
- 233480
- Author
- [email protected]
- Date
- 2018-07-03 14:04:13 -0700 (Tue, 03 Jul 2018)
Log Message
[iOS WK2] We fail to make surfaces volatile when suspending, increasing memory impact
https://bugs.webkit.org/show_bug.cgi?id=187285
rdar://problem/41732391
Reviewed by Tim Horton.
The "Mach port as layer contents" code path used in iOS WK2 relies on replacing the
Mach port layer contents with the actual IOSurface on suspension (otherwise the
live Mach port will keep the surface in use). However, we were never hitting this
RemoteLayerTreeHost::mapAllIOSurfaceBackingStore() code path on iOS 11 and later
because UIKit stopped firing the notification we relied on.
To fix this, use the _UIApplicationDidFinishSuspensionSnapshotNotification notification
which is fired on UIApp.
* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ApplicationStateTracker.mm:
(WebKit::ApplicationStateTracker::ApplicationStateTracker):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (233479 => 233480)
--- trunk/Source/WebKit/ChangeLog 2018-07-03 21:04:10 UTC (rev 233479)
+++ trunk/Source/WebKit/ChangeLog 2018-07-03 21:04:13 UTC (rev 233480)
@@ -1,3 +1,24 @@
+2018-07-03 Simon Fraser <[email protected]>
+
+ [iOS WK2] We fail to make surfaces volatile when suspending, increasing memory impact
+ https://bugs.webkit.org/show_bug.cgi?id=187285
+ rdar://problem/41732391
+
+ Reviewed by Tim Horton.
+
+ The "Mach port as layer contents" code path used in iOS WK2 relies on replacing the
+ Mach port layer contents with the actual IOSurface on suspension (otherwise the
+ live Mach port will keep the surface in use). However, we were never hitting this
+ RemoteLayerTreeHost::mapAllIOSurfaceBackingStore() code path on iOS 11 and later
+ because UIKit stopped firing the notification we relied on.
+
+ To fix this, use the _UIApplicationDidFinishSuspensionSnapshotNotification notification
+ which is fired on UIApp.
+
+ * Platform/spi/ios/UIKitSPI.h:
+ * UIProcess/ApplicationStateTracker.mm:
+ (WebKit::ApplicationStateTracker::ApplicationStateTracker):
+
2018-07-02 Simon Fraser <[email protected]>
Clean up the layer volatility code and logging
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (233479 => 233480)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2018-07-03 21:04:10 UTC (rev 233479)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2018-07-03 21:04:13 UTC (rev 233480)
@@ -104,7 +104,7 @@
#import <UIKit/_UITextDragCaretView.h>
#endif
-#else
+#else // USE(APPLE_INTERNAL_SDK)
#if ENABLE(DRAG_SUPPORT)
#import <UIKit/NSItemProvider+UIKitAdditions.h>
@@ -1029,6 +1029,8 @@
extern const float UITableCellDefaultFontSize;
extern const float UITableViewCellDefaultFontSize;
+extern NSString *const _UIApplicationDidFinishSuspensionSnapshotNotification;
+
extern NSString * const UIWindowDidMoveToScreenNotification;
extern NSString * const UIWindowDidRotateNotification;
extern NSString * const UIWindowNewScreenUserInfoKey;
Modified: trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm (233479 => 233480)
--- trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm 2018-07-03 21:04:10 UTC (rev 233479)
+++ trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm 2018-07-03 21:04:13 UTC (rev 233480)
@@ -94,7 +94,10 @@
ASSERT(window);
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ UIApplication *application = [UIApplication sharedApplication];
+
auto weakThis = makeWeakPtr(*this);
+ // FIXME: this notification never fires any more: rdar://problem/41752351.
m_didCreateWindowContextObserver = [notificationCenter addObserverForName:@"_UIWindowDidCreateWindowContextNotification" object:window queue:nil usingBlock:[weakThis](NSNotification *) {
auto applicationStateTracker = weakThis.get();
if (!applicationStateTracker)
@@ -102,7 +105,7 @@
applicationStateTracker->applicationDidCreateWindowContext();
}];
- m_didFinishSnapshottingAfterEnteringBackgroundObserver = [notificationCenter addObserverForName:@"_UIWindowWillDestroyWindowContextNotification" object:window queue:nil usingBlock:[weakThis](NSNotification *) {
+ m_didFinishSnapshottingAfterEnteringBackgroundObserver = [notificationCenter addObserverForName:@"_UIApplicationDidFinishSuspensionSnapshotNotification" object:application queue:nil usingBlock:[weakThis](NSNotification *) {
auto applicationStateTracker = weakThis.get();
if (!applicationStateTracker)
return;
@@ -111,8 +114,6 @@
switch (applicationType(window)) {
case ApplicationType::Application: {
- UIApplication *application = [UIApplication sharedApplication];
-
m_isInBackground = application.applicationState == UIApplicationStateBackground;
m_didEnterBackgroundObserver = [notificationCenter addObserverForName:UIApplicationDidEnterBackgroundNotification object:application queue:nil usingBlock:[this](NSNotification *) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes