Precision issue with angles in canvas arc stroke when using Direct2D
Categories
(Core :: Graphics: Canvas2D, defect, P3)
Tracking
()
People
(Reporter: bvisness, Unassigned, NeedInfo)
Details
Attachments
(7 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0
Steps to reproduce:
- Create a canvas and draw a stroke along arcs with a small radius (e.g. radius 10, starting angle 0, ending angle π/2, any stroke thickness).
Actual results:
The resulting strokes start slightly before the expected start angle and end slightly before the expected end angle. This results in discontinuities and sometimes missing pixels, especially at the end of the stroke.
See the attached file, which demonstrates the issue on many arcs.
Expected results:
The arc strokes should start and end at precisely the right places. (Chrome and Edge do the right thing - strokes starting and ending at 90-degree increments land cleanly on pixel boundaries and are not missing any pixels.)
Updated•5 years ago
|
Comment 1•5 years ago
|
||
Thank you very much for the bug report!
I've downloaded your attachment and taken a look at it. I added some grid lines to it to help me see what was going on at the boundaries. I'm not seeing a significant difference in the output. (I'll attach my case first.)
So, first of all, could you attach the output from about:support to this bug? (Just hit the "Copy text to clipboard" button and paste it into Bugzilla; it'll automatically offer to make it into an attachment.)
And second of all, could you attach a screen shot of what you are seeing from Firefox? If you could try my version and screenshot that too, that would be great.
Comment 2•5 years ago
|
||
Comment 3•5 years ago
|
||
Lee, you're the point man for the canvas, I think.
Comment 4•5 years ago
|
||
| Reporter | ||
Comment 5•5 years ago
|
||
I just tested on my other computer, and I think the issue only affects Windows. Here is what I see on Windows, while on Mac I see exactly the expected result.
| Reporter | ||
Comment 6•5 years ago
|
||
Updated•5 years ago
|
Comment 7•5 years ago
|
||
If you disable Direct2D acceleration of canvas by setting the pref gfx.direct2d.enabled to false, does the problem still occur?
| Reporter | ||
Comment 8•5 years ago
|
||
It appears to happen the same way regardless of that setting.
Comment 9•5 years ago
•
|
||
(In reply to Ben Visness from comment #8)
It appears to happen the same way regardless of that setting.
And when you use that pref, about:support you are no longer using direct2d for canvas, but instead using skia, right? In about:support it should just say "AzureCanvasBackend: skia" instead with that pref set to false (whereas with d2d on you will see "AzureCanvasBackend: direct2d 1.1").
If that is the case, this would imply this is something about the clang build/version/etc. itself on Windows causing the issue, rather than anything specific to the choice of canvas backend, which could be concerning.
| Reporter | ||
Comment 10•5 years ago
|
||
I took another look and discovered that the setting is actually gfx.direct2d.disabled (not enabled). I was new to the flags UI and didn't realize I was creating a new setting instead of changing an existing one.
With that setting on (and direct2d disabled) there is no issue. So it seems that the direct2d acceleration is to blame!
Comment 11•5 years ago
|
||
(In reply to Ben Visness from comment #10)
I took another look and discovered that the setting is actually gfx.direct2d.disabled (not enabled). I was new to the flags UI and didn't realize I was creating a new setting instead of changing an existing one.
With that setting on (and direct2d disabled) there is no issue. So it seems that the direct2d acceleration is to blame!
Ah, oops. I think I missed my morning coffee. What I meant to say earlier was the gfx.direct2d.disabled pref, and that to toggle direct2d off for canvas you wanted to actually set that to true. In any case, you figured it out...
So it seems that the divergence is then D2D's path/bezier code, which takes a different route for bezier rendering than Skia does.
Updated•5 years ago
|
| Reporter | ||
Comment 12•2 years ago
|
||
A similar but dramatically worse issue has now manifested on my Mac, causing me to revisit this issue.
On both Windows and Mac, the pref gfx.canvas.accelerated causes arcs to be rendered off-center and with a significant angle on the ends of the stroke. Setting the pref to false results in correct arcs with high-quality antialiasing.
On Windows, the original single-pixel bug is still present, but setting gfx.direct2d.disabled to true no longer fixes the problem.
| Reporter | ||
Comment 13•2 years ago
|
||
Mac, Firefox Nightly 114.0a1 (2023-04-12), gfx.canvas.accelerated true
| Reporter | ||
Comment 14•2 years ago
|
||
Mac, Firefox Nightly 114.0a1 (2023-04-12), gfx.canvas.accelerated false
Updated•2 years ago
|
Description
•