kiwix-js-pwa icon indicating copy to clipboard operation
kiwix-js-pwa copied to clipboard

Testing the draft File Handling API

Open Jaifroid opened this issue 2 years ago • 5 comments

I obtained an Origin Trial token to test out the draft File Handling API on https://kiwix.github.io/kiwix-js-windows/ (the token would work for any kiwix.github.io site that implements the API). This issue is to gather feedback before submitting to the trial.

Because this API depends on the File System Access API, it is only so far supported in browsers that support the latter, i.e. Chrome and Edge, and only on desktop. The Origin Trial requires >= Chromium 92 (for Edge, this means the Beta version). Otherwise the user can turn on the API for local testing with a flag. No flag is needed for browsers that meet the requirement.

The PWA must be installed to handle file types and/or mime types. On first launch with a registered file or mime type, the app asks permission to handle such files (see screenshot). Thereafter, on lauching the app by double-clicking a ZIM archive, the app will open and will immediately show the landing page without further permission prompts. This is fairly similar to drag-and-drop (which we already support in both Kiwix JS and Kiwix JS Windows), except that the file handle is serialized to IndexedDB and persisted across sessions. If user opens the app "normally" (from its shortcut), then the previously handled file is remembered, but as per the File System Access API, a permission prompt to open that specific file is displayed (simple Yes / No response required).

The Origin Trial is time-limited, and there will be a breakage period between the trial and any future adoption of the API.

image

Jaifroid avatar Jul 08 '21 11:07 Jaifroid

A side effect of this API is that drag-and-drop is now treated as a launch event, and the filehandle can be serialized to IndexedDB. This wasn't possible before (other than by using UWP/WinRT APIs, but only in the UWP app, not in the PWA).

Jaifroid avatar Jul 08 '21 15:07 Jaifroid

After a request, I have provided positive feedback to the Chromium devs on this API. It is working very well with the PWA version.

Jaifroid avatar Aug 20 '21 05:08 Jaifroid

After the trial ended, this API stopped working in the app. This is by design and is known as a "breakage" period. It is slated for release in Chromium 98. Current stable Edge is on Chromium 97. Once we have stable 98, I will test again. In the meantime, the origin tokens have been removed from the app, but I have kept the required manifest entries.

Jaifroid avatar Jan 20 '22 06:01 Jaifroid

This is still not working in Chromium. The release has now been bumped to 102. At least Edge Chromium is still on a lower number.

Jaifroid avatar May 05 '22 06:05 Jaifroid

The File Handling API is now working well in Chrome, but not yet in Edge (Chromium), which is strange, because it is the same release number (102).

Jaifroid avatar Jun 13 '22 23:06 Jaifroid

In a new install of the PWA in Windows sandbox, the File Handling API works fine. It is possibly the case that having the UWP app installed in Windows interferes with the PWA file handling, because both try to handle ZIM archives.

Jaifroid avatar Mar 05 '23 22:03 Jaifroid