Skip to content

ScrollArea: large content makes it sluggish #2906

@hacknus

Description

@hacknus

Describe the bug
When using a ScrollArea with a very large content (thousands of lines) the gui becomes very sluggish.

To Reproduce
Steps to reproduce the behavior:

let content: String = (0..1000000).map(|s| s.to_string() + "\n").collect();
egui::ScrollArea::vertical()
    .id_source("serial_output")
    .auto_shrink([false; 2])
    .stick_to_bottom(true)
    .enable_scrolling(true)
    .show(ui, |ui| {
        ui.add(
            egui::TextEdit::multiline(&mut content.as_str())
                .font(DEFAULT_FONT_ID)
                .lock_focus(true)
                .text_color(egui::Color32::WHITE)
                .desired_width(width),
        );
    });

This is based on the "text_editor" egui example, but the issue also occurs when just using ui.label() to display the content.

Expected behavior
I would expect the GUI to only draw the visible part of the content, so that the total amount would have no impact on the performance.

Observed on Desktop:

  • OS: macOS 13.3.1, Windows 10
  • Browser: not tested
  • Version: latest git

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions