kiwix / kiwix-js

Fully portable & lightweight ZIM reader in Javascript
https://www.kiwix.org/
GNU General Public License v3.0
309 stars 135 forks source link

content picker not loaded on ubuntu touch #1279

Open LiohMoeller opened 1 month ago

LiohMoeller commented 1 month ago

On Ubuntu Touch it is not possible to add a zim file, as the content picker does not show up on a click on the 'Load ZIM' or 'Select Folder' Button.

kelson42 commented 1 month ago

@Jaifroid Can we still support Ubuntu Touch devices properly?

Jaifroid commented 1 month ago

@LiohMoeller @kelson42 The problem is that I don't have an Ubuntu Touch device to test on. I've no idea why the API has broken. I wonder if it's been restricted recently? We used to have someone willing to test, and we'd send them a package before release, they'd test it and also diagnose any issues. For the last several releases, we've been releasing blind for this platform. I'm not sure what I could do about it unless someone with a device were willing to take a look at the code and debug, or at least point me in the right direction. Possibly the File System Access API appears to be supported but isn't actually, and the fallback to the old File Picker isn't working.

kelson42 commented 1 month ago

@LiohMoeller Are you able to test on a device and help us a bit with the root cause analysis?

LiohMoeller commented 1 month ago

I can just send/donate you a device for development, if that would help.

Jaifroid commented 1 month ago

@LiohMoeller That's very kind, but let me see if there's a reliable simulator I could use first, as I think testing on real hardware would be a bit of a last resort (testing time is already quite onerous). I'll come back to you once I've done some research on this.

Jaifroid commented 1 month ago

So it seems there is this Ubuntu Touch development kit: https://github.com/ubports/ubports-pdk . I'll see if I can get that to run in order to reproduce the issue.

AyushSahoo19 commented 2 weeks ago

Hi team,

Before proceeding, I wanted to ask if the team has already tested the content picker issue using the Ubports PDK to simulate the environment?

Since I don’t have access to an Ubuntu Touch device, my plan is to start by setting up this PDK to simulate the environment. This should help me:

  1. Replicate the Issue: I’ll focus on simulating the API behavior and how the content picker interacts with the system.
  2. Test Fallbacks: I’ll check whether the fallback to the old File Picker is functioning properly, especially if the File System Access API is unsupported or restricted. If I’m unable to reproduce the issue or need further testing on a real device, would it be possible to collaborate with someone who has access to an actual Ubuntu Touch device? Alternatively, do you have any recommendations for other reliable emulators or testing environments beyond the PDK?

Once I have the PDK set up, I’ll begin debugging the content picker and share my findings. Let me know if you have any specific areas in the codebase you think I should focus on, or any additional guidance for testing.

Jaifroid commented 2 weeks ago

Thanks, no we haven't tried replicating the issue yet, so it would be great if you could confirm the bug in the simulator.

The fallback to the standard HTML5 file picker happens if no support for the File System Access API or the webkitdirectory property is found. If either of those are found, then the HTML5 file picker gets hidden. My suspicion is that the APIs appear to be supported, but actually aren't on Ubuntu Touch.

Jaifroid commented 2 weeks ago

Also, the fact that there is a "Select folder" button strongly suggests my hypothesis is true. One of these APIs is being detected, but something is breaking. If neither of those APIs were detected, then the system would show the HTMl5 file picker only, and no "Select folder".

AyushSahoo19 commented 2 weeks ago

Thanks for the details! Could you point me to the specific file or section of the codebase where the content picker’s behavior and fallback mechanisms are handled? This will help me focus on the right part while testing the bug on the Ubuntu Touch emulator. Let me know, and I’ll dive in!

Jaifroid commented 2 weeks ago

Yes of course, just search for openLocalFiles in your code editor, and you should find the picker in index.html and app.js (where the initial logic is handled). There is also abstractFilesystemAccess.js which deals with the logic for the File System Access API, webkitdirectory and a few other things.

AyushSahoo19 commented 2 weeks ago

Before I start debugging the content picker issue, could you let me know which version of Ubuntu (or Ubuntu Touch) I should focus on testing this for? This will help ensure I'm replicating the correct environment.

Jaifroid commented 2 weeks ago

@AyushSahoo19 The bug report was from @LiohMoeller , but I'm assuming this is the latest Ubuntu Touch, because we never had this issue on previous versions of the app (at least until a couple of years ago -- no reports of anything till now). I'm assuming something broke recently (but it could be our end of course).

AyushSahoo19 commented 2 weeks ago

Ok, I’ll proceed with testing the issue on the recent version of Ubuntu Touch.