-
Notifications
You must be signed in to change notification settings - Fork 25
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
A Label with too much text (font and font size dependent) causes wgpu panic #415
Comments
I tried pasting a few markdown docs into the text editor of
This could be system-specific — one of the big issues with using hardware-accelerated rendering. I tried measuring usage locally and saw maybe 60-200MB (on top of approx. 2.4GB just from desktop apps). Can you check your video RAM size and usage? There should be a software-rendering fallback, but there isn't yet: #287 |
radeon 6700xt / linux / wayland
I sure hope 12gb is enough... |
That's basically what I have (but only 8GB version), so probably something else... I reproduced with that document. It turns out to only be one long (>16k) line that's responsible. Then I see this in the log:
That's a stupidly big window, but the buffer should only be around 22MB. It might exceed the maximum texture size though. The winit window builder:
Overriding the size like this ( builder = builder.with_inner_size(winit::dpi::LogicalSize { width: 2000, height: 1000 }); Looks like I shouldn't rely on winit to enforce a reasonable maximum window size. On the other hand, what reasonable value is there other than the display size? And given that I must supply a window size in logical pixels while the monitor sizes are only available in physical pixels and I also don't know which monitor the window will appear on, it's not obvious how to solve this. |
Note further: the crash isn't actually due to the window being constructed, but the GPU buffer. However, enforcing the window size is still probably the most sensible option. |
your window creation logic is very weird but this should make sure the windows's not too big while still using your weird constraints // Opening a zero-size window causes a crash, so force at least 1x1:
let ideal = solve_cache.ideal(true).max(Size(1, 1));
let ideal = match use_logical_size {
false => ideal.as_physical(),
true => ideal.as_logical(),
};
let mut builder = WindowBuilder::new();
let window = builder
.with_maximized(true)
.with_title(self.widget.title())
.with_window_icon(self.widget.icon())
.with_decorations(self.widget.decorations() == kas::Decorations::Server)
.with_transparent(self.widget.transparent())
.build(elwt)?;
let (restrict_min, restrict_max) = self.widget.restrictions();
if restrict_max {
window.set_max_inner_size(Some(ideal));
}
if restrict_min {
let min = solve_cache.min(true);
let min = match use_logical_size {
false => min.as_physical(),
true => min.as_logical(),
};
window.set_min_inner_size(Some(min));
}
let scale_factor = window.scale_factor();
shared.scale_factor = scale_factor;
let size: Size = window.inner_size().cast();
log::info!(
"new: constructed with physical size {:?}, scale factor {}",
size,
scale_factor
); |
the crashes are fixed but there's a race condition, if you scroll the ScrollLabel and after you jiggle the mouse near/over any window border the view will snap to a different position, it doesn't happen if you don't jiggle |
also, I want my view to display another string when I turn a page from my book so I replaced ScrollLabel with ScrollRegion::new(kas::widgets::Text::new(Book::display))
//and later
.on_message(|_, book, SwitchToPage(page_number)| book.show_page(page_number)); but this view has the worst scrolling i've ever seen and the cursor scrolls instead of selecting (grab-scrolling has much less lag than wheel scrolling for some reason) how do I make something that works like an interactive ScrollLabel? |
Sure, things are much simpler when window size is fixed as in many systems. Your logic "works" because you don't set the window's
I don't follow. Without Are you using drag-scrolling? There is momentum (flick) scrolling support and I have found that doesn't always stop moving correctly (I think the only issue is usually queuing extra wake-ups despite having reached the end of the scroll range).
The easy option is static pages: It looks like you are trying a harder option: re-assigning a single
Check the code. It's not as bad as |
I always --release, the problem for scrolling (with regular mousewheel) ScrollLabel is not scrolling or stopping, it's that once stopped, it snaps to another position if the mouse cursor has left and reentered the window between the last scrollevent and when the view stops moving
Not an option, loading all the text of all the pages at startup (like in a
basically I use Text::new(Book::display) as a Label that recreates itself by calling Book::display on Book when Book is turned
when an open page closes the selection can be dropped along with the content of the page
kas-widgets/src/scroll_label.rs looks like black magic to me |
I didn't observe this — how can I reproduce?
It is also possible to add new widgets to a
Lol. Kind of true, if you haven't looked into how the |
Displaying a big string in a scrolling view is a common use case but ScrollLabel::new(LOTS_of_TEXT) panics
error (on master but reproduces on alpha and 0.13):
code
Scroll<Label>
and justLabel
behave identicallyfor LOTS_of_TEXT you can use for example
r##"source html from https://github.com/kas-gui/kas"##
which displays at
.with_font_size(1.0)
but crashes at 2.0, an ebook chapter crashed at 14.0The text was updated successfully, but these errors were encountered: