New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 631508 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Octagonal antialiasing of rounded borders

Reported by teo8...@gmail.com, Jul 26 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36

Example URL:
http://jsbin.com/sovabuj/edit?html,css,output

Steps to reproduce the problem:
1. see http://jsbin.com/sovabuj/edit?html,css,output

What is the expected behavior?
The red span containing an x should be a circle

What went wrong?
it is a perfect octagon.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes 

Chrome version: 51.0.2704.106  Channel: n/a
OS Version: 
Flash Version: Shockwave Flash 22.0 r0
 
Screenshot from 2016-07-26 18-51-02.png
750 bytes View Download

Comment 1 by bokan@chromium.org, Jul 26 2016

Components: -Blink Blink>Paint
Labels: -OS-Linux OS-All
Status: Untriaged (was: Unconfirmed)
Summary: Octagonal antialiasing of rounded borders (was: Shitty antialiasing of rounded borders)
IMO, doesn't look any worse than Firefox but I'll let paint team decide.

Comment 2 by teo8...@gmail.com, Jul 26 2016

I don't know how it looks on firefox but that's irrelevant. It definitely looks worse than it should.

Comment 3 by bokan@chromium.org, Jul 26 2016

Its relevant because there's often specifications that limit implementation choices. If multiple browsers have similar output that's often a good sign that things are actually working as intended (despite not working as expected).

That said, I don't have relevant expertise here so someone on the paint team will have to decide if this is actually a bug.

Comment 4 by bokan@chromium.org, Jul 26 2016

Cc: bokan@chromium.org
Owner: schenney@chromium.org
Status: Assigned (was: Untriaged)
This is probably the best we can do. Looking at your zoomed in picture, you can see we have only a few pixels to draw something that looks like an arc, and you simply can't draw an accurate arc in a tiny number of pixels. I'll verify the situation when I can get to a low DPI machine.

Comment 6 by teo8...@gmail.com, Jul 26 2016

> This is probably the best we can do. 
> you simply can't draw an accurate arc in a tiny number of pixels

No it isn't. 

You definitely can draw a more accurate arc in that amount of pixels.

Attached is the proof.
Untitled.png
572 bytes View Download

Comment 7 by f...@opera.com, Jul 26 2016

I think the reason you're seeing this is that the border shape does not actually describe a circle. I.e you have box (square) that's 1.2em x 1.2em. You have a border box that's 1.2em+2px squared. You apply a 0.6em border-radius to that, meaning that what you get doesn't describe a circle - but something fairly close to it (because of the extra px.)

Try "box-sizing: border-box;" or "border-radius: calc(0.6em + 1px);" - or some variation thereof that make sure that the radii "line up" with the dimensions. Hope that helps.

Comment 8 by teo8...@gmail.com, Jul 26 2016

That would explain an additional very short flat horizontal and vertical segment on each border, but it doesn't explain that the rounded corners aren't rounded at all, but perfectly diagonal (or if you prefer, are very poorly antialiased and don't look like arks at all).

Comment 9 by teo8...@gmail.com, Jul 26 2016

In other words, this is approximately how it should look like.
ppp.png
585 bytes View Download

Comment 10 by teo8...@gmail.com, Jul 26 2016

And here's a version with your correction:
http://jsbin.com/geqete/edit?html,css,output

this one should actually be a perfect circle, and you can still see how it is pretty far from it, and much closer to a perfect octagon.

Either the rounding (i.e. arc drawing) or the antialiasing are broken.
Untitled2.png
585 bytes View Download

Comment 11 by f...@opera.com, Jul 27 2016

Cc: fmalita@chromium.org
Components: Internals>Skia
I'm going to take a guess and say that this might be because we end up producing a hairline stroke, and either the flattening step when drawing that stroke is too coarse (allows too large error) or doesn't use subpixel precision.

It looks more like a circle if you make the border 2px?

Comment 12 by pdr@chromium.org, Jul 27 2016

Cc: caryclark@chromium.org
This bug reminds me of  https://crbug.com/102411  & http://skbug.com/2769. +cc Cary just in case.
Components: -Internals>Skia
This goes south before it hits Skia:

* for the original case (c#1), we draw a 18x18 rrect with 7.9 radii (off by 1.1)
* for the border-box case (c#10), we draw a 16x16 rrect with 7.9 radii (off by 0.1)

What appears to work best is fs@'s second suggestion (border-radius: calc(0.6em + 1px);): http://jsbin.com/siqefi/1/edit?html,css,output

^ for which we draw a 18x18 rrect with 8.9 radii (still 0.1 off, but less noticeable due to the larger size).

So the radii calculation is off for some reason.

For reference, here's Skia's rendering of the same geometry but with matching radii (18x18/9 rrect): https://fiddle.skia.org/c/9d3697574abcb65d11e2a45c137f80ec


Comment 14 by teo8...@gmail.com, Sep 15 2016

> So the radii calculation is off for some reason.

I don't understand in what way that explains the rounded corners being less round, but if it's true that the radius calculation is wrong, could that explain https://bugs.chromium.org/p/chromium/issues/detail?id=631507 ?
Most likely not: the main complaint there appears to be related to AA quality, not geometry.

Comment 16 by teo8...@gmail.com, Sep 15 2016

> Most likely not

So, correct me if I am wrong: the radius is wrong, but the position of the center of the circle ark is consistent with the wrong radius, right? Otherwise, I wouldn't see how a wrong radius would not result in artifacts at the junctions.


> the main complaint there appears to be related to AA quality, not geometry

Well, the complaint is that the result of the rendering is incorrect.

That the error is in AA and not somewhere else is either a conclusion someone has arrived at (I hope it is) or an assumption someone has made.
> So, correct me if I am wrong: the radius is wrong, but the position of the center of the circle ark is consistent with the wrong radius, right? > Otherwise, I wouldn't see how a wrong radius would not result in artifacts at the junctions.

The geometry is not represented as 4 arcs + 4 lines, but a rectangle + 8 radii.  So there is no "arc" per se: the arcs are derived at rasterization time such that the junctions are always "perfect" (as long as the radii are not degenerate).

So passing the wrong radii is not going going to result in misaligned corner edges, but just smaller/larger arcs.


Cc: schenney@chromium.org
Owner: ----
Status: Available (was: Assigned)

Sign in to add a comment