servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.56k stars 198 forks source link

Rendering hangs when large numbers of paths overlap the viewport boundary #428

Closed alec-deason closed 2 years ago

alec-deason commented 4 years ago

This is a regression introduced by the fix for #416

This example hangs on build_and_render: https://gist.github.com/alec-deason/a093aecaebbed430f59df624547efa2f

But if you use the configuration in the comments on line 105 it works as expected. The difference is that the broken version renders a bunch of arcs partially out of view and the working version moves them entirely into view.

I see the same behavior in my real code, if I'm very careful to only create paths that are fully in view everything is fine but as soon as I have a non-trivial number of paths completely or partially out of view it fails.

alec-deason commented 3 years ago

I'm now unclear on what exactly triggers this. In my initial experiments it seemed like I needed quite a few paths overlapping the canvas boundary to cause the hang but this hangs even though there is only a single path:

let mut canvas = Canvas::new(vec2f(500.0, 500.0)).get_context_2d(font_context.clone());

let mut path = Path2D::new();
path.move_to(vec2f(0.0, 0.0));
path.line_to(vec2f(500.0, 0.0));
path.line_to(vec2f(250.0, 750.0));
path.close_path();
canvas.set_fill_style(ColorU::new(255, 0, 0, 255));
canvas.fill_path(path, FillRule::Winding);
pcwalton commented 3 years ago

Looking at this. Feels like possible floating-point error (that's why that check was in there in the first place).