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

Browser tab freezes when using unzip #101

Closed
linkurzweg opened this issue Nov 9, 2021 · 6 comments
Closed

Browser tab freezes when using unzip #101

linkurzweg opened this issue Nov 9, 2021 · 6 comments

Comments

@linkurzweg
Copy link

linkurzweg commented Nov 9, 2021

I am using fflate in a Vue.js 3 app and it it really a lot faster than other packages :)

However, I have the following problem (not sure if it's a bug or if I'm just using it wrong): I'm using unzip to extract a lot of xml files from a zip archive, parse them and push them into a store. As soon as the unzipping operation is started the UI of my vue app completely freezes, nothing is clickable anymore and my loading animation also stops moving.

My code looks like this:

loading.value = true
const fileBuffer = await file.file.arrayBuffer()
const archive = new Uint8Array(fileBuffer)
const unzippedFiles = []

unzip(archive, (err, unzipped) => {
  if (err) {
    console.log(err)
  }
  for (const file in unzipped) {
    const fileString = strFromU8(unzipped[file])
    unzippedFiles.push(parser.parse(fileString, {}, true))
  }
})

store.setDocuments(unzippedFiles)
loading.value = false

What can I do to prevent the freezing? Thank you!

@101arrowz
Copy link
Owner

Could you try just running unzip without the parsing logic afterwards? That function is actually specifically designed NOT to block the UI, so it's a bit weird that it does.

@linkurzweg
Copy link
Author

@101arrowz I tried that already. It takes less time processing the zip file, but everything still freezes. Yes, I read that it is supposed to be non-blocking and to run in another thread...

@101arrowz
Copy link
Owner

Could you send me the file that causes this so I can debug further?

@linkurzweg
Copy link
Author

I'll ask if I'm allowed to :)

@linkurzweg
Copy link
Author

@101arrowz Sorry, I'm not allowed to send it because it contains confidential information. I understand if you can't investigate any further in this.

@101arrowz
Copy link
Owner

Ok that's fine. I'm going to guess that this will be solved by compressing as many files as possible on another thread rather than having an arbitrary byte cutoff by implementing the worker pool from #58, so I'm closing in favor of that issue. If you want to know when this is resolved follow #58; for now you should probably just make a web worker manually and call unzipSync.

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