linebender / linebender/resvg

Specific file causes assertions in lighting.rs

Open
#1,048 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at crates/resvg/src/filter/lighting.rs:185, then follow the apply_specular_lighting call in crates/resvg/src/filter/mod.rs. Reproduce the panic with the supplied SVG and rendering example, and verify that the file no longer triggers the assertion while producing output.png.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.