-
-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finding local .zim files takes a very long time ~15 minutes #3646
Comments
I can only support this issue, really wonder myself. Maybe there a legit explanation, then very interested in it. |
I have just tested this issue on Samsung Galaxy Tab S4 running Android 10 and here it works fine -- it discovers these files in "just" 1 minute and 46 seconds. Still a bit slow, but acceptable. This tablet has the same 1TB microsd and a slower CPU than Note10+ (and 1/3 of RAM -- 4GB vs 12GB, though it is probably irrelevant). |
@tigran123 Do you have a lot of other kinds of files (on the SD card) beside the two ZIM files? |
Yes, my books library (30,000 books) and Audio library (100,000 files), but they are all in other subdirectories ( But all these other files are present on both the tablet and the phone (I always have my library close, being a "bookworm" :) |
@tigran123 OK, we have found I guess why this is that slow. But I will leave @MohitMaliFtechiz give the full answer. Hopefully we can better filter by filename extensions... @MohitMaliFtechiz Sorry for my ignorance but I have a few questions:
|
If you think that it is the presence of 150k other files that slowed Kiwix down, then I suspect that you are mistaken, because I vaguely remember that when I was setting up this Note10+ smartphone the ZIM files for Kiwix were the first thing that I copied to the microsd, i.e. the books and classical music were NOT yet there -- the microsd was essentially empty. And, as far as I remember, Kiwix was extremely slow to find those ZIM files. Anyway, it is easy to verify this -- tomorrow I'll just take a small microsd card 200GB in size and will copy just the ZIM files to it -- let's see how fast Kiwix will find them. My guess is -- in 14 minutes. Well, if I am mistaken then this is a very serious bug in Kiwix -- it certainly shouldn't go looking in places where it is not supposed to, i.e. outside the directory explicitly designated by the user. |
Actually, on my tablet the Books and Audio live in |
As promised, I performed the experiment and confirm that on a 200GB microsd with only the two ZIM files present in So this means there is a bug in Kiwix -- it ignores the storage setting pointing it directly to So, I suggest that you fix Kiwix app to honour the user-specified location, IF it is specified. But if nothing is specified, then, yes, it may proceed to scan recursively the whole |
Can someone explain to me how this is achieved? In my Settings I can only should internal or external... nothing else. |
When you touch "External" there appears a UI dialog which allows you to select a specific directory and then you have to touch a button at the bottom which says "use this folder". This is a very useful and correct policy, but unfortunately Kiwix appears to ignore this selection. In that dialog you can even change the device, i.e. select internal even though you have selected external at the previous step, but we are not talking about this feature -- we are talking about a specific subdirectory within a given mounted storage filesystem. |
Wow, I don't have this feature on my phone. I guess this is non-playstore-version only. Anyway, this is a feature I don't remember to have validated at all (I might have forgotten)... that said I understand it could be useful even if pretty hacky. My main concern is the mix which seems to be made between different concepts: @MohitMaliFtechiz Therefore my questions to #3646 (comment) |
Yes, this UI chooser only appears in the version installed from apk downloaded from your website. And only on Android 12, not on Android 10 (not sure about Android 11 as I don't have any devices that run it). |
Some programs (e.g. ebookdroid) allow the user to select the list of locations to scan, so that one can specifically avoid some locations which are known to have millions of irrelevant files to prevent the problems we are discussing. It would be good if Kiwix could do the same. Or, at the very least, allow the user to set a single location to be used for all the three purposes you described above. Even this minimalistic approach is good enough, imho. |
@kelson42, For the feature that @tigran123 asking we need to fix the #3636 after that we can do it. If a user selects a directory then.
|
@MohitMaliFtechiz not asking how it should be, asking how it is today. |
For now, we are scanning the whole storage and showing ZIM files on the library screen. On Android 11 and above we are taking the
|
@MohitMaliFtechiz You still don't answer the questions asked at #3646 (comment). Please stop explaining why things are like this or talk about permissions, because there the concern I have so far is conceptual. |
@MohitMaliFtechiz Thank you, I understand now that you have to deal with the various versions of Android and this makes it more difficult to implement and more confusing to explain to others. Now, for older versions of Android I have no complaints about the current behaviour. As all versions of Android up to and including 10 allow other apps to access a particular app-specific data directory on external storage (in my case Termux, i.e. /storage/XXXX-YYYY/Android/data/com.termux) then there is no issue there. I just store Books and Audio as "Termux's private data" and it is visible to all other apps with no problem, and I can do rsync to/from a Linux host serving as a "library centre". But for newer versions of Android (11+) I would like to make the following suggestion. Please consider to implement it, if it is not too hard. This is what I suggest. If the user did NOT specify a specific directory via UI chooser, then the current behaviour is acceptable -- no changes required. But if the user DID point to a specific directory, then would it be possible to kill the current scanning thread (presumably trying to scan the whole storage, both internal and external) and restart it but with the parameter telling it to search JUST THIS user-specified directory (recursively, of course) and nothing else? If this is implemented, then the problem of the current ticket will go away. Thank you. Just to clarify: I cannot move Books and Audio outside |
Extremely sorry about that!!
It is slow because it scans the full storage to filter the ZIM files by their extension. We should try to improve this scanning process. kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/utils/files/FileSearch.kt Line 75 in 61c6f96
kiwix-android/core/src/main/java/org/kiwix/kiwixmobile/core/utils/files/FileSearch.kt Line 60 in 61c6f96
No, scanning is not related to the storage setting, scanning worked independently.
Yes, while scanning the storage, there is a loading progress showing on the library screen, it hides when the storage scanning is complete. |
Hmm, I see. Well, in that case I guess what I am suggesting in the previous message also implies using this user-specified directory as a place where to look for side-loaded ZIM files. I think it makes perfect sense to do this, don't you? And for the older versions of Android (where no UI directory picker appears) the user's selection of "Internal/External" should imply some default hardcoded location like |
No, that does not appear to be the case on my system (both Android 10 and 12). All I see is a rotating circle, but it does NOT indicate progress in any way, just the status "busy". Here is the screenshot: |
@tigran123 yes, It's the circular loading progressBar that we are showing while scanning the storage. |
Unfortunately, it cannot serve as a progress bar, because it does not show the progress at all. It is making 360-degree rotations indefinitely, so how am I to decode the progress from these rotations? There is no way to do this. I repeat: it is just a BUSY status indicator, not a progress bar. My screenshot may be confusing you because obviously it can show an instantaneous picture (it is not a video) -- which would look like a "circular loading progress bar". But obviously I am assuming that you are not looking at a screenshot, but know exactly what I am talking about -- the circular string inside a circle (like a snake) is making 360 degree (FULL CIRCLE!) rotations infinitely many times. So it cannot serve as a progress bar. If it was slowly moving and the completion would correspond to 360 degree, then, yes, it could serve as a progress indicator. But that is certainly NOT what actually happens. |
@tigran123 I concur with your perspective. This implementation was established quite some time ago, likely with a specific purpose in mind. One possible reason is that we perform a comprehensive scan of storage across various locations, both internal and external. Consequently, we traverse through every conceivable path in search of ZIM files, employing different methods to check for their existence. For instance, distinct methods are used to examine app-specific directories in internal and external storage. We amalgamated all potential paths and methods for scanning storage, which explains why there is no progress indicator displayed on the page. Instead, we showcase a continuous rotating circle until the scanning process is complete. |
I know we've discussed this several times in different issues, but this just reinforces for me that this "scanning" behaviour is a cause of a lot of problems for the Kiwix Android app (not least that it is disallowed by the Play Store), and should IMHO be considered a legacy behaviour. Nowadays users may have tens of thousands of photos, etc., and scanning everything is no-longer acceptable behaviour for users from a privacy perspective, as well as being increasingly impractical. If #3628 can be achieved, maybe it's time to think about retiring this full device-scanning code. |
@Jaifroid Ok, it would seem that you are suggesting to use the file-picker to point to a specific .zim file, is that correct? But is it short-lived (the comment mentioned "file descriptor" which is short-lived, but I wasn't sure if it referred to the file-picker or not) or can the reference to .zim file be reused in subsequent sessions? What I am asking is this: currently, if I click on the So, before retiring the full device-scanning code one has to carefully and clearly formulate what it is going to be replaced with. |
@tigran123 Android has persistent permissions (if the permission is stored by the app in the correct way), so choosing a folder to scan for ZIMs contained in it (and optionally any subfolders) needn't be temporary. I don't think it should matter that the file is being accessed via file descriptors. Once the app has been granted permission by the user, the permission should be storable. Regarding bookmarks, I don't know the current mechanism, but I envisage they should be stored in the app's database (or possibly its own scoped file system) independently of the location of ZIM archives. If a user opens a bookmark for a ZIM the app can no longer find, the user should be prompted to open the correct location. All of above is just my tuppence. I'm not an Android dev here (I work on the PWA). |
Ok, then it is by omission that Kiwix does not add the .zim file (added via
Currently this does not happen -- instead, just an error message is shown about the missing .zim file. |
@Jaifroid Yes, we are thinking about it, I am waiting for #3628 to complete.
@tigran123 Thanks for your suggestion, we are planning to implement this in #3628. |
@MohitMaliFtechiz please open a dedicated ticket and fix quickly in a dedicated PR. This has nothing to do with the playstore and is a bug. |
@MohitMaliFtechiz Can we do anything to speed-up the scanning? Better inform the user about time left? Run this scanning at more pertinent time? |
The best way to speed up scanning is by NOT doing any scanning at all. If the interface with a plus button |
@MohitMaliFtechiz Do we have a way to make this scanning:
Question to speed-up the overall operation remains. |
Edited: @tigran123, It is likely a good option; however, rather than disabling the scanning feature, we should consider enhancing it. The scanning process could be significantly expedited if users are given the option to designate a specific folder for all their ZIM files. Additionally, users could manually select additional ZIM files via the "+" button, which would then be automatically added to the library screen.
Yes, we can show the remaining time of scanning. And also I will try to improve the scanning process.
Yes we can do this by disabling the default scanning when opening the
It would be good to show a progress bar to show the remaining progress of the scanning process that will show the remaining time of the scanning. |
Describe the bug
On Android 12 running on Samsung Galaxy Note10+ phone it took 14 minutes 5 seconds to find just two .zim files.
Expected behavior
Should take a few seconds. Actually, reading a directory and discovering those files should take 2-3ms, but assuming x1000 application overhead it should still complete in a couple of seconds, no more. Also, allowing one more second for reading and parsing the metadata I would say the maximum allowed time for this is 3 seconds. However, if the .zim file architecture is wrong, i.e. if the file is compressed (the 'z' in the name gives this hint) AND the metadata is stored inside the archive, then it would take about 15 minutes to access 100GB files, which is very bad, because this sort of processing should not depend on the filesize. To test this theory I would have to try with the smaller .zim files.
Steps to reproduce the behavior:
/Android/media/kiwix
. I used WikiPedia English (102GB latest) and WikiPedia Russian (33GB latest)./Android/media/kiwix
directory (making sure that it does point to External device first)Screenshots
Environment
This problem was also mentioned in #3604
The text was updated successfully, but these errors were encountered: