Skip to content

Specific file causes assertions in lighting.rs #1048

@smourier

Description

@smourier

Hi,

Running On Windows 11, latest version, this code:

use std::fs;

use resvg::{
    tiny_skia::{Pixmap, Transform},
    usvg::{Options, Tree},
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let svg_data = fs::read("circle_black.svg")?;

    let mut opt = Options::default();
  	opt.fontdb_mut().load_system_fonts();
	
    let tree = Tree::from_data(&svg_data, &opt)?;

    let size = tree.size().to_int_size();
    let mut pixmap = Pixmap::new(size.width(), size.height())
        .ok_or("Failed to create pixmap")?;

    resvg::render(&tree, Transform::default(), &mut pixmap.as_mut());

    pixmap.save_png("output.png")?;
    println!("Rendered to output.png");
    Ok(())
}

And this file

Image

Causes this assert

thread 'main' (42028) panicked at crates\resvg\src\filter\lighting.rs:185:5:
assertion failed: src.width == dest.width && src.height == dest.height
stack backtrace:
   0: std::panicking::panic_handler
             at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library\std\src\panicking.rs:689
   1: core::panicking::panic_fmt
             at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library\core\src\panicking.rs:80
   2: core::panicking::panic
             at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library\core\src\panicking.rs:150
   3: resvg::filter::lighting::specular_lighting
             at e:\smo\GitHub\resvg\crates\resvg\src\filter\lighting.rs:185
   4: resvg::filter::apply_specular_lighting
             at e:\smo\GitHub\resvg\crates\resvg\src\filter\mod.rs:1045
   5: resvg::filter::apply_inner
             at e:\smo\GitHub\resvg\crates\resvg\src\filter\mod.rs:446
   6: resvg::filter::apply
             at e:\smo\GitHub\resvg\crates\resvg\src\filter\mod.rs:340
   7: resvg::render::render_group
             at e:\smo\GitHub\resvg\crates\resvg\src\render.rs:110
   8: resvg::render::render_node
             at e:\smo\GitHub\resvg\crates\resvg\src\render.rs:29
   9: resvg::render::render_nodes
             at e:\smo\GitHub\resvg\crates\resvg\src\render.rs:17
  10: resvg::render
             at e:\smo\GitHub\resvg\crates\resvg\src\lib.rs:49
  11: svg_render_demo::main
             at e:\smo\GitHub\resvg\crates\c-api\examples\svg_render_demo\src\main.rs:22
  12: core::ops::function::FnOnce::call_once<enum2$<core::result::Result<tuple$<>,alloc::boxed::Box<dyn$<core::error::Error>,alloc::alloc::Global> > > (*)(),tuple$<> >
             at C:\Users\simon\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions