Bug 169547 - REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
Summary: REGRESSION (r213764): Background image from sprite sheet incorrectly scaled
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Macintosh macOS 10.12
: P1 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
: 169574 (view as bug list)
Depends on: 169771
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-13 03:04 PDT by Jamie White
Modified: 2017-03-31 12:26 PDT (History)
10 users (show)

See Also:


Attachments
Minimal HTML demonstrating the bug (284 bytes, text/html)
2017-03-13 03:04 PDT, Jamie White
no flags Details
Demo video (45.97 KB, image/gif)
2017-03-13 03:04 PDT, Jamie White
no flags Details
Patch (19.66 KB, patch)
2017-03-13 14:27 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews116 for mac-elcapitan (1.80 MB, application/zip)
2017-03-13 15:49 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews103 for mac-elcapitan (1.09 MB, application/zip)
2017-03-13 16:06 PDT, Build Bot
no flags Details
Patch (19.65 KB, patch)
2017-03-13 16:49 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews113 for mac-elcapitan (1.62 MB, application/zip)
2017-03-13 17:57 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews102 for mac-elcapitan (911.90 KB, application/zip)
2017-03-13 18:05 PDT, Build Bot
no flags Details
Patch (15.80 KB, patch)
2017-03-14 09:42 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (15.87 KB, patch)
2017-03-14 10:51 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (15.87 KB, patch)
2017-03-14 11:23 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-elcapitan (753.67 KB, application/zip)
2017-03-14 12:37 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews116 for mac-elcapitan (1.67 MB, application/zip)
2017-03-14 17:05 PDT, Build Bot
no flags Details
Patch (16.27 KB, patch)
2017-03-14 22:14 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (16.73 KB, patch)
2017-03-14 23:11 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-elcapitan (970.94 KB, application/zip)
2017-03-15 00:26 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews114 for mac-elcapitan (1.67 MB, application/zip)
2017-03-15 00:34 PDT, Build Bot
no flags Details
Patch (12.78 KB, patch)
2017-03-15 08:44 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (19.14 KB, patch)
2017-03-28 15:25 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-elcapitan (989.93 KB, application/zip)
2017-03-28 16:41 PDT, Build Bot
no flags Details
Patch (21.06 KB, patch)
2017-03-28 16:42 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews115 for mac-elcapitan (1.80 MB, application/zip)
2017-03-28 18:14 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews102 for mac-elcapitan (929.12 KB, application/zip)
2017-03-28 18:17 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews122 for ios-simulator-wk2 (1.03 MB, application/zip)
2017-03-28 18:39 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (1.03 MB, application/zip)
2017-03-28 18:45 PDT, Build Bot
no flags Details
Patch (25.63 KB, patch)
2017-03-29 10:17 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (1000.96 KB, application/zip)
2017-03-29 11:25 PDT, Build Bot
no flags Details
Patch (25.62 KB, patch)
2017-03-29 11:31 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews117 for mac-elcapitan (1.85 MB, application/zip)
2017-03-29 12:51 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews100 for mac-elcapitan (1.04 MB, application/zip)
2017-03-29 12:51 PDT, Build Bot
no flags Details
Patch (26.46 KB, patch)
2017-03-29 13:14 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-elcapitan (1.04 MB, application/zip)
2017-03-29 14:09 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews113 for mac-elcapitan (1.90 MB, application/zip)
2017-03-29 14:21 PDT, Build Bot
no flags Details
Patch (27.78 KB, patch)
2017-03-29 14:47 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews126 for ios-simulator-wk2 (2.69 MB, application/zip)
2017-03-29 16:16 PDT, Build Bot
no flags Details
Patch (29.27 KB, patch)
2017-03-29 18:08 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-elcapitan (1.16 MB, application/zip)
2017-03-29 19:19 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews115 for mac-elcapitan (1.84 MB, application/zip)
2017-03-29 19:26 PDT, Build Bot
no flags Details
Patch (31.79 KB, patch)
2017-03-30 12:03 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (31.91 KB, patch)
2017-03-30 14:57 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie White 2017-03-13 03:04:05 PDT
Created attachment 304246 [details]
Minimal HTML demonstrating the bug

The reproduction is extracted from Slack, which uses a large sprite sheet for its emojis. On the current nightly, the sprites in question appear to be scaled much larger than is intended. To demonstrate the effect: load the sample page and resize the browser window.
Comment 1 Jamie White 2017-03-13 03:04:48 PDT
Created attachment 304247 [details]
Demo video
Comment 2 Radar WebKit Bug Importer 2017-03-13 09:39:09 PDT
<rdar://problem/31011842>
Comment 3 Said Abou-Hallawa 2017-03-13 14:27:13 PDT
Created attachment 304302 [details]
Patch
Comment 4 Said Abou-Hallawa 2017-03-13 14:27:47 PDT
Comment on attachment 304302 [details]
Patch

This patch is for EWS.
Comment 5 Build Bot 2017-03-13 15:49:45 PDT
Comment on attachment 304302 [details]
Patch

Attachment 304302 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3310670

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 6 Build Bot 2017-03-13 15:49:48 PDT
Created attachment 304315 [details]
Archive of layout-test-results from ews116 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 7 Build Bot 2017-03-13 16:06:07 PDT
Comment on attachment 304302 [details]
Patch

Attachment 304302 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3310856

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 8 Build Bot 2017-03-13 16:06:11 PDT
Created attachment 304316 [details]
Archive of layout-test-results from ews103 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 9 Said Abou-Hallawa 2017-03-13 16:49:31 PDT
Created attachment 304324 [details]
Patch
Comment 10 Build Bot 2017-03-13 17:57:18 PDT
Comment on attachment 304324 [details]
Patch

Attachment 304324 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3311648

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 11 Build Bot 2017-03-13 17:57:22 PDT
Created attachment 304326 [details]
Archive of layout-test-results from ews113 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 12 Build Bot 2017-03-13 18:05:29 PDT
Comment on attachment 304324 [details]
Patch

Attachment 304324 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3311784

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 13 Build Bot 2017-03-13 18:05:33 PDT
Created attachment 304328 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 14 Said Abou-Hallawa 2017-03-14 09:42:21 PDT
Created attachment 304388 [details]
Patch
Comment 15 Said Abou-Hallawa 2017-03-14 10:51:39 PDT
Created attachment 304399 [details]
Patch
Comment 16 Said Abou-Hallawa 2017-03-14 11:23:13 PDT
Created attachment 304400 [details]
Patch
Comment 17 Build Bot 2017-03-14 12:37:22 PDT
Comment on attachment 304400 [details]
Patch

Attachment 304400 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3322956

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 18 Build Bot 2017-03-14 12:37:28 PDT
Created attachment 304413 [details]
Archive of layout-test-results from ews101 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 19 Build Bot 2017-03-14 17:04:55 PDT
Comment on attachment 304400 [details]
Patch

Attachment 304400 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3324962

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 20 Build Bot 2017-03-14 17:05:00 PDT
Created attachment 304446 [details]
Archive of layout-test-results from ews116 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 21 Said Abou-Hallawa 2017-03-14 22:14:34 PDT
Created attachment 304477 [details]
Patch
Comment 22 Said Abou-Hallawa 2017-03-14 23:11:48 PDT
Created attachment 304479 [details]
Patch
Comment 23 Build Bot 2017-03-15 00:26:19 PDT
Comment on attachment 304479 [details]
Patch

Attachment 304479 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3327922

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 24 Build Bot 2017-03-15 00:26:24 PDT
Created attachment 304484 [details]
Archive of layout-test-results from ews101 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 25 Build Bot 2017-03-15 00:34:16 PDT
Comment on attachment 304479 [details]
Patch

Attachment 304479 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3327909

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 26 Build Bot 2017-03-15 00:34:21 PDT
Created attachment 304485 [details]
Archive of layout-test-results from ews114 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 27 Said Abou-Hallawa 2017-03-15 08:44:25 PDT
Created attachment 304503 [details]
Patch
Comment 28 Said Abou-Hallawa 2017-03-15 08:48:44 PDT
I gave up adding a test to this patch. The test runs all the times locally even with --repeat-each=100. But it's never passed on the mac bots. The bots refused to show the image when it is included as an <img> element or as a css background-image.
Comment 29 Said Abou-Hallawa 2017-03-16 12:11:58 PDT
Comment on attachment 304503 [details]
Patch

The tests may not be showing the images because of https://bugs.webkit.org/show_bug.cgi?id=169771.
Comment 30 Said Abou-Hallawa 2017-03-28 15:25:55 PDT
Created attachment 305651 [details]
Patch
Comment 31 Simon Fraser (smfr) 2017-03-28 15:34:25 PDT
Comment on attachment 305651 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=305651&action=review

> LayoutTests/fast/images/sprite-sheet-image-draw.html:19
> +            }, 50);

Are you racing with image decode? This could be flakey on the bots.
Comment 32 Build Bot 2017-03-28 16:41:44 PDT
Comment on attachment 305651 [details]
Patch

Attachment 305651 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3429832

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 33 Build Bot 2017-03-28 16:41:48 PDT
Created attachment 305667 [details]
Archive of layout-test-results from ews100 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 34 Said Abou-Hallawa 2017-03-28 16:42:38 PDT
Created attachment 305668 [details]
Patch
Comment 35 Build Bot 2017-03-28 18:14:04 PDT
Comment on attachment 305668 [details]
Patch

Attachment 305668 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3430402

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 36 Build Bot 2017-03-28 18:14:08 PDT
Created attachment 305687 [details]
Archive of layout-test-results from ews115 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 37 Build Bot 2017-03-28 18:17:44 PDT
Comment on attachment 305668 [details]
Patch

Attachment 305668 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3430473

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 38 Build Bot 2017-03-28 18:17:47 PDT
Created attachment 305689 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 39 Build Bot 2017-03-28 18:39:38 PDT
Comment on attachment 305668 [details]
Patch

Attachment 305668 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3430420

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 40 Build Bot 2017-03-28 18:39:41 PDT
Created attachment 305691 [details]
Archive of layout-test-results from ews122 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 41 Build Bot 2017-03-28 18:45:56 PDT
Comment on attachment 305668 [details]
Patch

Attachment 305668 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3430594

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 42 Build Bot 2017-03-28 18:45:59 PDT
Created attachment 305693 [details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 43 Said Abou-Hallawa 2017-03-29 10:17:40 PDT
Created attachment 305754 [details]
Patch
Comment 44 Build Bot 2017-03-29 11:25:33 PDT
Comment on attachment 305754 [details]
Patch

Attachment 305754 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3434740

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 45 Build Bot 2017-03-29 11:25:37 PDT
Created attachment 305761 [details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 46 Said Abou-Hallawa 2017-03-29 11:31:44 PDT
Created attachment 305764 [details]
Patch
Comment 47 Build Bot 2017-03-29 12:51:08 PDT
Comment on attachment 305764 [details]
Patch

Attachment 305764 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3435105

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 48 Build Bot 2017-03-29 12:51:11 PDT
Created attachment 305772 [details]
Archive of layout-test-results from ews117 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 49 Build Bot 2017-03-29 12:51:48 PDT
Comment on attachment 305764 [details]
Patch

Attachment 305764 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3435135

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 50 Build Bot 2017-03-29 12:51:52 PDT
Created attachment 305773 [details]
Archive of layout-test-results from ews100 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 51 Said Abou-Hallawa 2017-03-29 13:14:33 PDT
Created attachment 305775 [details]
Patch
Comment 52 Build Bot 2017-03-29 14:09:43 PDT
Comment on attachment 305775 [details]
Patch

Attachment 305775 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3435536

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 53 Build Bot 2017-03-29 14:09:47 PDT
Created attachment 305784 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 54 Build Bot 2017-03-29 14:21:41 PDT
Comment on attachment 305775 [details]
Patch

Attachment 305775 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3435558

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 55 Build Bot 2017-03-29 14:21:44 PDT
Created attachment 305789 [details]
Archive of layout-test-results from ews113 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 56 Said Abou-Hallawa 2017-03-29 14:47:06 PDT
Created attachment 305796 [details]
Patch
Comment 57 Build Bot 2017-03-29 16:16:54 PDT
Comment on attachment 305796 [details]
Patch

Attachment 305796 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3436145

New failing tests:
fast/images/sprite-sheet-image-draw.html
Comment 58 Build Bot 2017-03-29 16:16:58 PDT
Created attachment 305804 [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
Comment 59 Said Abou-Hallawa 2017-03-29 18:08:19 PDT
Created attachment 305818 [details]
Patch
Comment 60 Build Bot 2017-03-29 19:18:55 PDT
Comment on attachment 305818 [details]
Patch

Attachment 305818 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3437057

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 61 Build Bot 2017-03-29 19:19:00 PDT
Created attachment 305821 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 62 Build Bot 2017-03-29 19:26:45 PDT
Comment on attachment 305818 [details]
Patch

Attachment 305818 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3437055

New failing tests:
fast/images/sprite-sheet-image-draw.html
fast/images/async-image-background-image.html
Comment 63 Build Bot 2017-03-29 19:26:50 PDT
Created attachment 305822 [details]
Archive of layout-test-results from ews115 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 64 Said Abou-Hallawa 2017-03-30 12:03:31 PDT
Created attachment 305870 [details]
Patch
Comment 65 Said Abou-Hallawa 2017-03-30 12:22:02 PDT
There were three issues with the test:

1. There was a bug in the code. BitmapImage::stopAnimation() was stopping the decoding thread for all images. This is not needed for large images since the decoding thread will stop automatically once the frame is decoded. The fix is to make BitmapImage::stopAnimation() stops the decoding thread for the animated images only.

2. There was a problem with the test when running it on 2x display. The width of the <div> element was created with the same width as the background image. But on 2x display, the number of pixels of the <div> element are doubled for each dimension. And this was causing the image to be resized and the pixels on the edges get blurred. The solution was use @media css rules for the 2x display.

3. In the test I using document.body.offsetHeight to force redraw. It turns out this is not sufficient since offsetHeight is now optimized such that it won't cause layout/redraw unless the element is dirty. The fix was to change the element properties temporarily, call offsetHeight and then reset the element properties back.
Comment 66 Simon Fraser (smfr) 2017-03-30 13:34:01 PDT
Comment on attachment 305870 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=305870&action=review

> Source/WebCore/ChangeLog:15
> +        To fix this issue, we must use the size of the image and not destRect.size().

You say "size of the image", but the srcRect parameter to nativeImageDrawingScale() isn't necessarily the bounds of the whole image. We may be drawing a subsection of the image.

> Source/WebCore/platform/graphics/cg/NativeImageCG.cpp:83
> -float subsamplingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect)
> +FloatSize nativeImageDrawingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect)
>  {
>      // Never use subsampled images for drawing into PDF contexts.
>      if (wkCGContextIsPDFContext(context.platformContext()))
> -        return 1;
> +        return { 1, 1 };
>  
>      CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(context.platformContext()));
> -    return std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height()));
> +    return { static_cast<float>(transformedDestinationRect.size.width / srcRect.width()), static_cast<float>(transformedDestinationRect.size.height / srcRect.height()) };

It's weird to have this bare function for each platform, but it's mostly cross platform code (you can call getCTM on the GraphicsContext). This should become a function on maybe GraphicsContext at some point.
Comment 67 Said Abou-Hallawa 2017-03-30 14:00:44 PDT
*** Bug 169574 has been marked as a duplicate of this bug. ***
Comment 68 Said Abou-Hallawa 2017-03-30 14:57:35 PDT
Created attachment 305910 [details]
Patch
Comment 69 Said Abou-Hallawa 2017-03-30 15:00:54 PDT
(In reply to Simon Fraser (smfr) from comment #66)
> Comment on attachment 305870 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=305870&action=review
> 
> > Source/WebCore/ChangeLog:15
> > +        To fix this issue, we must use the size of the image and not destRect.size().
> 
> You say "size of the image", but the srcRect parameter to
> nativeImageDrawingScale() isn't necessarily the bounds of the whole image.
> We may be drawing a subsection of the image.
> 

I changed the ChangeLog to include the following description for the fix:

To fix this issue, first the base size has to be size of the image and not destRect.size(). Secondly, we need to scale this base size with the context transformation multiplied by the ratio destRect / srcRect. This scaling is exactly the same scaling which is calculated in subsamplingScale(). Finally we use this scaled size as the sizeForDrawing to send to the ImageDecoder.

> > Source/WebCore/platform/graphics/cg/NativeImageCG.cpp:83
> > -float subsamplingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect)
> > +FloatSize nativeImageDrawingScale(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect)
> >  {
> >      // Never use subsampled images for drawing into PDF contexts.
> >      if (wkCGContextIsPDFContext(context.platformContext()))
> > -        return 1;
> > +        return { 1, 1 };
> >  
> >      CGRect transformedDestinationRect = CGRectApplyAffineTransform(destRect, CGContextGetCTM(context.platformContext()));
> > -    return std::min<float>(1, std::max(transformedDestinationRect.size.width / srcRect.width(), transformedDestinationRect.size.height / srcRect.height()));
> > +    return { static_cast<float>(transformedDestinationRect.size.width / srcRect.width()), static_cast<float>(transformedDestinationRect.size.height / srcRect.height()) };
> 
> It's weird to have this bare function for each platform, but it's mostly
> cross platform code (you can call getCTM on the GraphicsContext). This
> should become a function on maybe GraphicsContext at some point.

Will do.
Comment 70 WebKit Commit Bot 2017-03-30 15:41:17 PDT
Comment on attachment 305910 [details]
Patch

Clearing flags on attachment: 305910

Committed r214635: <http://trac.webkit.org/changeset/214635>
Comment 71 WebKit Commit Bot 2017-03-30 15:41:20 PDT
All reviewed patches have been landed.  Closing bug.
Comment 72 Said Abou-Hallawa 2017-03-31 12:26:04 PDT
I logged https://bugs.webkit.org/show_bug.cgi?id=170353 to track making nativeImageDrawingScale() a cross platform function.