New issue
Advanced search Search tips

Issue 627588 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Percentage-Based Translate Rounding Error

Reported by grupp...@gmail.com, Jul 12 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Example URL:
http://codepen.io/gruppler/pen/BzmmLE?editors=0100

Steps to reproduce the problem:
1. Set an element's dimensions using percentages
2. Translate the element using percentages greater than 100%
3. Resize the container

What is the expected behavior?
The element is translated based on the original numerical values.

What went wrong?
The element is translated based on rounded numerical values.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? No 

Does this work in other browsers? Yes 

Chrome version: 51.0.2704.103  Channel: stable
OS Version: 10.0
Flash Version: Shockwave Flash 22.0 r0
 
Components: -Blink Blink>Paint
Labels: -Pri-2 Pri-3
Owner: chrishtr@chromium.org
Status: Assigned (was: Unconfirmed)
Labels: -Pri-3 Pri-2
I've attached a simpler example that does not depend on browser window size.

The core issue is that Blink (incorrectly) rounds off width and height before multiplying by percent. Thus the 900% value in the test example ends up causing
up to a 4-5px rounding error, because it's 9 * (roundoff amount) incorrect.

This behavior was introduced in this commit in 2012:

https://chromium.googlesource.com/chromium/src/+/1255d37e8c6202ab8f88f2933ed9dadfd62b903c

I think this side-effect was simply an unintended bad side-effect.
test.html
316 bytes View Download
Project Member

Comment 4 by bugdroid1@chromium.org, Oct 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/234079c8f5478894d70b6899a7461caa7062504d

commit 234079c8f5478894d70b6899a7461caa7062504d
Author: chrishtr <chrishtr@chromium.org>
Date: Tue Oct 04 02:50:05 2016

Don't pixel-snap box size before applying percentage transform to it.

Otherwise we'll end up with error that gets larger according to the percentage.

Note that subpixel accumulation is already plumbed through for transforms in
other ways.

BUG=627588
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2386263002
Cr-Commit-Position: refs/heads/master@{#422680}

[modify] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/LayoutTests/TestExpectations
[delete] https://crrev.com/bc0b8bebb01af4c46a742a9e119a5eb39ee9aff0/third_party/WebKit/LayoutTests/fast/backgrounds/background-with-sub-pixel-offset-positioning-expected.html
[add] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/LayoutTests/fast/backgrounds/background-with-sub-pixel-offset-positioning-expected.png
[add] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/LayoutTests/fast/backgrounds/background-with-sub-pixel-offset-positioning-expected.txt
[modify] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/LayoutTests/fast/backgrounds/background-with-sub-pixel-offset-positioning.html
[add] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/LayoutTests/paint/transforms/percentage-transform-fractional-box-size-expected.png
[add] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/LayoutTests/paint/transforms/percentage-transform-fractional-box-size-expected.txt
[add] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/LayoutTests/paint/transforms/percentage-transform-fractional-box-size.html
[modify] https://crrev.com/234079c8f5478894d70b6899a7461caa7062504d/third_party/WebKit/Source/core/paint/PaintLayer.cpp

Status: Fixed (was: Assigned)
Project Member

Comment 6 by bugdroid1@chromium.org, Oct 4 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/819c9cf6d5b6a16440e683cef25baec9f60210f2

commit 819c9cf6d5b6a16440e683cef25baec9f60210f2
Author: Rebaseline Bot <blink-rebaseline-bot@chromium.org>
Date: Tue Oct 04 04:28:19 2016

Auto-rebaseline for r422680

https://chromium.googlesource.com/chromium/src/+/234079c8f

BUG=627588
TBR=chrishtr@chromium.org

Review URL: https://codereview.chromium.org/2391813003 .

Cr-Commit-Position: refs/heads/master@{#422705}

[modify] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/TestExpectations
[modify] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/paint/invalidation/invalidation-with-scale-transform-expected.png
[add] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/android/compositing/gestures/gesture-tapHighlight-pixel-rotated-link-expected.png
[add] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/android/paint/invalidation/invalidation-with-scale-transform-expected.png
[modify] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/linux/compositing/gestures/gesture-tapHighlight-pixel-rotated-link-expected.png
[modify] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/mac/compositing/geometry/fixed-position-transform-composited-page-scale-expected.png
[add] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/mac/fast/backgrounds/background-with-sub-pixel-offset-positioning-expected.png
[modify] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/win/compositing/geometry/fixed-position-transform-composited-page-scale-expected.png
[modify] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/win/compositing/gestures/gesture-tapHighlight-pixel-rotated-link-expected.png
[modify] https://crrev.com/819c9cf6d5b6a16440e683cef25baec9f60210f2/third_party/WebKit/LayoutTests/platform/win/fast/transforms/transform-on-inline-expected.png

Comment 7 by grupp...@gmail.com, Jan 14 2017

When will this hit Stable?
It is already in Chrome 55 stable.

Comment 9 by grupp...@gmail.com, Jan 14 2017

This is strange. I see that in the original example URL I provided, the bug appears to be fixed. However, in the project that brought the bug to my attention, I'm still seeing the same behavior.

Here's a new example URL where the problem is still appearing:
http://ptn.ninja/#NoEQhgLgpgBARAJgAwEYDsA6VGUBY4C6AUMAAoA2YAnlAE4rwDqAFgJbSEkXV0LwBClAMYBrTsABKUAM4BXchHjiAyqwBesOADZxAFVLL4KADQJjJsxYD0l0+bsorF+7YQ2XHx8++n3PyzAMKACcnEA

You can see the same "jiggle" effect when the board changes in size, such as when the window resizes, or when you toggle an element of the board (press "x" to toggle axis labels). The upper-right piece shows the greatest rounding error "jiggle" while the lower-left piece shows the least.
This page doesn't seem to have any transforms on it. Am I missing it?

The div with class "table" has an inline transform on it, but a CSS rule removes it
because it's not 3D.

Comment 11 by grupp...@gmail.com, Jan 14 2017

The pieces are positioned via translate3d specified in percentages. The size of each piece is a percentage of the board size. The board size is set in pixels according to the amount of space available.

The pieces have pointer-events: none so you'll have to find div.board > div.pieces > div.piece to inspect one.
Status: Assigned (was: Fixed)
Owner: ----
Status: Untriaged (was: Assigned)
Owner: schenney@chromium.org
Status: Assigned (was: Untriaged)
I'll look into verifying and reducing this when I get a chance.

Comment 15 by grupp...@gmail.com, Nov 16 2017

Here's a more recent version of the previous example:
http://dev.ptn.ninja/#NoEQhgLgpgBARAJgAwEYDsA6VGUBY4C6AUMAAoA2YAnlAE4rwDqAFgJbSEkXV0LwBClAMYBrTsABKUAM4BXchHjiAyqwBesOADZxAFVLL4KADQJjJsxYD0l0+bsorF+7YQ2XHx8++n3PyzAMKACcnEA

Press X and/or C to watch the pieces 'jiggle' more and more severely as they increase in distance from their origin (the bottom left).

Sign in to add a comment