kiwix / kiwix-apple

Kiwix for iOS & macOS
https://apple.kiwix.org
GNU Lesser General Public License v3.0
470 stars 70 forks source link

Library loading is blocking the main thread #861

Open BPerlakiH opened 1 month ago

BPerlakiH commented 1 month ago

When opening the application, the library loading is still doing some heavy work on the main thread. If we open the application it is needed to load the library straight away, but there are cases when this is not immediately needed. Eg. when the Kiwix app is not open, and we open it by clicking on a ZIM file in Finder. If no other windows were saved earlier, it will open the content page, therefore the library loading can be either postponed, or done in the background.

The more ZIM files we have in our library the longer we will be stuck on this screen:

Screenshot 2024-07-12 at 00 32 33
BPerlakiH commented 1 month ago

After some investigation, this is not going to be an easy change, as the underlying Objective-C code is not thread safe, so that needs to be replaced with swift code or split into smaller chunks, so we can do the file open / reading part on a different thread. For this reason I changed the milestone for this to be 3.5.0.