Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with flattening of a stroked cubic around a near-cusp #581

Open
armansito opened this issue May 16, 2024 · 0 comments
Open

Issue with flattening of a stroked cubic around a near-cusp #581

armansito opened this issue May 16, 2024 · 0 comments

Comments

@armansito
Copy link
Collaborator

armansito commented May 16, 2024

On Apple hardware, the following near-cusp test case from the tricky_strokes test scene has this artifact at certain scale factors:

This specifically only seems to happen with the near-cusp defined as [(0., 0.01), (128., 127.999), (128., 0.01), (0., 127.99)]. The bug itself is in the flatten stage, specifically the cubic-to-es subdivision loop in flatten_euler. I debugged this over a couple days and here are my findings so far:

  • For that specific cubic, the issue is only present for a (uniform) scale factor within the range 5.3332 and 113.5797. Scale factors outside that range do not exhibit the issue. This can be verified by hard-coding a scale factor right before testing the scaled error estimate against the error tolerance:
...
scale = 5.3332;
if cubic_params.err * scale <= tol || dt <= SUBDIV_LIMIT {
...
  • The issue is not present when fastmath is disabled. The Metal compiler enables optimizations on floating-point arithmetic (which may violate the IEEE-754 standard) by default. I verified this by setting fastMathEnabled = NO on MTLCompilerOptions directly on Skia-Graphite's Metal backend (which uses the shaders directly and doesn't use wgpu).
  • The issue is not present on CPU shaders (which doesn't use fastmath).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant