RESOLVED FIXED 169421
Implement PlatformWebView::windowSnapshotImage and createBitmapContextFromWebView for iOS devices
https://bugs.webkit.org/show_bug.cgi?id=169421
Summary Implement PlatformWebView::windowSnapshotImage and createBitmapContextFromWeb...
Jonathan Bedard
Reported 2017-03-09 10:12:12 PST
Currently, iOS devices do not have an implementation of PlatformWebView::windowSnapshotImage. This needs to be implemented for running ImageDiff tests on iOS devices.
Attachments
Patch (1.74 KB, patch)
2017-03-09 10:18 PST, Jonathan Bedard
no flags
Patch (3.44 KB, patch)
2017-03-10 10:09 PST, Jonathan Bedard
no flags
Patch (9.17 KB, patch)
2017-03-13 12:01 PDT, Jonathan Bedard
no flags
Archive of layout-test-results from ews124 for ios-simulator-wk2 (1.14 MB, application/zip)
2017-03-13 13:22 PDT, Build Bot
no flags
Patch (10.16 KB, patch)
2017-03-17 10:10 PDT, Jonathan Bedard
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (1.02 MB, application/zip)
2017-03-17 11:41 PDT, Build Bot
no flags
Patch (10.04 KB, patch)
2017-04-11 15:15 PDT, Jonathan Bedard
no flags
Patch (10.17 KB, patch)
2017-04-11 16:01 PDT, Jonathan Bedard
no flags
Archive of layout-test-results from ews124 for ios-simulator-wk2 (14.07 MB, application/zip)
2017-04-11 17:36 PDT, Build Bot
no flags
Patch (11.97 KB, patch)
2017-04-12 09:10 PDT, Jonathan Bedard
no flags
Patch (11.91 KB, patch)
2017-04-13 09:31 PDT, Jonathan Bedard
no flags
Patch (12.04 KB, patch)
2017-05-05 10:57 PDT, Jonathan Bedard
no flags
Patch (9.91 KB, patch)
2017-05-05 15:19 PDT, Jonathan Bedard
no flags
Patch (10.19 KB, patch)
2017-05-05 15:28 PDT, Jonathan Bedard
no flags
Patch (7.15 KB, patch)
2017-05-05 17:35 PDT, Jonathan Bedard
no flags
Patch (7.09 KB, patch)
2017-05-08 14:52 PDT, Jonathan Bedard
no flags
Radar WebKit Bug Importer
Comment 1 2017-03-09 10:12:55 PST
Jonathan Bedard
Comment 2 2017-03-09 10:18:06 PST
Jonathan Bedard
Comment 3 2017-03-10 10:09:01 PST
Tim Horton
Comment 4 2017-03-10 14:21:31 PST
Comment on attachment 304051 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=304051&action=review > Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm:60 > + CGSize viewSize = [[mainFrame webView] frame].size; You should use CARenderServerRenderLayerWithTransform into an IOSurface and make a CGImage from the IOSurface. > Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:263 > + RetainPtr<CGImageRef> cgImage = adoptCF(CGBitmapContextCreateImage(context)); Here you can use CARenderServerRenderLayerWithTransform like we do in WKWebView (not the YUV part, but the rest) or maybe try the WK2 snapshotting API which just does that. renderInContext: is comparatively slow and imperfect.
Tim Horton
Comment 5 2017-03-10 14:24:46 PST
(In reply to comment #4) > Comment on attachment 304051 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=304051&action=review > > > Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm:60 > > + CGSize viewSize = [[mainFrame webView] frame].size; > > You should use CARenderServerRenderLayerWithTransform into an IOSurface and > make a CGImage from the IOSurface. > > > Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:263 > > + RetainPtr<CGImageRef> cgImage = adoptCF(CGBitmapContextCreateImage(context)); > > Here you can use CARenderServerRenderLayerWithTransform like we do in > WKWebView (not the YUV part, but the rest) or maybe try the WK2 snapshotting > API which just does that. renderInContext: is comparatively slow and > imperfect. If you use the WK2 snapshotting API you can probably remove the #if and just use one codepath (though WK2 will decide internally between a number of different options).
Jonathan Bedard
Comment 6 2017-03-13 12:01:41 PDT
Build Bot
Comment 7 2017-03-13 13:22:02 PDT
Comment on attachment 304282 [details] Patch Attachment 304282 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3309499 New failing tests: compositing/regions/position-layers-inside-region-overflow-hidden.html fast/harness/snapshot-captures-compositing.html compositing/regions/position-layer-inside-region-overflow-hidden.html compositing/hidpi-subpixel-transform-origin.html compositing/regions/position-layers-inside-regions-overflow-hidden.html compositing/geometry/clipped-out-perspective.html
Build Bot
Comment 8 2017-03-13 13:22:05 PDT
Created attachment 304291 [details] Archive of layout-test-results from ews124 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews124 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Tim Horton
Comment 9 2017-03-13 13:41:22 PDT
Something bad is happening with the software painting path. For now, just put the new WK2 code inside the #if USE(IOSURFACE) and put the sim-specific code back in the #else block in WKTR.
Jonathan Bedard
Comment 10 2017-03-17 10:10:53 PDT
Build Bot
Comment 11 2017-03-17 11:41:48 PDT
Comment on attachment 304790 [details] Patch Attachment 304790 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3350655 New failing tests: compositing/regions/position-layers-inside-region-overflow-hidden.html fast/harness/snapshot-captures-compositing.html compositing/regions/position-layer-inside-region-overflow-hidden.html compositing/hidpi-subpixel-transform-origin.html compositing/regions/position-layers-inside-regions-overflow-hidden.html compositing/geometry/clipped-out-perspective.html
Build Bot
Comment 12 2017-03-17 11:41:51 PDT
Created attachment 304801 [details] Archive of layout-test-results from ews126 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews126 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Jonathan Bedard
Comment 13 2017-04-11 15:15:13 PDT
Jonathan Bedard
Comment 14 2017-04-11 16:01:29 PDT
Build Bot
Comment 15 2017-04-11 17:36:04 PDT
Comment on attachment 306870 [details] Patch Attachment 306870 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/3520867 New failing tests: compositing/regions/position-layers-inside-region-overflow-hidden.html fast/harness/snapshot-captures-compositing.html compositing/regions/position-layer-inside-region-overflow-hidden.html compositing/hidpi-subpixel-transform-origin.html compositing/regions/position-layers-inside-regions-overflow-hidden.html compositing/geometry/clipped-out-perspective.html
Build Bot
Comment 16 2017-04-11 17:36:05 PDT
Created attachment 306878 [details] Archive of layout-test-results from ews124 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews124 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Jonathan Bedard
Comment 17 2017-04-12 08:14:59 PDT
(In reply to Build Bot from comment #15) > Comment on attachment 306870 [details] > Patch > > Attachment 306870 [details] did not pass ios-sim-ews (ios-simulator-wk2): > Output: http://webkit-queues.webkit.org/results/3520867 > > New failing tests: > compositing/regions/position-layers-inside-region-overflow-hidden.html > fast/harness/snapshot-captures-compositing.html > compositing/regions/position-layer-inside-region-overflow-hidden.html > compositing/hidpi-subpixel-transform-origin.html > compositing/regions/position-layers-inside-regions-overflow-hidden.html > compositing/geometry/clipped-out-perspective.html Looking at these failures, this seems to be a bug in the WK2 snapshot code. Our reference images are consistent with what is shown on the screen of a device.
Jonathan Bedard
Comment 18 2017-04-12 09:10:21 PDT
Jonathan Bedard
Comment 19 2017-04-13 09:31:29 PDT
Jonathan Bedard
Comment 20 2017-05-05 10:57:38 PDT
Jonathan Bedard
Comment 21 2017-05-05 10:58:24 PDT
(In reply to Jonathan Bedard from comment #20) > Created attachment 309183 [details] > Patch Updating this patch so it is up-to-date with the repository
Tim Horton
Comment 22 2017-05-05 13:03:57 PDT
Comment on attachment 309183 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309183&action=review > LayoutTests/platform/ios/TestExpectations:2960 > +compositing/geometry/clipped-out-perspective.html [ ImageOnlyFailure ] > +compositing/hidpi-subpixel-transform-origin.html [ ImageOnlyFailure ] > +compositing/regions/position-layer-inside-region-overflow-hidden.html [ ImageOnlyFailure ] > +compositing/regions/position-layers-inside-region-overflow-hidden.html [ ImageOnlyFailure ] > +compositing/regions/position-layers-inside-regions-overflow-hidden.html [ ImageOnlyFailure ] You should talk to Simon about these. Otherwise, maybe split this into the completely non-contentious part (and use my review for that) and make a new patch for the other bit.
Simon Fraser (smfr)
Comment 23 2017-05-05 14:26:17 PDT
Comment on attachment 309183 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309183&action=review > Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:266 > + [m_view > + takeSnapshotWithConfiguration:snapshotConfiguration.get() Don't split this here. >> LayoutTests/platform/ios/TestExpectations:2960 >> +compositing/regions/position-layers-inside-regions-overflow-hidden.html [ ImageOnlyFailure ] > > You should talk to Simon about these. > > Otherwise, maybe split this into the completely non-contentious part (and use my review for that) and make a new patch for the other bit. These need to go into a device-specific TE file.
Jonathan Bedard
Comment 24 2017-05-05 15:19:55 PDT
Jonathan Bedard
Comment 25 2017-05-05 15:28:06 PDT
Simon Fraser (smfr)
Comment 26 2017-05-05 15:43:35 PDT
Comment on attachment 309224 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309224&action=review > Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm:84 > + RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(bufferWidth, bufferHeight, 8, 32, rowBytes, sRGBSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, provider, 0, false, kCGRenderingIntentDefault)); I'm not sure this will do the right thing if WebCore::screenSupportsExtendedColor() above cause you to make a 10-bit surface. Here you're assuming it's sRGB, 8-bit. Does the snapshot work on a iPhone7 test? > Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:273 > + completionHandler:^(UIImage* snapshotImage, NSError *error) { completionHandler: should go on the previous line.
Tim Horton
Comment 27 2017-05-05 15:45:12 PDT
Comment on attachment 309224 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309224&action=review >> Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm:84 >> + RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(bufferWidth, bufferHeight, 8, 32, rowBytes, sRGBSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, provider, 0, false, kCGRenderingIntentDefault)); > > I'm not sure this will do the right thing if WebCore::screenSupportsExtendedColor() above cause you to make a 10-bit surface. Here you're assuming it's sRGB, 8-bit. Does the snapshot work on a iPhone7 test? Err, actually, could we use WebCore::IOSurface here? Or CGIOSurfaceContextCreateImage, like it does?
Jonathan Bedard
Comment 28 2017-05-05 15:57:19 PDT
Comment on attachment 309224 [details] Patch Making the changes you've both suggested (I think Tim's surface.createImage() renders Simon's comment about the 7 moot) but I need to rebuild to confirm them, so it's going to be a bit.
Jonathan Bedard
Comment 29 2017-05-05 17:35:31 PDT
Tim Horton
Comment 30 2017-05-08 14:33:03 PDT
Comment on attachment 309248 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=309248&action=review > Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:269 > + [snapshotConfiguration setRect:NSMakeRect(0, 0, m_view.frame.size.width, m_view.frame.size.height)]; CGRectMake > Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:272 > + [m_view takeSnapshotWithConfiguration:snapshotConfiguration.get() completionHandler:^(UIImage* snapshotImage, NSError *error) { Stars on the wrong side :) > Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm:278 > + while (!isDone) > + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]; Don't we have a wrapper for this? If not, it's fine.
Jonathan Bedard
Comment 31 2017-05-08 14:52:22 PDT
WebKit Commit Bot
Comment 32 2017-05-08 16:15:03 PDT
Comment on attachment 309417 [details] Patch Clearing flags on attachment: 309417 Committed r216462: <http://trac.webkit.org/changeset/216462>
WebKit Commit Bot
Comment 33 2017-05-08 16:15:05 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.