Giter Club home page Giter Club logo

Comments (13)

brendan-duncan avatar brendan-duncan commented on August 21, 2024 1

Looks like I'll need to rework the cache for the zlib decompression a bit. The file seeking it needs to do is going outside the bounds of the in-memory cache, and causing file io thrashing. I had previously improved it for smaller compressed blocks, like in that Audios zip, but the other zips in your collection have much larger compressed blocks. Hopefully I can get that fixed up soon.

from archive.

brendan-duncan avatar brendan-duncan commented on August 21, 2024

If it's possible, maybe you could try the 4.0 branch I've been working on. You'd have to change your pubspec to the git path:

dependencies:
  archive:
    git:
      url: https://github.com/brendan-duncan/archive
      ref: '4.0'

I did a bunch of work on memory and file io performance in that branch, it would be great to know if it's enough to get past the iOS memory issues. It should also be considerably faster to extract that zip too. I tested the previous version and it took over a minute, and on the 4.0 branch it took a couple seconds.

from archive.

CaptainDario avatar CaptainDario commented on August 21, 2024

Thank you for your reply!
I will try this today in the evening, but this does not only happen on iOS but also on Android.

from archive.

brendan-duncan avatar brendan-duncan commented on August 21, 2024

Mobile is much more restrictive with memory.
The 4.0 branch is now in the main branch, it will be the next version update. So you can test without the git branch:

dependencies:
  archive:
    git:
      url: https://github.com/brendan-duncan/archive

from archive.

CaptainDario avatar CaptainDario commented on August 21, 2024

Is there a migration guide available?
Hitting this

The method 'decodeBuffer' isn't defined for the type 'ZipDecoder'.
Try correcting the name to the name of an existing method, or defining a method named 'decodeBuffer'.

from archive.

CaptainDario avatar CaptainDario commented on August 21, 2024

I assume it should be decodeStream but I am not sure.

from archive.

brendan-duncan avatar brendan-duncan commented on August 21, 2024

Yeah, decodeStream. There's a migration guide link in the README.

from archive.

CaptainDario avatar CaptainDario commented on August 21, 2024

I tried the new version in debug mode on Android and it is significantly slower, even so much that I cannot use this version.

v3.6.1

I/flutter (18876): assets/dict/dictionary.zip
I/flutter (18876): 0:00:01.509784
I/flutter (18876): assets/dict/examples.zip
I/flutter (18876): 0:00:01.104178
I/flutter (18876): assets/dict/krad.zip
I/flutter (18876): 0:00:00.250422
I/flutter (18876): assets/dict/radk.zip
I/flutter (18876): 0:00:00.170664
I/flutter (18876): assets/ipadic.zip
I/flutter (18876): 0:00:00.384508

master

I/flutter (14027): assets/dict/dictionary.zip
I/flutter (14027): 0:02:35.098774
I/flutter (14027): assets/dict/examples.zip
I/flutter (14027): 0:01:21.271891
I/flutter (14027): assets/dict/krad.zip
I/flutter (14027): 0:00:00.988176
I/flutter (14027): assets/dict/radk.zip
I/flutter (14027): 0:00:00.564761
I/flutter (14027): assets/ipadic.zip
I/flutter (14027): 0:00:26.827676

You can find the used files here.

from archive.

CaptainDario avatar CaptainDario commented on August 21, 2024

But on a positive note, the unpacking of the initially mentioned zip does now work on android in debug mode.
Thanks!

from archive.

CaptainDario avatar CaptainDario commented on August 21, 2024

I could add decodeBuffer back with a deprecated label if you think that would be easier.

No, I think it is fine. I just did not know where to find the migration guide

from archive.

brendan-duncan avatar brendan-duncan commented on August 21, 2024

Well shoot, back to the drawing board then. Sometimes Dart drives me a bit nuts. Must be some extra file io, probably file position seeking, causing the slowdown. Strange the tests I did were faster. Thanks for the report, I'll get it sorted out soon.

from archive.

brendan-duncan avatar brendan-duncan commented on August 21, 2024

Decoding a zip on dart:io platforms should be significantly faster with 4.0 now.

It will use native executed zlib for decompressing zip data on platforms that support it now. The dictionary.zip file was taking >1minute before, takes <1second now.

If you could run your tests on the update in git, that would be appreciated.

from archive.

timautin avatar timautin commented on August 21, 2024

Same problem here using latest 3.x or 4.0. I'm trying to unzip a 2.5 GB archive containing a 1 GB file, it fails on iOS (working on Android). Here's the code:

final input = InputFileStream("/path/to/my-archive.zip");
final archive = ZipDecoder().decodeStream(input);

for (final file in archive) {
  final filename = file.name;
  if (file.isFile) {
    final output = OutputFileStream('/path/to/$filename');
    output.writeStream(file.getContent()!);
    await file.close();
  } else {
    await Directory('${datasetsFolder.path}/$filename').create(recursive: true);
  }
}

And the log:

Exhausted heap space, trying to allocate 1044090912 bytes.
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Out of Memory
#0 new Uint8List (dart:typed_data-patch/typed_data_patch.dart:2236:3)
#1 new OutputMemoryStream (package:archive/src/util/output_memory_stream.dart:17:19)
#2 new Inflate.stream (package:archive/src/codecs/zlib/inflate.dart:37:29)
#3 ZipFile.getStream (package:archive/src/codecs/zip/zip_file.dart:232:21)
#4 ArchiveFile.decompress (package:archive/src/archive/archive_file.dart:208:40)
#5 ArchiveFile.getContent (package:archive/src/archive/archive_file.dart:139:7)
#6 ApplicationState.test (package:atlas/application.dart:77:33)
#7 _FutureListener.handleValue (dart:async/future_impl.dart:162:18)

Are you planning to support this use case or do I need to find a workaround?

from archive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.