-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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.
Line 115 in e462535
| .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?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working