Skip to content

Crash on tiny_skia backend when rendering zero-width/height image #2877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
kiedtl opened this issue Apr 7, 2025 · 1 comment
Open
4 tasks done

Crash on tiny_skia backend when rendering zero-width/height image #2877

kiedtl opened this issue Apr 7, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@kiedtl
Copy link
Contributor

kiedtl commented Apr 7, 2025

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

Rendering an image widget with zero pixels results in a panic in Iced's tiny_skia code.

Minimal example:

use iced::window;
use iced::{Element, Task};
use iced::widget::image;

fn main() -> iced::Result {
    iced::daemon(Example::title, Example::update, Example::view)
        .run_with(Example::new)
}

struct Example { }

#[derive(Debug, Clone)]
enum Message { Nuhuh }

impl Example {
    fn new() -> (Self, Task<Message>) {
        let (_id, open) = window::open(window::Settings::default());

        (Self {}, open.map(|_| Message::Nuhuh))
    }

    fn title(&self, _: window::Id) -> String {
        "Test".to_owned()
    }

    fn update(&mut self, message: Message) -> Task<Message> {
        match message {
            Message::Nuhuh => { }
        }
        Task::none()
    }

    fn view(&self, _: window::Id) -> Element<Message> {
        image(image::Handle::from_rgba(0, 0, iced::advanced::image::Bytes::new())).into()
    }
}

This results in an immediate panic of Build pixmap from image bytes.

.expect("Build pixmap from image bytes")

Note that this doesn't appear(?) to panic when running with the wgpu backend.

What is the expected behavior?

Well, anything except panic.

Assuming this isn't expected behaviour (I don't think it is), ideally an empty element should be returned with no work done, i.e., the equivalent of row![].into(). Alternatively, image could return a Result.

If this is expected behaviour, it could be documented on the Image widget, and the error message could be more helpful. And, this behaviour should be standardized on the other backends.

Version

crates.io release

Operating System

Linux

Do you have any log output?

@kiedtl kiedtl added the bug Something isn't working label Apr 7, 2025
@iced-rs iced-rs deleted a comment from bashkir066 Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant