Skip to content

Unnecessarily slow because of weird .NET core ZipArchive behaviour #1

@trishume

Description

@trishume

For me using Apkifier to sign takes 20 seconds, not during the actual Sign method call, but in the disposal of the ZipArchive. I did some experimentation and looked at the corefx source code and it seems that opening a file with a ZipArchive in Update mode, even if you only read that file, seems to trigger it being re-written. See https://github.com/dotnet/corefx/blob/aa0c037c1f64c91f73698d0607dea16904d08da8/src/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs#L935

This means that when the signer reads every single entry, it causes them all to be re-written. Even though the actual signing process takes 2s the unnecessary re-writing takes 20s.

My idea for how to solve this is to open the apk in Read mode first, hash all the entries, close the apk, then open it in update mode and do the manifest modifications.

The problem is this doesn't work with the current way Apkifier is set up to keep around a ZipArchive and allow operations on it as well.

My current plan is just to copy-paste the parts I need into QuestSaberPatch and modify it to do this multi-stage version. But I imagine you might want to implement this in Apkifier and I'm opening this to discuss how to do that. Also because Discord is currently failing to connect for me (does it work for you?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions