-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
The version 3.0.0 is not async in chrome #280
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
Comments
Could you give us a code sample ? Several things can affect the speed: the type of file contents, parameters given to |
I tried your script with multiple 1MB files and it`s worked. I tested mine with File or ArrayBuffer, and it worked too. However, when I used a bigger file 10 - 20MB for example, I got the same behaviour as my first post. |
It looks like the issue comes from
YuzuJS/setImmediate updates the global object, I'll check zloirock/core-js. |
As says the documentation of [asap](https://github.com./kriskowal/asap), > ASAP strives to schedule events to occur before yielding for IO, > reflow, or redrawing. The goal of async methods in JSZip is to not freeze the browser, a macro task is a better choice here. See https://github.com./YuzuJS/setImmediate#macrotasks-and-microtasks for a description of micro/macro tasks. Fix Stuk#280.
I just tried the pull request and nothing change in the chrome profile. There is always a big long flush() call if the file is large enough. I tested it in nodejs ( simple fs readFile -> zipping uInt buffer and trying to write a stdout every sec) and it freezed for couple of second every time. I'll post script and zip sample to be able to test the code from now on. |
@CVex2150J I updated the plunker here to use https://rawgit.com/dduponchel/jszip/fix_280_dist/dist/jszip.js instead of the v3.0.0 file and I get the expected result (I get the bug with the old plunker, not with the new one): Same with nodejs. With the following script var JSZip = require("./jszip_pr288");
var fs = require("fs");
var tickCount = 0;
setInterval(function () {
console.log("tick", tickCount);
tickCount++;
}, 200);
var zip = new JSZip();
for (var i = 1; i <= 20; i++) {
// 20 files, generated with
// for i in `seq 1 20`; do
// dd if=/dev/urandom of=$i.data bs=1M count=$i
// done
zip.file("" + i, fs.readFileSync(i + ".data"));
}
console.log("start");
zip.generateAsync({type:"arraybuffer", compression:"DEFLATE"})
.then(buffer => console.log(buffer)); I get regular How do you reproduce your issue with the updated files from the pull request ? |
I was using jszip 2.6.0 for at least 1 years and it work great with a minus problem("stopping" javascript execution for a while) but it was "ok". Now with the chrome upgrade 50.0.2661.75 m I get "aw snap" page most of the time (I zip a large string therefore stalling the javascript for more than 20 sec of work).
I'm really happy to see v3.0.0 with all thoses async methods. But during my tests for the last 2 days to solve my "aw snap" problem I found that on chrome 50 and using the latest build and async functions... my javascript block at generateAsync()
I did a test on NodeJS and it seems to work ok (not 100% sure)
There is a screenShot of chrome devTool. I tried to generate a zip with 22 files in it (~21MB of data). The flush function block all javascript execution for 4.73s.
I will use multiple zips generation as a work around for the moment.
The text was updated successfully, but these errors were encountered: