Skip to content

[classic] Non-deterministic rendering bug when stroking rounded rectangles #1314

@PoignardAzur

Description

@PoignardAzur

Vello has a non-deterministic bug when trying to render rounded rects in some very specific case.

Right now I can reliably trigger the bug on my machine in Masonry by replacing the contents of Scrollbar::paint() with this code:

    fn paint(&mut self, ctx: &mut PaintCtx<'_>, _props: &PropertiesRef<'_>, scene: &mut Scene) {
        let rect =
            Rect::from_origin_size((2.0, 0.), (8.0, 327.76546717171715)).to_rounded_rect(3.91);

        let style = Stroke {
            width: 1.0,
            join: Join::Miter,
            ..Default::default()
        };
        scene.stroke(&style, Affine::IDENTITY, &Color::WHITE, None, &rect);
    }

Running the http_cats example on commit 0fff1c161306364bdff7ff9b880eb63533953cbb with this code gives me this:

Image

(Variations of this code usually lead to smaller less spectacular artifacts.)

However, running the exact same code in Vello's regression.rs doesn't give me any rendering artifacts. And the artifacts change every render, between people's machines, etc. Hence why I'm pretty sure this is a non-deterministic bug.


Some characteristics I've found:

  • The bug is much more likely to happen when the radius is a non-integer number.
  • The bug also tends to happen when the sum of the radii is equal to the rect width.
  • The bug will sometimes depend on the rounded rect's position (e.g. in the original http_cats example, the bug only trigger at some arbitrary scroll positions).

This is all I've been able to figure out. The trouble with a non-deterministic bug is that it's hard to know when the bug is gone vs just not reproducing at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-classicApplies to the classic `vello` crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions