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

memory access out of bounds when processing large files with use_drop_zone #93

Open
gitmalong opened this issue Mar 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@gitmalong
Copy link

gitmalong commented Mar 16, 2024

Hi!

I found my app becoming unresponsive when working with large files (e.g. 1GB).

let UseDropZoneReturn {
      is_over_drop_zone: _,
      files: _,
  } = use_drop_zone_with_options(
      drop_zone_el,
      UseDropZoneOptions::default().on_drop(move |event| {

          spawn_local(async move {
              for f in event.files.iter() {
                  let js_future = wasm_bindgen_futures::JsFuture::from(f.array_buffer());
                  let js_val = js_future.await.unwrap();
                  let arr = js_sys::Uint8Array::new(&js_val);
                  let data: Vec<u8> = arr.to_vec();

I wonder if files can also be processed via a stream to avoid loading all data into memory at once (if that is supported from browser side)?

Currently it looks like that the file's content is completely loaded into memory: https://github.com/Synphonyte/leptos-use/blob/main/src/use_drop_zone.rs#L92

Uncaught RuntimeError: memory access out of bounds
myapp-ui.js:1508 Uncaught Error: invalid malloc request
@gitmalong gitmalong changed the title Processing large files with use_drop_zone Processing large files with use_drop_zone is blocking Mar 16, 2024
@gitmalong gitmalong changed the title Processing large files with use_drop_zone is blocking Processing large files with use_drop_zone loads whole file into memory / is blocking Mar 16, 2024
@gitmalong gitmalong changed the title Processing large files with use_drop_zone loads whole file into memory / is blocking memory access out of bounds when processing large files with use_drop_zone Mar 16, 2024
@maccesch
Copy link
Contributor

That's a very interesting proposition. I'm not sure when I'll have time to work on this. So a PR would be very welcome.

@maccesch maccesch added the enhancement New feature or request label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants