Title: [212260] trunk/Source
Revision
212260
Author
simon.fra...@apple.com
Date
2017-02-13 16:47:41 -0800 (Mon, 13 Feb 2017)

Log Message

Call WKDestroyRenderingResources() on iOS when tabs are backgrounded
https://bugs.webkit.org/show_bug.cgi?id=168261
rdar://problem/30481079

Reviewed by Tim Horton.

Source/WebCore:

Add CABackingStoreCollectBlocking() to QuartzCoreSPI.h, and fix files in WebCore
that do a framework include.

* platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
* platform/graphics/cocoa/WebActionDisablingCALayerDelegate.h:
* platform/spi/cocoa/QuartzCoreSPI.h:
* platform/spi/mac/NSViewSPI.h:

Source/WebKit2:

There's code to call CABackingStoreCollectBlocking() on a 10s timer that exists for Mac, but on iOS
the web processes are suspended before this timer fires. So call CABackingStoreCollectBlocking()
from WebProcess::actualPrepareToSuspend(), which is where we also trigger the markAllLayersVolatile()
code.

Also add CABackingStoreCollectBlocking() to QuartzCoreSPI.h so we can use it without using WKSI.

Release-log how long this takes, in case we get reports of bad performance. In my testing it could be up to 10ms.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::actualPrepareToSuspend):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::destroyRenderingResources):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (212259 => 212260)


--- trunk/Source/WebCore/ChangeLog	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebCore/ChangeLog	2017-02-14 00:47:41 UTC (rev 212260)
@@ -1,3 +1,19 @@
+2017-02-13  Simon Fraser  <simon.fra...@apple.com>
+
+        Call WKDestroyRenderingResources() on iOS when tabs are backgrounded
+        https://bugs.webkit.org/show_bug.cgi?id=168261
+        rdar://problem/30481079
+
+        Reviewed by Tim Horton.
+
+        Add CABackingStoreCollectBlocking() to QuartzCoreSPI.h, and fix files in WebCore
+        that do a framework include.
+
+        * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
+        * platform/graphics/cocoa/WebActionDisablingCALayerDelegate.h:
+        * platform/spi/cocoa/QuartzCoreSPI.h:
+        * platform/spi/mac/NSViewSPI.h:
+
 2017-02-13  Youenn Fablet  <you...@apple.com>
 
         ASSERTION FAILED: !m_bodyLoader

Modified: trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm (212259 => 212260)


--- trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm	2017-02-14 00:47:41 UTC (rev 212260)
@@ -32,7 +32,7 @@
 #include "GraphicsContextCG.h"
 #include "IntRect.h"
 
-#import <WebCore/QuartzCoreSPI.h>
+#import "QuartzCoreSPI.h"
 
 #if PLATFORM(IOS)
 #include "WebCoreThread.h"

Modified: trunk/Source/WebCore/platform/graphics/cocoa/WebActionDisablingCALayerDelegate.h (212259 => 212260)


--- trunk/Source/WebCore/platform/graphics/cocoa/WebActionDisablingCALayerDelegate.h	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebActionDisablingCALayerDelegate.h	2017-02-14 00:47:41 UTC (rev 212260)
@@ -26,7 +26,7 @@
 #ifndef WebActionDisablingCALayerDelegate_h
 #define WebActionDisablingCALayerDelegate_h
 
-#import <WebCore/QuartzCoreSPI.h>
+#import "QuartzCoreSPI.h"
 
 WEBCORE_EXPORT @interface WebActionDisablingCALayerDelegate : NSObject <CALayerDelegate>
 

Modified: trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h (212259 => 212260)


--- trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2017-02-14 00:47:41 UTC (rev 212260)
@@ -28,6 +28,7 @@
 
 #if USE(APPLE_INTERNAL_SDK)
 
+#include <QuartzCore/CABackingStore.h>
 #include <QuartzCore/CAColorMatrix.h>
 #include <QuartzCore/CARenderServer.h>
 
@@ -192,6 +193,8 @@
 mach_port_t CAMachPortGetPort(CAMachPortRef);
 CFTypeID CAMachPortGetTypeID(void);
 
+void CABackingStoreCollectBlocking(void);
+
 WTF_EXTERN_C_END
 
 extern NSString * const kCATiledLayerRemoveImmediately;
@@ -235,4 +238,5 @@
 
 @protocol CAAnimationDelegate <NSObject>
 @end
-#endif
+
+#endif // USE(APPLE_INTERNAL_SDK)

Modified: trunk/Source/WebCore/platform/spi/mac/NSViewSPI.h (212259 => 212260)


--- trunk/Source/WebCore/platform/spi/mac/NSViewSPI.h	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebCore/platform/spi/mac/NSViewSPI.h	2017-02-14 00:47:41 UTC (rev 212260)
@@ -25,7 +25,7 @@
 
 #if USE(APPKIT)
 
-#import <WebCore/QuartzCoreSPI.h>
+#import "QuartzCoreSPI.h"
 
 @interface NSView () <CALayerDelegate>
 @end

Modified: trunk/Source/WebKit2/ChangeLog (212259 => 212260)


--- trunk/Source/WebKit2/ChangeLog	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-14 00:47:41 UTC (rev 212260)
@@ -1,3 +1,25 @@
+2017-02-13  Simon Fraser  <simon.fra...@apple.com>
+
+        Call WKDestroyRenderingResources() on iOS when tabs are backgrounded
+        https://bugs.webkit.org/show_bug.cgi?id=168261
+        rdar://problem/30481079
+
+        Reviewed by Tim Horton.
+
+        There's code to call CABackingStoreCollectBlocking() on a 10s timer that exists for Mac, but on iOS
+        the web processes are suspended before this timer fires. So call CABackingStoreCollectBlocking()
+        from WebProcess::actualPrepareToSuspend(), which is where we also trigger the markAllLayersVolatile()
+        code.
+
+        Also add CABackingStoreCollectBlocking() to QuartzCoreSPI.h so we can use it without using WKSI.
+
+        Release-log how long this takes, in case we get reports of bad performance. In my testing it could be up to 10ms.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::actualPrepareToSuspend):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::destroyRenderingResources):
+
 2017-02-13  Brady Eidson  <beid...@apple.com>
 
         Followup to: Replace all WebKit Library Version checks in WK2 with SDK version checks.

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (212259 => 212260)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2017-02-14 00:47:41 UTC (rev 212260)
@@ -1272,6 +1272,10 @@
         MemoryPressureHandler::singleton().releaseMemory(Critical::Yes, Synchronous::Yes);
 
     setAllLayerTreeStatesFrozen(true);
+    
+#if PLATFORM(COCOA)
+    destroyRenderingResources();
+#endif
 
     markAllLayersVolatile([this, shouldAcknowledgeWhenReadyToSuspend] {
         RELEASE_LOG(ProcessSuspension, "%p - WebProcess::markAllLayersVolatile() Successfuly marked all layers as volatile", this);

Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm (212259 => 212260)


--- trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm	2017-02-14 00:44:54 UTC (rev 212259)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm	2017-02-14 00:47:41 UTC (rev 212260)
@@ -27,6 +27,7 @@
 #import "WebProcess.h"
 
 #import "CustomProtocolManager.h"
+#import "Logging.h"
 #import "ObjCObjectGraph.h"
 #import "SandboxExtension.h"
 #import "SandboxInitializationParameters.h"
@@ -52,6 +53,7 @@
 #import <WebCore/MemoryRelease.h>
 #import <WebCore/NSAccessibilitySPI.h>
 #import <WebCore/PerformanceLogging.h>
+#import <WebCore/QuartzCoreSPI.h>
 #import <WebCore/RuntimeApplicationChecks.h>
 #import <WebCore/WebCoreNSURLExtras.h>
 #import <WebCore/pthreadSPI.h>
@@ -435,7 +437,14 @@
 
 void WebProcess::destroyRenderingResources()
 {
-    WKDestroyRenderingResources();
+#if !RELEASE_LOG_DISABLED
+    double startTime = monotonicallyIncreasingTime();
+#endif
+    CABackingStoreCollectBlocking();
+#if !RELEASE_LOG_DISABLED
+    double endTime = monotonicallyIncreasingTime();
+#endif
+    RELEASE_LOG(ProcessSuspension, "%p - WebProcess::destroyRenderingResources() took %.2fms", this, (endTime - startTime) * 1000.0);
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to