broot icon indicating copy to clipboard operation
broot copied to clipboard

Feature Request: Async for previews

Open stevenxxiu opened this issue 3 months ago • 1 comments

From https://github.com/Canop/broot/pull/1034#issuecomment-3282024441, displaying large images can be slow.

I identified these as being slow:

  • Creating ImageView:
    • broot/src/preview/preview_state.rs PreviewState::new()
    • broot/src/preview/preview.rs Preview::new()
    • broot/src/image/image_view.rs ImageView::new()
  • Displaying ImageView:
    • broot/src/preview/preview_state.rs preview.display(w, disc, &self.preview_area)
    • broot/src/preview/preview.rs Self::Image(iv) => iv.display(w, disc, area)
    • broot/src/image/image_view.rs ImageView::display()

Could Broot switch to using async? Then the entire preview function could be async. Key presses can then cancel it at any point.

stevenxxiu avatar Sep 29 '25 10:09 stevenxxiu

Could Broot switch to using async?

Broot contains a framework for executing tasks in background and for cancelling them. That's how search works, how long texts are read in background for preview, how sizes are computed, etc.

I'll see if I can improve reactivity by deferring some parts of the computation.

Canop avatar Sep 30 '25 06:09 Canop