iced
iced copied to clipboard
scrollable content produces - attempt to add with overflow error
Is there an existing issue for this?
- [X] I have searched the existing issues.
Is this issue related to iced?
- [X] My hardware is compatible and my graphics drivers are up-to-date.
What happened?
I'm using the latest 0.12.0 release I made a simple program with just a single text widget put it into a container with Length::Fill for width and height. This works no issue. I then put the content into a scrollable using Length::Shrink or Length::Fill for width and height and get an error "attempt to add with overflow" text_render.rs:210:33.
if I use max_height in the container and set to any number, the error does not occur.
What is the expected behavior?
The scrollable should either shrink or fill without having to use max_height for a container
Version
master
Operating System
Linux
Do you have any log output?
thread 'main' panicked at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glyphon-0.5.0/src/text_render.rs:210:33:
attempt to add with overflow
Filling a scrollable
in the scrolling direction is considered an invalid layout, since the available space is infinite.
I'll look into adding a debug assertion here to make the runtime error easier to debug.
Thanks a lot for your help. I had assumed that when the container fills to the window size, then scrollable, when shrinked, would be the size of the window and not infinite, even though I wouldn't expect it the be used or maybe visible until the content exceeds the windows size.
Reproducer (for iced 0.12.1) below.
Scrolling down on the text box results in a panic.
Edit: seems like this is a different panic, even if related. I can open a new issue if needed.
use iced::widget::text_editor::{Action, Content};
use iced::widget::{scrollable, text_editor};
use iced::{Application, Command, Element, Renderer, Settings};
#[derive(Debug, Default)]
struct App {
content: Content,
}
#[derive(Debug, Clone)]
enum Message {
Update(Action),
}
impl Application for App {
type Executor = iced::executor::Default;
type Message = Message;
type Theme = iced::Theme;
type Flags = ();
fn new(_flags: Self::Flags) -> (Self, Command<Self::Message>) {
(Self::default(), Command::none())
}
fn title(&self) -> String {
"Reproducer".to_string()
}
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
match message {
Message::Update(action) => self.content.perform(action),
}
Command::none()
}
fn view(&self) -> Element<'_, Self::Message, Self::Theme, Renderer> {
scrollable(text_editor(&self.content).on_action(Message::Update)).into()
}
}
fn main() {
App::run(Settings::default()).unwrap()
}
Full Panic Backtrace (The file above is scroll/src/main.rs
)
thread 'main' panicked at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/cosmic-text-0.10.0/src/buffer.rs:488:26:
attempt to add with overflow
stack backtrace:
0: 0x5621ea7d75b6 - std::backtrace_rs::backtrace::libunwind::trace::hbee8a7973eeb6c93
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x5621ea7d75b6 - std::backtrace_rs::backtrace::trace_unsynchronized::hc8ac75eea3aa6899
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x5621ea7d75b6 - std::sys_common::backtrace::_print_fmt::hc7f3e3b5298b1083
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:68:5
3: 0x5621ea7d75b6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbb235daedd7c6190
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:44:22
4: 0x5621ea803cd0 - core::fmt::rt::Argument::fmt::h76c38a80d925a410
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/fmt/rt.rs:142:9
5: 0x5621ea803cd0 - core::fmt::write::h3ed6aeaa977c8e45
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/fmt/mod.rs:1120:17
6: 0x5621ea7d412f - std::io::Write::write_fmt::h78b18af5775fedb5
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/io/mod.rs:1810:15
7: 0x5621ea7d7394 - std::sys_common::backtrace::_print::h5d645a07e0fcfdbb
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:47:5
8: 0x5621ea7d7394 - std::sys_common::backtrace::print::h85035a511aafe7a8
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:34:9
9: 0x5621ea7d8a67 - std::panicking::default_hook::{{closure}}::hcce8cea212785a25
10: 0x5621ea7d87c9 - std::panicking::default_hook::hf5fcb0f213fe709a
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:292:9
11: 0x5621ea7d8ef8 - std::panicking::rust_panic_with_hook::h095fccf1dc9379ee
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:779:13
12: 0x5621ea7d8d99 - std::panicking::begin_panic_handler::{{closure}}::h032ba12139b353db
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:649:13
13: 0x5621ea7d7ab6 - std::sys_common::backtrace::__rust_end_short_backtrace::h9259bc2ff8fd0f76
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:171:18
14: 0x5621ea7d8b30 - rust_begin_unwind
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
15: 0x5621e9241ea5 - core::panicking::panic_fmt::h784f20a50eaab275
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
16: 0x5621e9241f63 - core::panicking::panic::hb837a5ebbbe5b188
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:144:5
17: 0x5621e9ac01ed - cosmic_text::buffer::Buffer::shape_until_scroll::h155b2e49675888f0
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/cosmic-text-0.10.0/src/buffer.rs:488:26
18: 0x5621e9ad31e1 - <cosmic_text::edit::editor::Editor as cosmic_text::edit::Edit>::shape_as_needed::hf9def9506b02f185
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/cosmic-text-0.10.0/src/edit/editor.rs:108:13
19: 0x5621e938548d - <iced_graphics::text::editor::Editor as iced_core::text::editor::Editor>::update::h50a5a3b07df33387
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_graphics-0.12.1/src/text/editor.rs:555:9
20: 0x5621e9392773 - <iced_widget::text_editor::TextEditor<Highlighter,Message,Theme,Renderer> as iced_core::widget::Widget<Message,Theme,Renderer>>::layout::h6eeb85c0e185d29a
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_widget-0.12.3/src/text_editor.rs:364:9
21: 0x5621e9398078 - <iced_widget::scrollable::Scrollable<Message,Theme,Renderer> as iced_core::widget::Widget<Message,Theme,Renderer>>::layout::{{closure}}::ha6528909ec2b500e
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_widget-0.12.3/src/scrollable.rs:249:17
22: 0x5621e9395f96 - iced_widget::scrollable::layout::{{closure}}::hac3b0b98e4560efb
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_widget-0.12.3/src/scrollable.rs:495:9
23: 0x5621e9340d07 - iced_core::layout::contained::h7759415aa4569456
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_core-0.12.3/src/layout.rs:144:19
24: 0x5621e9395d26 - iced_widget::scrollable::layout::h8ec63ec48d675836
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_widget-0.12.3/src/scrollable.rs:478:5
25: 0x5621e9397fef - <iced_widget::scrollable::Scrollable<Message,Theme,Renderer> as iced_core::widget::Widget<Message,Theme,Renderer>>::layout::h97360a1fe38685a6
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_widget-0.12.3/src/scrollable.rs:242:9
26: 0x5621e9319d90 - iced_runtime::user_interface::UserInterface<Message,Theme,Renderer>::build::he536885f0320671d
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_runtime-0.12.1/src/user_interface.rs:98:20
27: 0x5621e9309b88 - iced_winit::application::build_user_interface::h2d7e867d3152c3b9
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.2/src/application.rs:611:26
28: 0x5621e9309456 - iced_winit::application::run_instance::{{closure}}::hf2f7f00b5979aeff
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.2/src/application.rs:544:56
29: 0x5621e930b5b7 - iced_winit::application::run::{{closure}}::h6b26d7c6ced1a2d1
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.2/src/application.rs:228:24
30: 0x5621e930bbcf - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::ha1086bd77fafe117
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:294:13
31: 0x5621e930bb6f - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h3299f576d57cbea4
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:294:13
32: 0x5621e928c854 - winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::single_iteration::he5d5060cb1f47735
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.14/src/platform_impl/linux/wayland/event_loop/mod.rs:519:9
33: 0x5621e928f028 - winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::poll_events_with_timeout::h33c15293078532aa
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.14/src/platform_impl/linux/wayland/event_loop/mod.rs:322:9
34: 0x5621e928a43f - winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::pump_events::h005c9da9d7fbd642
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.14/src/platform_impl/linux/wayland/event_loop/mod.rs:236:13
35: 0x5621e928a925 - winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run_on_demand::h7a13d3991619508f
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.14/src/platform_impl/linux/wayland/event_loop/mod.rs:200:19
36: 0x5621e92ec044 - winit::platform_impl::platform::EventLoop<T>::run_on_demand::hbab4204a9a58a969
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.14/src/platform_impl/linux/mod.rs:829:56
37: 0x5621e92ec8d6 - winit::platform_impl::platform::EventLoop<T>::run::hd184898904a77c84
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.14/src/platform_impl/linux/mod.rs:822:9
38: 0x5621e9242b37 - winit::event_loop::EventLoop<T>::run::h141717d75181030c
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.14/src/event_loop.rs:249:9
39: 0x5621e930afef - iced_winit::application::run::hfef76e1ae6738ef7
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced_winit-0.12.2/src/application.rs:243:13
40: 0x5621e92ffed8 - iced::application::Application::run::h7fbf33a766bcefaa
at ~/.var/app/com.jetbrains.RustRover/data/cargo/registry/src/index.crates.io-6f17d22bba15001f/iced-0.12.1/src/application.rs:208:12
41: 0x5621e9246d80 - scroll::main::hb23afce804c4bde7
at ~/GitHub/project/scroll/src/main.rs:43:5
42: 0x5621e92aa7ab - core::ops::function::FnOnce::call_once::hf053e823c0e959c6
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
43: 0x5621e92dbf2e - std::sys_common::backtrace::__rust_begin_short_backtrace::h7feaf4847da37023
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:155:18
44: 0x5621e927f471 - std::rt::lang_start::{{closure}}::hedbc701067ea5b23
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:166:18
45: 0x5621ea7ced01 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h37600b1e5eea4ecd
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:284:13
46: 0x5621ea7ced01 - std::panicking::try::do_call::hb4bda49fa13a0c2b
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
47: 0x5621ea7ced01 - std::panicking::try::h8bbf75149211aaaa
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
48: 0x5621ea7ced01 - std::panic::catch_unwind::h8c78ec68ebea34cb
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
49: 0x5621ea7ced01 - std::rt::lang_start_internal::{{closure}}::hffdf44a19fd9e220
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:48
50: 0x5621ea7ced01 - std::panicking::try::do_call::hcb3194972c74716d
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
51: 0x5621ea7ced01 - std::panicking::try::hcdc6892c5f0dba4c
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
52: 0x5621ea7ced01 - std::panic::catch_unwind::h4910beb4573f4776
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
53: 0x5621ea7ced01 - std::rt::lang_start_internal::h6939038e2873596b
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:20
54: 0x5621e927f44a - std::rt::lang_start::h9d79bf26088ba7ec
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:165:17
55: 0x5621e9246e6e - main
56: 0x7fc18b05d08a - <unknown>
57: 0x7fc18b05d14b - __libc_start_main
58: 0x5621e92428a5 - _start
at /buildstream-build/csu/../sysdeps/x86_64/start.S:115
59: 0x0 - <unknown>
Addressed by #2287.