Bug 221662
Summary: | WKWebView's -takeSnapshotWithConfiguration:completionHandler: can't capture GPU rendering features | ||
---|---|---|---|
Product: | WebKit | Reporter: | Jonathan Deutsch <jonathan> |
Component: | WebKit API | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Critical | CC: | achristensen, ggaren, jonathan, thorton, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 14 | ||
Hardware: | Mac (Apple Silicon) | ||
OS: | macOS 11 |
Jonathan Deutsch
Snapshots can't capture 3D perspective, filter effects, reflection, etc.
Using the -[NSView cacheDisplayInRect:toBitmapImageRep:] doesn't get the view at all; the only workaround seems to be to make another WKWebView with a copy of the content/DOM in a mostly offscreen window (1px must show) and use CGWindowListCreateImage(). This isn't desirable for several reasons such as performance and issues in recreating the view accurately.
Apps like Tumult Hype [https://tumult.com/hype/] need to take web view snapshots for many reasons like thumbnails, poster images, video export, etc. Being unable to capture the web view in use is a significant hurdle.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Tim Horton
Unfortunately since CGWindowListCreateImage and friends are the primary way to do this on macOS, and WebKit doesn’t know the rest of the contents of the window, this is not easy to fix (at least, not without sometimes getting random non-WebKit content in the snapshot).
WebKit gets around this on iOS by using CARenderServer mechanisms to snapshot a subtree of layers.
For now you’re likely best off with your hand rolled snapshotting solution (since you can guarantee nothing overlaps the web view in the snapshot), but do know that we are aware of this limitation.
Radar WebKit Bug Importer
<rdar://problem/74423427>