aonez / Keka

The macOS & iOS file archiver
https://www.keka.io
4.72k stars 237 forks source link

[BUG] Extraction takes way too long #1040

Closed NikxDa closed 2 years ago

NikxDa commented 2 years ago

Workaround

👉 If you're stuck in the quarantine application step please reinstall Keka.

As of version 1.2.53 this issue will be automatically detected and advised to reinstall Keka. You can disable that detection by setting SkipQuarantineSlowdownDetection to TRUE.

Screenshot 2022-02-11 at 16 20 44

If your issue is not related to the quarantine step please open a new issue.


Configuration

Describe the bug

Keka takes way, way, way too long to extract archives. Extracting the Oversight software for example (https://objective-see.com/products/oversight.html), which is 3.5 MB Zip file, takes over a minute. The time remaining always says "5 seconds remaining", yet that is never the case. The macOS built-in archive utility completes the task in probably a fraction of a second.

To Reproduce

I am unsure whether this affects more people. In my scenario, I can repeat the action every time and it will be slow every time for all archives.

Expected behavior

Keka extracts the archive in ~1 second.

Log file

Keka_2022-02-02-203240068.log

aonez commented 2 years ago

This is a dupe of https://github.com/aonez/Keka/issues/992

I'm not sure why it's happening and can't reproduce it. Can you check with this build, that outputs more logs?

https://github.com/aonez/Keka/releases/download/dev-test-builds/Keka-1.2.51-dev.r4843.7z

aonez commented 2 years ago

Just so you know, disabling "Inherit quarantine from downloaded files" in Keka - Preferences - Extraction should workaround the issue, but if you could provide some more feedback it would be awesome to fix this issue.

NikxDa commented 2 years ago

Here are two more extractions of the same archive with the binaries you provided :) Let me know if I can do anything more to help get this fixed, I love Keka in every other aspect!

Async_Keka_2022-02-02-210410069.log Sync_Keka_2022-02-02-210310789.log

NikxDa commented 2 years ago

Also adding a Console log filtered by Keka (but the primary version, 1.2.52).

Keka_Console.log

aonez commented 2 years ago

Thanks a lot for the logs! If you could do the same with those builds:

https://github.com/aonez/Keka/releases/download/dev-test-builds/Keka-Quarantine-Tests-NikxDa.7z

aonez commented 2 years ago

By the way @NikxDa by any change do you have any other apps from Objective-See like RansomWhere? Maybe you could try disabling them, in case this is the cause of the issue.

Even an empty user with no third party apps will be an awesome test but I understand this needs time to try.

NikxDa commented 2 years ago

Nope, no other Objective-See apps in place, this would be the first one. I typically use Micro Snitch but that doesn't produce the process that's using it. It's also the first time installing it (Oversight) on my machine. I'll update with the new logs soon, won't have the time to do so today though!

aonez commented 2 years ago

No problem @NikxDa. Any feedback you can provide will be very welcome.

NikxDa commented 2 years ago

Hi @aonez I just tried to run your custom releases but they don't open up for me at all. Activity Monitor shows them active for a few seconds, then they close on their own. No GUI ever shows up. Is this intended or is there something weird going on there?

aonez commented 2 years ago

They're not notarized by Apple (to share with you faster) so maybe you need to right click - Open?

If not I'll build and notarize them again. Thanks for taking the time :)

NikxDa commented 2 years ago

@aonez That seems to have done the trick, thanks! Interestingly enough, it still presented me with a "Do you want to open this file?" popup yet did nothing when opening it normally...

Attached are all Console & debug logs for the binaries provided. Let me know if you need anything else! (Skip was the fastest, which I guess makes sense!)

Rescopy_Keka_2022-02-06-233829025.log Rescopy_Keka_Console.log Skip_Keka_2022-02-06-233700344.log Skip_Keka_Console.log Sleep50_Keka_2022-02-06-233109063.log Sleep50_Keka_Console.log Sleep100_Keka_2022-02-06-233417797.log Sleep100_Keka_Console.log

aonez commented 2 years ago

So none of those builds improve 😩 Also I'm not seeing any useful message in the Console logs as to why it takes 1+ second to apply it to every file.

Could you extract the quarantine attribute and share it with me? Maybe it helps reproduce the issue on my side, although I don't think it will.

xattr -p com.apple.quarantine/Users/YOURUSERNAME/Downloads/OverSight_2.0.1.zip > ~/Desktop/quarantine.xattr

If you could create an additional user in your machine and try if there's also present the issue will help rule out third party apps/system extensions. Now that I mention it, do you have any Finder extensions active? Probably also won't be the reason but just checking things...

Screenshot 2022-02-07 at 16 30 41
NikxDa commented 2 years ago

@aonez Quarantine attribute is attached!

I also noticed today that the wait time increases with increased file size. I tried extracting a 110 MB zip file and waited for over 20 minutes before aborting. Not sure this information helps, but leaving it here...

quarantine.xattr.zip

Let me know if I can do anything else! :)

NikxDa commented 2 years ago

Also, I can confirm that on a second user on the machine, the issue does not occur! Attached is the quarantine XAttr of the same file on that user, if it helps.

quarantine.otheruser.xattr.zip

aonez commented 2 years ago

Also, I can confirm that on a second user on the machine, the issue does not occur!

Thanks a lot for taking the time on this!!!

As I thought there's nothing wrong with the quarantine flags, they're both correct for your current and new users.

I've created a test application that just applies the quarantine to a folder (previously copies it to /tmp) to see If this issue is only present when running the code with Keka. Check it out if you can, simply drop the "OverSight Installer.app" to this test application icon.

If this test application also takes more than a second I can only think of a third party app, kernel extension, Finder Extension or something else that is affecting the writing of the quarantine on the newly created files, making the process very slow. You can try extracting the same file in an external disk that maybe is not monitored and see if that works as expected (quick). If so, think of file syncing, backup or even virus scanning apps that you may have installed.

If this only affects Keka, and knowing only affects your current user:


This is the code in question that is taking so long:

[newFile setResourceValue:quarantineResources forKey:NSURLQuarantinePropertiesKey error:&error];

Pretty standard code, nothing fancy. I can do a test app that applies the quarantine to a dropped folder to discard this just happens to Keka.

NikxDa commented 2 years ago

@aonez Thanks for taking the time to look into this, I really appreciate the effort you are putting in!

I tested your test application and it is applying the quarantine in 0s - so immediately, no delay or wait whatsoever. Just to confirm I'm not crazy I also tried again using Keka and that (again) took longer than expected. So there seems to be something funky going on.

If you're keen to get this done, I'm happy to jump on a Discord call sometime so you can try to debug it live. Maybe that way it's less of a time sink for you because we remove the "waiting on me to respond" part!

NikxDa commented 2 years ago

Actually, I think I might not be able to stick to my offer from that last message. Deleting Keka & preferences as per your link, then reinstalling fixed it immediately. That would also explain why it's not happening on the other user... Very weird! Looks like I won't be able to offer any more insights with the issue now fixed on my end!

aonez commented 2 years ago

Well, at least we no know that reinstalling Keka fixes that weird issue. Probably this is something related to the sandboxing then, one of those things only Apple (and maybe) knows why.

Thanks again for all the testing and feedback @NikxDa!!! 🙇🏻‍♂️🙇🏻‍♂️🙇🏻‍♂️

aonez commented 2 years ago

Thanks again for all the feedback :)

adrianmihalko commented 6 months ago

I have opposite question: how is Keka so fast? I have a 30GB 7z archive and extration with default unarchiver in MacOS and even with "The Unarchiver" takes so long, but Keka is very fast.