iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.8k stars 1.17k forks source link

Skia panicing rendering widgets #2066

Closed sdgoihew closed 9 months ago

sdgoihew commented 1 year ago

Is there an existing issue for this?

Is this issue related to iced?

What happened?

Panic with meaningless explanation (using tiny_skia backend)

Minimized example:

    fn view(&self) -> Element<'_, self::Message> {
        let regex_field = TextInput::new("qwe", "asd")
            .on_input(Message::RegexText)
            .on_submit(Message::RegexProcess);
        let controls = Row::new().push(regex_field);
        let column = Column::new().push(controls);
        let spacer = Text::new("spacer");
        let row: Element<'_, Message> = Row::new().push(column).push(spacer).into();
        let content = Scrollable::new(row/*.explain(Color::WHITE)*/)
            .direction(iced::widget::scrollable::Direction::Both {
                vertical: widget::scrollable::Properties::new(),
                horizontal: widget::scrollable::Properties::new() });
        Container::new(content).into()
    }

What is the expected behavior?

Compile time error, or sane explanation of what happened

Version

crates.io release

Operating System

Windows

Do you have any log output?

PS C:\workspace\iced-tour> cargo run --release
    Finished release [optimized] target(s) in 0.35s
     Running `target\release\tour.exe`
thread 'main' panicked at C:\Users\Nikolay\.cargo\registry\src\index.crates.io-6f17d22bba15001f\iced_tiny_skia-0.1.0\src\backend.rs:706:22:
Build rounded rectangle path
stack backtrace:
   0:     0x7ff78bd57eca - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\sys_common\backtrace.rs:44
   1:     0x7ff78bd7089b - core::fmt::rt::Argument::fmt
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\core\src\fmt\rt.rs:138
   2:     0x7ff78bd7089b - core::fmt::write
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\core\src\fmt\mod.rs:1094
   3:     0x7ff78bd54281 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\io\mod.rs:1714
   4:     0x7ff78bd57c4b - std::sys_common::backtrace::_print
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\sys_common\backtrace.rs:47
   5:     0x7ff78bd57c4b - std::sys_common::backtrace::print
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\sys_common\backtrace.rs:34
   6:     0x7ff78bd5a653 - std::panicking::panic_hook_with_disk_dump::closure$1
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:278
   7:     0x7ff78bd5a1fa - std::panicking::panic_hook_with_disk_dump
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:312
   8:     0x7ff78bd5add0 - std::panicking::default_hook
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:239
   9:     0x7ff78bd5add0 - std::panicking::rust_panic_with_hook
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:729
  10:     0x7ff78bd5acbd - std::panicking::begin_panic_handler::closure$0
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:621
  11:     0x7ff78bd588f9 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\sys_common\backtrace.rs:170
  12:     0x7ff78bd5a9c0 - std::panicking::begin_panic_handler
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:617
  13:     0x7ff78bd847a5 - core::panicking::panic_fmt
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\core\src\panicking.rs:67
  14:     0x7ff78bd84762 - core::panicking::panic_display
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\core\src\panicking.rs:150
  15:     0x7ff78bd84762 - core::panicking::panic_str
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\core\src\panicking.rs:134
  16:     0x7ff78bd84762 - core::option::expect_failed
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\core\src\option.rs:1988
  17:     0x7ff78baac0e7 - iced_tiny_skia::backend::into_color::hc85a745da7920e79
  18:     0x7ff78baa908a - iced_tiny_skia::backend::Backend::draw_primitive::h75ea874bbbf689b3
  19:     0x7ff78baa94ed - iced_tiny_skia::backend::Backend::draw_primitive::h75ea874bbbf689b3
  20:     0x7ff78baa94ed - iced_tiny_skia::backend::Backend::draw_primitive::h75ea874bbbf689b3
  21:     0x7ff78baa9657 - iced_tiny_skia::backend::Backend::draw_primitive::h75ea874bbbf689b3
  22:     0x7ff78ba81741 - iced_tiny_skia::backend::Backend::draw::h7bef7b3c40556e96
  23:     0x7ff78ba62ca3 - iced_tiny_skia::window::compositor::present::h2ac76d4dba4f685c
  24:     0x7ff78ba693b6 - winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}::ha66b4850ddbbd271
  25:     0x7ff78ba4be18 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h4b072275ecc983e8
  26:     0x7ff78ba6c064 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::h5db380d01229d954
  27:     0x7ff78ba6b9a3 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::send_event::hea9e0ce96db3d9d7
  28:     0x7ff78ba4d4fc - winit::platform_impl::platform::event_loop::public_window_callback_inner::{{closure}}::h1ddfe2fe5a36fb11
  29:     0x7ff78ba6c3f8 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::hf4c6826fa1ff07e0
  30:     0x7ff78ba486a2 - winit::platform_impl::platform::event_loop::public_window_callback::h01f628fbe1c2e477
  31:     0x7ffd165174d6 - DispatchMessageW
  32:     0x7ffd165171fc - DispatchMessageW
  33:     0x7ffd16520ab3 - EnumChildWindows
  34:     0x7ffd16be3744 - KiUserCallbackDispatcher
  35:     0x7ffd12fc1764 - NtUserDispatchMessage
  36:     0x7ffd1651706f - DispatchMessageW
  37:     0x7ff78ba4606d - iced_winit::application::platform::run::hc1654a4908c50dd3
  38:     0x7ff78ba71f2b - iced_winit::application::run::h47b64201f9cb12af
  39:     0x7ff78ba85003 - iced_core::widget::Widget::on_event::h24fc067a59c30390
  40:     0x7ff78ba77346 - std::sys_common::backtrace::__rust_begin_short_backtrace::h9ea73063d61a596f
  41:     0x7ff78ba7f29c - std::rt::lang_start::{{closure}}::h284c6858eb3a8cf5
  42:     0x7ff78bd4ef58 - std::rt::lang_start_internal::closure$2
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\rt.rs:148
  43:     0x7ff78bd4ef58 - std::panicking::try::do_call
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:524
  44:     0x7ff78bd4ef58 - std::panicking::try
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panicking.rs:488
  45:     0x7ff78bd4ef58 - std::panic::catch_unwind
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\panic.rs:142
  46:     0x7ff78bd4ef58 - std::rt::lang_start_internal
                               at /rustc/03a119b0b0e310d22d94399b24ed030056050f13/library\std\src\rt.rs:148
  47:     0x7ff78ba852ac - main
  48:     0x7ff78bd78250 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  49:     0x7ff78bd78250 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  50:     0x7ffd16177974 - BaseThreadInitThunk
  51:     0x7ffd16b9a2f1 - RtlUserThreadStart
error: process didn't exit successfully: `target\release\tour.exe` (exit code: 101)
PS C:\workspace\iced-tour>
joshuamegnauth54 commented 1 year ago

I'm going to attempt to fix this sometime later this week. I managed to reduce your example down to:

    fn view(&self) -> Element<'_, self::Message> {
        let text_input = TextInput::new("", "");
        let content =
            Scrollable::new(text_input).direction(Direction::Horizontal(Properties::new()));
        content.into()
    }

The bug seems related to rounded widgets and Scrollables based on the backtrace.

Full example for easy copy and pasting:

use iced::{
    widget::{
        scrollable::{Direction, Properties},
        Scrollable, TextInput,
    },
    Element, Sandbox, Settings,
};

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

struct Example;

impl Sandbox for Example {
    type Message = Message;

    fn new() -> Self {
        Self
    }

    fn title(&self) -> String {
        "Issue 2066".into()
    }

    fn update(&mut self, _message: Self::Message) {}

    fn view(&self) -> Element<'_, self::Message> {
        let text_input = TextInput::new("", "");
        let content =
            Scrollable::new(text_input).direction(Direction::Horizontal(Properties::new()));
        content.into()
    }
}

fn main() -> iced::Result {
    Example::run(Settings::default())
}