Diff
Modified: trunk/Source/WTF/ChangeLog (276472 => 276473)
--- trunk/Source/WTF/ChangeLog 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Source/WTF/ChangeLog 2021-04-22 22:33:20 UTC (rev 276473)
@@ -1,3 +1,14 @@
+2021-04-22 Simon Fraser <[email protected]>
+
+ Add trace points for WKWebView snapshotting
+ https://bugs.webkit.org/show_bug.cgi?id=224943
+
+ Reviewed by Tim Horton.
+
+ New snapshot values.
+
+ * wtf/SystemTracing.h:
+
2021-04-22 Martin Robinson <[email protected]>
[GTK] Turn on editable <input type=date> and <input type=time> fields
Modified: trunk/Source/WTF/wtf/SystemTracing.h (276472 => 276473)
--- trunk/Source/WTF/wtf/SystemTracing.h 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Source/WTF/wtf/SystemTracing.h 2021-04-22 22:33:20 UTC (rev 276473)
@@ -119,6 +119,12 @@
FlushRemoteImageBufferEnd,
CreateInjectedBundleStart,
CreateInjectedBundleEnd,
+ PaintSnapshotStart,
+ PaintSnapshotEnd,
+ RenderServerSnapshotStart,
+ RenderServerSnapshotEnd,
+ TakeSnapshotStart,
+ TakeSnapshotEnd,
UIProcessRange = 14000,
CommitLayerTreeStart,
Modified: trunk/Source/WebKit/ChangeLog (276472 => 276473)
--- trunk/Source/WebKit/ChangeLog 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Source/WebKit/ChangeLog 2021-04-22 22:33:20 UTC (rev 276473)
@@ -1,3 +1,26 @@
+2021-04-22 Simon Fraser <[email protected]>
+
+ Add trace points for WKWebView snapshotting
+ https://bugs.webkit.org/show_bug.cgi?id=224943
+
+ Reviewed by Tim Horton.
+
+ Add new trace points to make snapshotting-related issues easier to diagnose. In the UI
+ process we start/end a trace scope when requested to snapshot, and before calling the
+ client's completion handler.
+
+ Trace CARenderServer snapshots which happen in the UI process, and in the web process, trace
+ the start and end of the snapshot painting.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
+ * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+ (-[_WKThumbnailView requestSnapshot]):
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::paintSnapshotAtSize):
+
2021-04-22 Lauro Moura <[email protected]>
Unreviewed. Guard doesPageNeedTCCD in platform COCOA after r274213
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (276472 => 276473)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-04-22 22:33:20 UTC (rev 276473)
@@ -148,6 +148,7 @@
#import <wtf/NeverDestroyed.h>
#import <wtf/Optional.h>
#import <wtf/RetainPtr.h>
+#import <wtf/SystemTracing.h>
#import <wtf/UUID.h>
#import <wtf/cocoa/VectorCocoa.h>
#import <wtf/spi/darwin/dyldSPI.h>
@@ -1104,6 +1105,9 @@
- (void)takeSnapshotWithConfiguration:(WKSnapshotConfiguration *)snapshotConfiguration completionHandler:(void(^)(CocoaImage *, NSError *))completionHandler
{
+ constexpr bool snapshotFailedTraceValue = false;
+ tracePoint(TakeSnapshotStart);
+
CGRect rectInViewCoordinates = snapshotConfiguration && !CGRectIsNull(snapshotConfiguration.rect) ? snapshotConfiguration.rect : self.bounds;
CGFloat snapshotWidth;
if (snapshotConfiguration)
@@ -1128,6 +1132,7 @@
// in snapshotConfiguration.afterScreenUpdates at that time.
_page->takeSnapshot(WebCore::enclosingIntRect(rectInViewCoordinates), bitmapSize, WebKit::SnapshotOptionsInViewCoordinates, [handler, snapshotWidth, imageHeight](const WebKit::ShareableBitmap::Handle& imageHandle) {
if (imageHandle.isNull()) {
+ tracePoint(TakeSnapshotEnd, snapshotFailedTraceValue);
handler(nil, createNSError(WKErrorUnknown).get());
return;
}
@@ -1134,6 +1139,7 @@
auto bitmap = WebKit::ShareableBitmap::create(imageHandle, WebKit::SharedMemory::Protection::ReadOnly);
RetainPtr<CGImageRef> cgImage = bitmap ? bitmap->makeCGImage() : nullptr;
auto image = adoptNS([[NSImage alloc] initWithCGImage:cgImage.get() size:NSMakeSize(snapshotWidth, imageHeight)]);
+ tracePoint(TakeSnapshotEnd, true);
handler(image.get(), nil);
});
#else
@@ -1148,7 +1154,8 @@
error = createNSError(WKErrorUnknown);
else
image = adoptNS([[UIImage alloc] initWithCGImage:snapshotImage scale:deviceScale orientation:UIImageOrientationUp]);
-
+
+ tracePoint(TakeSnapshotEnd, !!snapshotImage);
handler(image.get(), error.get());
}];
};
@@ -1160,6 +1167,7 @@
_page->callAfterNextPresentationUpdate([callSnapshotRect = WTFMove(callSnapshotRect), handler](WebKit::CallbackBase::Error error) {
if (error != WebKit::CallbackBase::Error::None) {
+ tracePoint(TakeSnapshotEnd, snapshotFailedTraceValue);
handler(nil, createNSError(WKErrorUnknown).get());
return;
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm (276472 => 276473)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm 2021-04-22 22:33:20 UTC (rev 276473)
@@ -36,6 +36,7 @@
#import "WebPageProxy.h"
#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <wtf/NakedPtr.h>
+#import <wtf/SystemTracing.h>
// FIXME: Make it possible to leave a snapshot of the content presented in the WKView while the thumbnail is live.
// FIXME: Don't make new speculative tiles while thumbnailed.
@@ -122,6 +123,7 @@
return;
}
+ tracePoint(TakeSnapshotStart);
_waitingForSnapshot = YES;
RetainPtr<_WKThumbnailView> thumbnailView = self;
@@ -144,6 +146,7 @@
_webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](const WebKit::ShareableBitmap::Handle& imageHandle) {
auto bitmap = WebKit::ShareableBitmap::create(imageHandle, WebKit::SharedMemory::Protection::ReadOnly);
RetainPtr<CGImageRef> cgImage = bitmap ? bitmap->makeCGImage() : nullptr;
+ tracePoint(TakeSnapshotEnd, !!cgImage);
[thumbnailView _didTakeSnapshot:cgImage.get()];
});
}
Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (276472 => 276473)
--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2021-04-22 22:33:20 UTC (rev 276473)
@@ -60,6 +60,7 @@
#import <pal/spi/cocoa/QuartzCoreSPI.h>
#import <pal/spi/ios/GraphicsServicesSPI.h>
#import <wtf/BlockPtr.h>
+#import <wtf/SystemTracing.h>
#import <wtf/cocoa/VectorCocoa.h>
#if ENABLE(DATA_DETECTION)
@@ -3074,6 +3075,7 @@
// If we are parented and not hidden, and thus won't incur a significant penalty from paging in tiles, snapshot the view hierarchy directly.
NSString *displayName = self.window.screen.displayConfiguration.name;
if (displayName && !self.window.hidden) {
+ TraceScope snapshotScope(RenderServerSnapshotStart, RenderServerSnapshotEnd);
auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::sRGBColorSpaceRef());
if (!surface) {
completionHandler(nullptr);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (276472 => 276473)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-04-22 22:33:20 UTC (rev 276473)
@@ -259,6 +259,7 @@
#include <wtf/ProcessID.h>
#include <wtf/RunLoop.h>
#include <wtf/SetForScope.h>
+#include <wtf/SystemTracing.h>
#include <wtf/text/TextStream.h>
#if ENABLE(APP_HIGHLIGHTS)
@@ -2538,6 +2539,8 @@
void WebPage::paintSnapshotAtSize(const IntRect& rect, const IntSize& bitmapSize, SnapshotOptions options, Frame& frame, FrameView& frameView, GraphicsContext& graphicsContext)
{
+ TraceScope snapshotScope(PaintSnapshotStart, PaintSnapshotEnd, options);
+
IntRect snapshotRect = rect;
float horizontalScaleFactor = static_cast<float>(bitmapSize.width()) / rect.width();
float verticalScaleFactor = static_cast<float>(bitmapSize.height()) / rect.height();
Modified: trunk/Tools/ChangeLog (276472 => 276473)
--- trunk/Tools/ChangeLog 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Tools/ChangeLog 2021-04-22 22:33:20 UTC (rev 276473)
@@ -1,3 +1,14 @@
+2021-04-22 Simon Fraser <[email protected]>
+
+ Add trace points for WKWebView snapshotting
+ https://bugs.webkit.org/show_bug.cgi?id=224943
+
+ Reviewed by Tim Horton.
+
+ New snapshot descriptions.
+
+ * Tracing/SystemTracePoints.plist:
+
2021-04-22 Tim Nguyen <[email protected]>
Add "Tim Nguyen" to contributors.json.
Modified: trunk/Tools/Tracing/SystemTracePoints.plist (276472 => 276473)
--- trunk/Tools/Tracing/SystemTracePoints.plist 2021-04-22 22:31:57 UTC (rev 276472)
+++ trunk/Tools/Tracing/SystemTracePoints.plist 2021-04-22 22:33:20 UTC (rev 276473)
@@ -512,6 +512,52 @@
</dict>
<dict>
<key>Name</key>
+ <string>Paint snapshot</string>
+ <key>Type</key>
+ <string>Interval</string>
+ <key>Component</key>
+ <string>47</string>
+ <key>CodeBegin</key>
+ <string>12019</string>
+ <key>CodeEnd</key>
+ <string>12020</string>
+ <key>ArgNamesBegin</key>
+ <dict>
+ <key>Arg1</key>
+ <string>Options</string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Name</key>
+ <string>Render server snapshot</string>
+ <key>Type</key>
+ <string>Interval</string>
+ <key>Component</key>
+ <string>47</string>
+ <key>CodeBegin</key>
+ <string>12021</string>
+ <key>CodeEnd</key>
+ <string>12022</string>
+ </dict>
+ <dict>
+ <key>Name</key>
+ <string>Take snapshot</string>
+ <key>Type</key>
+ <string>Interval</string>
+ <key>Component</key>
+ <string>47</string>
+ <key>CodeBegin</key>
+ <string>12023</string>
+ <key>CodeEnd</key>
+ <string>12024</string>
+ <key>ArgNamesEnd</key>
+ <dict>
+ <key>Arg1</key>
+ <string>Succeeded</string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Name</key>
<string>Commit RemoteLayerTree transaction</string>
<key>Type</key>
<string>Interval</string>