openzim / overview

:balloon: Start here for current projects, how to get involved, and joining community calls. A resource for new and veteran members of the offline commmunity
2 stars 1 forks source link

Which persistent storage is available in ZIM readers? #39

Open benoit74 opened 4 days ago

benoit74 commented 4 days ago

Readers should provide a way for JS running inside the ZIM to persist some data, typically when navigating from page to page in a single session but ideally also between user sessions.

https://github.com/openzim/ted/issues/208 has shown that it is a least unclear what readers are currently supporting and what they are supposed to support.

I propose to setup a ZIM with both local storage and cookies, and we should then check how this behaves in all readers. Based on that, we can decide what is reasonable to request as mandatory / optional.

benoit74 commented 4 days ago

TL;DR

So far, only local storage works as expected across all tested readers

Details

I've created a very basic test setup (HTML + JS), available at https://tmp.kiwix.org/ci/persitent_storage/persistent_storage_20240704.tar

ZIM has been created with zimwriterfs:

docker run -it --rm -v $(pwd):/data -v $(pwd)/..:/output ghcr.io/openzim/zim-tools zimwriterfs -w index.html -I logo.png -l eng -t "Persistent storage tests" -d "Tests of cookies and local storage in a ZIM" -c "Mixed" -p "openZIM" -n "tests_en_persistent-storage" -L "Tests of cookies and local storage in a ZIM" /data /output/tests_en_persistent-storage_2024-07.zim

Resulting ZIM is available at https://tmp.kiwix.org/ci/persitent_storage/tests_en_persistent-storage_2024-07.zim

kiwix-serve

Tested on a Mac M1, Mac OS Sonoma 14.5.

Firefox

With Firefox 127.0.2

✅ Local storage works as expected, value is kept across browser restart.

✅ Non-expiring cookie works as expected, value is kept across browser restart.

⚠️ Session cookie value is kept but a bit too much, it is not dropped at application restart.

Safari

With Safari 17.5 (19618.2.12.11.6)

✅ Cookies and local storage works as expected ; session cookie is dropped at browser restart ; non-expiring cookie and local storage values are kept across browser restart.

Chrome

With Chrome 126.0.6478.127

✅ Cookies and local storage works as expected ; session cookie is dropped at browser restart ; non-expiring cookie and local storage values are kept across browser restart.

kiwix-apple

✅ Tested on a Mac M1, Mac OS Sonoma 14.5 with kiwix-apple 3.4.0 (166)

✅ Local storage works as expected, value is kept across browser restart.

⚠️ It is impossible to set cookie (we probably get an error, but I can't debug).

kiwix-android

Tested on a Fairphone 4 5G, with Android 13 and kiwix-android 3.10.0

✅ Local storage works as expected, value is kept across browser restart.

✅ Non-expiring cookie works as expected, value is kept across browser restart.

⚠️ Session cookie value is kept but a bit too much, it is not dropped at application restart.

pwa

Tested with pwa.kiwix.org 3.3.6 on Firefox 127.0.2, Safari 17.5 (19618.2.12.11.6), Chrome 126.0.6478.127 on a Mac M1, Mac OS Sonoma 14.5.

⚠️ pwa fails to load the index.html

Kiwix-JS

Firefox

Tested with browser extension 4.0.1 on Firefox 127.0.2 on a Mac M1, Mac OS Sonoma 14.

✅ Local storage works as expected, value is kept across browser restart.

✅ Non-expiring cookie works as expected, value is kept across browser restart.

⚠️ Session cookie value is kept but a bit too much, it is not dropped at application restart.

Chrome

Tested with browser extension 4.0.1 on Chrome 126.0.6478.127 on a Mac M1, Mac OS Sonoma 14.

✅ Cookies and local storage works as expected ; session cookie is dropped at browser restart ; non-expiring cookie and local storage values are kept across browser restart.

Conclusion

So far, only local storage works as expected across all readers

mgautierfr commented 3 days ago

Seems kiwix-desktop is missing

benoit74 commented 3 days ago

Tester(s) on kiwix-desktop and/or iOS are welcomed ! ;-)

mgautierfr commented 14 hours ago

kiwix-desktop (qt5)

✅ Tested on linux Fedora, kiwix-desktop locally build

⚠️ Local storage works, value is NOT kept across browser restart.

⚠️ It is impossible to set cookie (we probably get an error, but I can't debug).