gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.38k stars 510 forks source link

Entry#getData not work since from v2.6.24 on Android System WebView #400

Closed liuwin7 closed 1 year ago

liuwin7 commented 1 year ago

Operation system: Android 10.0

Browser: Android system WebView 74 or 79

Description: After call the Entry.getData(), there is nothing callback.

  const data = await entry.getData!(new BlobWriter());

From the release notes, the transferStreams was introduced from v2.6.24, is that why?

gildas-lormeau commented 1 year ago

No errors are thrown?

liuwin7 commented 1 year ago

Nothing at all on Android system WebView 74, but, Fetch failed will be thrown on the 79. I added the EntryDataOnprogressOptions, onstart \ onprogress \ onend, the callbacks will be called but there is no value from the callback function.

gildas-lormeau commented 1 year ago

Did you try to set the option transferStreams to false when calling Entry#getData()?

liuwin7 commented 1 year ago

Yes, I have tried.

liuwin7 commented 1 year ago

Hi, I forked the project and run the web test on the Android 10.0 emulator shipped with the Chrome v74. Many errors had been thrown.

Uncaught (in promise) TypeError: blob.arrayBuffer is not a function

According the Blob.arrayBuffer, the function arrayBuffer need the minimum version is 76.

Uncaught (in promise) TypeError: Object.hasOwn is not a function

According the Object.hasOwn function hasOwn needs 93+.

gildas-lormeau commented 1 year ago

You have to compile the code with babel. Compatibility with old browsers is outside the scope of the project.

liuwin7 commented 1 year ago

Ok, this is indeed a compatibility issue, however, the incompatibility is not in the APIs blob.arrayBuffer Object.hasOwn above, but the WritableStream. WritableStream.close must be 81 and above, if it is lower than this version, WritableStream dose not work, the close function will not been called.

gildas-lormeau commented 1 year ago

It can be polyfilled, see https://www.npmjs.com/package/web-streams-polyfill. I tested it and it works fine. You will probably need to disable web workers support in zip.js to make it work though.

liuwin7 commented 1 year ago

When disable web workers, an error will occur.

writable.close is not a function