Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Local storage #76

Closed
dauwhe opened this issue Jan 24, 2019 · 9 comments
Closed

Local storage #76

dauwhe opened this issue Jan 24, 2019 · 9 comments
Labels
bug question triage applied to an issue where we need to figure out what the problem is, and who can help with a solutio

Comments

@dauwhe
Copy link
Contributor

dauwhe commented Jan 24, 2019

Local storage is not reliably supported in most reading systems.

What can be done to help with this? We do have some spec issues around origins. There are bugs in reading systems. What do reading systems have to say about this?

@dauwhe dauwhe added bug question triage applied to an issue where we need to figure out what the problem is, and who can help with a solutio labels Jan 24, 2019
@GarthConboy
Copy link

Well, as a Reading System that doesn't support scripting, I have very little to say. It's difficult to make the case to deal with the plethora of issues around scripting, given the dearth of high-value scripted content and the prohibitive cost of creating such content.

@teytag
Copy link
Collaborator

teytag commented Jan 24, 2019 via email

@llemeurfr
Copy link
Collaborator

llemeurfr commented Feb 5, 2019

Readium projects are based of Web rendering engines, which support LS;
LS is shared between publications if nothing is made to avoid it: this is a security issue;
On our desktop project, care is taken to sandbox storage areas via a virtual publication origin;
This is not the case for most reading systems on the market; those which do not rely on Web rendering engines don't support LS, and most of those which support LS don't sandbox by publication;
LS is not robust: the webview can decide to delete content if it needs space.

@teytag
Copy link
Collaborator

teytag commented Feb 5, 2019 via email

@JayPanoz
Copy link

JayPanoz commented Feb 6, 2019

Adding to Laurent’s answer:

  • “LS is not robust”
    • depending on the implementation, localStorage can even turn into sessionStorage (e.g. Reading System is using a local server with a random port) so don’t count on persistence too much;
    • also, if the origin is global, one localStorage.clear() in one publication = all items are cleared, for all publications ;
    • and if you have a collection of publications making use of localStorage but don’t prefix your items, then you’re constantly overwriting them when the user switches from one to another.
  • “LS is shared between publications if nothing is made to avoid it” → web has no suborigin concept (yet) so that’s a tough challenge for cloud readers;
  • on top of that, Reading Systems may (re)load several or all spine items to compute the total number of reflowable pages for instance, so…
    • expect localStorage to be populated frantically if setting items on DOMContentLoaded or load;
    • don’t assume localStorage.getItem("key") to be reliable on load, it the RS does that.
  • finally, platform web views handle localStorage differently i.e. opt-in vs. opt-out – on Android for instance, you must enable it while it is by default on iOS.

@llemeurfr
Copy link
Collaborator

In summary the real issue is not that LS support by reading systems is usually bad, it is that LS support by underlying rendering engines is suboptimal.

@JayPanoz
Copy link

JayPanoz commented Feb 6, 2019

Note we’ve been working on that use case under an “origin” umbrella here in order to list issues and their possible solutions.

(Our bandwidths are currently low though, so it is not necessarily evolving as fast as we’d like to considering some details are sparse.)

@danielweck
Copy link
Member

@llemeurfr

In summary the real issue is not that LS support by reading systems is usually bad, it is that LS support by underlying rendering engines is suboptimal.

Well, indeed a typical reading system (RS) makes use of a browser engine (webview), but the RS effectively also runs a "web server", even if an IP address / HTTP(S) protocol is not explicitly used. Internally, the RS controls caching, browsing sessions, resource cleanup, etc. Crucially ; as mentioned before ; the RS is also responsible for serving web documents using an arbitrary, possibly temporary/transient (i.e. not persistent) origin. Or multiple origins, in supporting implementations.

Historically, this problem space has arguably not been addressed sufficiently (not just in terms of the EPUB spec. itself not being clear or thorough enough), resulting in significant disparities across RS solutions. Although, this has not been a major concern for the vast majority of "ebook"-like publications, which typically do not have mission-critical Javascript needs.

Perhaps the EPUB format specification cannot / should not have conformance requirements for such things. Perhaps it is too late anyway: RS vendors / implementors are only going to rewrite / upgrade their software if it makes sense financially, if there is a huge demand for an alignment with the web security model, etc. driven by the needs of consumers / content producers.

So, perhaps these kinds of issues are best articulated in "production practices / guidelines" (for content authors), and tested / validated (for implementors) through RS evaluation methods such as epub-test.org. We know that content creators struggle to find reliable, up-to-date "can-I-use?" information about web features like localStorage in EPUB (the default assumption is "probably not"). Consequently, they either fallback to the lowest common denominator (e.g. no scripting), or they resort to targeting a tiny selection of vendor-bound RS that support the rich functionality they need in their products.

In the web community there is a fairly good degree of awareness regarding graceful degradation / fallbacks vs. progressive enhancements (etc.), because of accessibility requirements, the necessity to adapt content to desktop / mobile (etc.). In the e-book space / digital publishing, there are competent EPUB "developers" too, but they do not have the luxury of a consistent and reliable runtime: i.e. the web platform (servers + clients) which follows a common set of open standards and conventions.

Would it be more effective to have a "living document" outside of the specification process, that would somehow articulate the technical gap between "the web" and a typical RS runtime? (baring in mind that there are many variants of this thing we call "RS"). Or perhaps categorized additions to epub-test.org in order to specifically check for web / origin-related features? (e.g. localStorage, indexedDB, etc.)

@RachelComerford
Copy link
Contributor

This was an interesting conversation but is out of scope for the EPUB CG to resolve. If it's still of interest, it could be taken to the newly formed Publishing CG for incubation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug question triage applied to an issue where we need to figure out what the problem is, and who can help with a solutio
Projects
None yet
Development

No branches or pull requests

7 participants