tiny-skia icon indicating copy to clipboard operation
tiny-skia copied to clipboard

Debug assertion failed in hairline_aa.rs:124

Open danieldg opened this issue 1 year ago • 3 comments

Using tiny-skia-0.11.4:

use tiny_skia::*;

fn main() {
    let mut pixmap = Pixmap::new(100, 10).unwrap();
    let paint = Paint {
        shader: Shader::SolidColor(Color::BLACK),
        anti_alias: true,
        ..Default::default()
    };
    let rect = Rect::from_ltrb(88.1, 0., 89.6, 10.).unwrap();

    pixmap.fill_rect(rect, &paint, Default::default(), None);
}

Backtrace:

#14 0x00005555555602f3 in core::panicking::panic ()
#15 0x0000555555568b1c in tiny_skia::scan::hairline_aa::fill_dot8 (l=22554, t=<optimized out>, r=22938, b=2560, fill_inner=true, blitter=...) at src/scan/hairline_aa.rs:124
#16 tiny_skia::scan::hairline_aa::fill_fixed_rect (blitter=..., rect=<optimized out>) at src/scan/hairline_aa.rs:58
#17 tiny_skia::scan::hairline_aa::fill_rect (rect=<optimized out>, clip=<optimized out>, blitter=...) at src/scan/hairline_aa.rs:54
#18 0x0000555555561331 in tiny_skia::scan::fill_rect_aa (rect=0x7fffffffddd0, clip=0x7fffffffc8f0, blitter=...) at src/scan/mod.rs:38
#19 tiny_skia::pixmap::PixmapMut::fill_rect (self=0x7fffffffdd30, rect=..., paint=0x7fffffffdde8, transform=..., mask=...) at src/painter.rs:203
#20 0x000055555556113e in tiny_skia::pixmap::Pixmap::fill_rect (self=<optimized out>, rect=<error reading variable: Cannot access memory at address 0x555e>, paint=0x6, transform=..., mask=...) at src/painter.rs:114

danieldg avatar Feb 19 '24 15:02 danieldg

Thanks, will take a look.

RazrFalcon avatar Feb 19 '24 16:02 RazrFalcon

I came across what I think is the same issue. I was drawing aa rects with width exactly 1 and non-integral horizontal positions.

I think the right fix is to let width be 0 in the inner part of hairline_aa.rs:fill_dot8 and just skip the blit_rect for that case with no error.

I put up a pull request with test and fix at #119.

nwhitehead avatar Apr 25 '24 19:04 nwhitehead

Thanks. Will take a look. The correct fix would be to have exactly the same logic Skia does. So the main problem here is for me to find time to dive into Skia sources.

RazrFalcon avatar Apr 26 '24 16:04 RazrFalcon