Skip to content
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

Labels in a list are extremely slow on macOS #2281

Open
griccardos opened this issue Oct 25, 2022 · 2 comments
Open

Labels in a list are extremely slow on macOS #2281

griccardos opened this issue Oct 25, 2022 · 2 comments

Comments

@griccardos
Copy link

Loading a few hundred labels are extremely slow on macos, but runs fast on Windows/Linux.
Makes it unusable on macos for anything more than a few labels.

Running instruments on macos I was able to trace most time spent to piet CoreGraphicsTextLayoutBuilder.
Not sure if the issue is there or druid itself.

Below example takes a few seconds after each click of button to load 200 labels on macos, but is instant in windows.
RichText with attributes also takes long.

A minimum working example:

use std::time::Instant;
use druid::{WidgetExt, im::Vector, WindowDesc, widget::{Flex, Button, Scroll, RawLabel, List}, Lens, Data};

#[derive(Clone,Data,Lens)]
struct AppState{
    lines:druid::im::Vector<String>
}

fn main() {
    druid::AppLauncher::with_window(WindowDesc::new(ui_builder()))
    .launch(AppState{lines:Vector::new()})
    .expect("Run druid window");
}

fn ui_builder() -> impl druid::Widget<AppState> {
    Flex::column()
    .with_child(
       Button::new("change")
        .on_click(|_,state:&mut AppState,_|{
        state.lines=std::iter::repeat(format!("{:?}",Instant::now())).take(200).collect::<Vec<String>>().into()
    }))
    .with_child(
     Scroll::new(List::new(|| RawLabel::new()).lens(AppState::lines))
    )
}

If someone else can test and confirm to determine if hardware/setup problem or valid issue.

@raphlinus
Copy link
Contributor

This is probably linebender/piet#472. If so, getting stuff released should fix things right up. We're working on that but depending on volunteers, so don't have a timeline.

@griccardos
Copy link
Author

Thanks for the quick response raphlinus. I think you are correct. I patched the Cargo.toml file to use the github version of piet-common, and it works perfectly on macos. Unfortunately there was also 1 place in druid that needed fixing too (spinner.rs should use piet Color enum, not reference) but after fixing that it works and loads labels significantly faster.

I'll wait until the update is released, and maybe do a workaround until then. I'm testing different GUIs for rusl, and druid is my favourite, so thanks to all working on druid - it is awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants