emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
20.61k stars 1.49k forks source link

Drag and Drop: read incrementally #4654

Open rm-dr opened 2 weeks ago

rm-dr commented 2 weeks ago

Is your feature request related to a problem? Please describe.

When dropping a large file into egui on the web, eframe always reads the whole file---even if file drop events aren't handled. Drag a particularly large file into egui, and eframe will try to load the whole thing into memory. This isn't ideal.

The code below is problematic:

https://github.com/emilk/egui/blob/ca36f3df6319cbba0e2ab4366d51d97caa9e85b6/crates/eframe/src/web/events.rs#L563-L589

Describe the solution you'd like

It would be nice to read dropped files in parts, and only on demand. Seems that Blob.stream() is how JS usually does it, but my knowledge of web is limited.

May be related to #3702