372 points · by bubblehack3r · 3y ago · 207 comments
There's one problem though, this new API is for the web, so the nature of this storage is temporary - obviously the user must be able to clear it when clearing site data and this what makes it currently an unviable solution for a persistent extensions data storage. https://bugs.chromium.org/p/chromium/issues/detail?id=138321...
This is already possible with the file system access API. Clearing site data has no impact on these files. But you do have to re-grant permission every time you reload the page.
https://developer.mozilla.org/en-US/docs/Web/API/File_System...
From https://news.ycombinator.com/item?id=32953286 https://westurner.github.io/hnlog/#story-32950199 :
> - [ ] UBY: Browsers: Vary the {color, size, fill} of the tab tabs according to their relative resource utilization
And then that tabs are (sandboxed) subprocesses running as the same user though.
Containers may have unique SELinux MCS labels, and browser tab processes probably should too.
containers/container-selinux: https://github.com/containers/container-selinux
https://github.com/kai5263499/awesome-container-security/iss...
> - [ ] ENH,SEC: Browsers: specify per-tab/per-domain resource quotas: CPU, RAM, Disk, [GPU, TPU, QPU] (Linux: cgroups,)
Like Flash
What are you suggesting here? That extensions should have some special storage, that can't be (easily) deleted? Noooooooo thank you. Firefox has "forget about this site" and similar tools, which I use near daily. Don't fuck with my ability to do housekeeping.
asking for permission to a longer storage.local exemption for the user? noooo let's not even think about giving user control of things. let's the European union pass post-fact legislation after file system access is abused by adnetworks. then they get the blame of being annoying, not the browser vendor who sell ads.
let's stop being naive. there are a million ways to fix that bug with better UX and respect for user control, but this is a scape goat to have that feature.
EDIT: I saw from your other comments on this post that Firefox has implemented at least the origin private file system part in nightly builds; that's useful info that I was looking for.
However the sqlite demo page says OPFS is unavailable for me in Safari https://sqlite-wasm-opfs.glitch.me/ ...unsure whether it only supports a subset of the APIs that the official sqlite build uses?
What happens is Chrome releases a Chrome-only non-standard (at a rate of 400 APIs per year). It cobbles together a barely legible spec [1], and then uses its multiple propaganda channels like web.dev to present them as actual completed standards that other browsers are just slow to implement.
Even if other browsers only learn about this a few days before Chrome ships, or have multiple objections.
[1] Example, File System API https://wicg.github.io/file-system-access/ "not a W3C Standard nor is it on the W3C Standards Track."
https://developer.mozilla.org/en-US/docs/Web/API/FileSystemF...
Discussion from back when the SQLite project announced this last year: https://news.ycombinator.com/item?id=33374402
There isn't an "official" NPM package or ES6 model yet, but I believe they are working on it. It's also very much designed for the browser currently, but again I believe they are intending to support server WASM environments too eventually.
(The sqlite team's JS/WASM Guy here...)
An ES6 module build was added shortly after the 3.40 release.
NPM/node.js are nowhere on our radar. Our build is structured such that people who want to plug it in the resulting JS file to whatever their favorite toolchain is are welcomed to do so, but we have neither the ambition nor the bandwidth to support every build/bundling platform out there, especially ones none of us otherwise use.
> It's also very much designed for the browser currently, but again I believe they are intending to support server WASM environments too eventually.
The JS code is targeted solely at browsers and there are no plans on changing that in the foreseeable future.
The WASM build itself, we are working to provide server-side support for. We have a branch which builds under wasi-sdk, but we cannot create a JS binding for that build until/unless we find some substitute for Emscripten's transparent translation of POSIX I/O APIs.
For what it's worth (though it seems like the decisions is done), there's no need to support every build/bundling platform - the NPM registry is rather 'tooling agnostic' and publishing there would make it available to a lot more people with a lot less effort.
The sqlite project is populated entirely by C coders (my primary language), none of whom have either experience with, nor a need for, NPM, so we're not eager to claim any level of support for it. Trying to support a tool one neither uses nor understands is like trying to wave away darkness with one's hand.
> ... with a lot less effort.
A lot less effort on their own parts and a lot more on ours ;).
Future NPM support has not been outright ruled out, but it is admittedly nowhere even close to currently being on our radar.
The JavaScript world is culturally so dependent on npm now that adoption of SQLite in that world would massively increase given the availability of a good "official" package.
And without an official one I imagine there will quickly emerge dozens of unofficial ones, many of which will end up poorly maintained in the future.
https://developer.mozilla.org/en-US/docs/Web/API/File_System...
What's next, mmap() for javascript?
For example, it should be possible to build websites for downloading YouTube videos that does not use server side code execution or bandwidth. These were popular at some point but disappeared after Java applets stopped being supported by most browsers.
WebSockets are already a problem because many web devs don't know that other origins can connect to them and potentially fetch data they're not supposed to (even ignoring the fact you can construct these without a browser), unleashing raw sockets to the web platform would be hell.
WebRTC and WebSockets provide more than enough already. If you need even more, your browser just isn't the place for this type of code IMO.
Devs who don't need the high performance but want wider compatibility will probably continue to use the "unofficial" versions.
Also, last I checked, you could definitely load web assembly in a page that has a File:/// origin.
My use case is an entirely offline webapp that I'm building as a side project, partly just to see what is possible. I've tried indexeddb, pouchdb, absurd-sql, and various others, and have ended up back at localstorage, which is plain but low on edge cases.
The other big pain point I am hacking around is cross device sync; I'm leaning towards simple chrome and firefox extensions that'll slurp data into your profile in order to sync, which'll work for cross computer sync for my needs. However, chrome on android doesn't support extensions, and there's no other good way that I've found to sync between a user's chrome profile and android, so that is still a hole in the story. Some kind of webrtc based thing is imaginable, but it's clunky.
[1] https://jlongster.com/future-sql-web
[2] https://developer.chrome.com/docs/web-platform/storage-found...
IMO, the Chrome team is being a bit deceptive with their phrasing on synchronous file handles. The problem is that the entire API is wrapped up in an asynchronous ceremony. `createSyncAccessHandle` is only available in a worker context. So you can only communicate with the worker using an asynchronous postMesssage event dispatcher. And even when you’re in the worker, file handles can only be accessed through methods that return a promise.
I understand the need for such boundaries when working with a single threaded language, but limiting the synchronous APIs to just workers seems like one too many layers of indirection. I recently attempted to write a POSIX-style BusyBox library and this sort of thing was a total show stopper.
An unresponsive script is slowing this window down - kill process ot wait?
I would be delighted if handlers were more akin to byte arrays that could be written and read synchronously, albeit with an asynchronous function to persist changes to the disk.
The File System Access API does give the webpage the ability access files on the users file system, with permission. However not at the block level, that is only enabled for the OPFS. In order to provide ACID compliance SQLite needs to be able to hold a lock to a file and write at the block level, which is only possible within the OPFS sandbox.
It's frustrating that the web community first build File System Access, but made a number of design choices compromising performance. Then AccessHandles/whatwg-fs, which unlocks performance, but severely limits it's usability to things users can't really interact with. And only release a sync implementation.
I love the web platform, but this feels so unfortunate.
Example of syncing your app across tabs with SQLite here: https://vlcn.io/docs/guide-solving-tabs
It's mostly works with OPFS but with a few edge cases. They are working with the browser vendors on improving this in OPFS.
Alternatively run it in a SharedWorker (https://developer.mozilla.org/en-US/docs/Web/API/SharedWorke...), which seems to have made a comeback after being dropped for security concerns. Or do some sort of leader election with browser tabs and use a BroadcastChannel.
Given the use of SharedArrayBuffers and that SharedArrayBuffers can't be used in a shared worker (funny), SQLite WASM doesn't work in shared workers.
If getSyncAccessHandle was made synchronous then maybe everything would just work. It'd also improve SQLite WASM perf by 30% according to their measurements [1]
[1] https://sqlite.org/forum/forumpost/af64f73911e5410cf9a640c9e...
Something relevant is absurd-sql, but unfortunately that's not even close to production ready :/
683KB plus 300KB is less than many web pages these days.
Just because everything is already shit doesn't mean it's a good idea to pile more on top.
Hm.. 1 MB is good (just zero app code) ..okay.
On use cases, you can give your web app offline support by locally caching data in an SQL database and have it be fully queryable.
Say you are building an app like Notion, they already have "offline mode" for the mobile and desktop apps, this would enable you to build that for the web app.
This is very much one of the final jigsaw pieces needed to make PWAs (progressive web apps) competitive for the majority of use cases. We just need Apple to catch up and fill in a few other blanks too.
A design pattern that is beginning to emerge is "offline/local first". You design your app to fundamentally work offline, using things such as this, and the server component only works to synchronise clients. It's a bit like the design move to "mobile first" that happed 10 years ago, but going to another level.
It reminds me of an old concept, that has a catchy name I can't recall, positing an endless cycle in systems evolution where local peripherals grow processing capability until someone notices and (re)centralizes it, only for the local processing capability to quietly begin growing again, and so on.
If you want relational tables, joins, aggregations etc, you want something like this (or the original Web SQL that was deprecated).
There is definitely a use case for it.
SQLite, which has a SQL database engine, is, by definition, a relational database. IndexedDB is a non-relational, or noSQL, database. One can't be basically the same as the other :-)
IndexedDB seems like a whole bag of gotchas. SQLite + simpler browser provided file backing seems interesting to me.
Think Redis vs PostgreSQL.
Apple wants to handicap web apps to encourage people to build for iOS.
I think Safari has also made progress over the last couple of years, and there is indication of them being more receptive to PWAs. I'm going to cheerlead for that.
It's also worth noting that the EU and UK competition authorities are looking at forcing Apple to make changes to some of their rules around web browsers on iOS. They have a big stick, I don't, hence my nicer words.
You also have mixed (“just right”) consistency systems and techniques to introduce and optimise the use of runtime coordination where necessary.
For example see https://electric-sql.com/docs/reference/consistency
> In our blog post Deprecating and removing Web SQL, we promised a replacement for Web SQL based on SQLite. The SQLite Wasm library with the Origin Private File System persistence backend is our fulfillment of this promise.
I'd venture to guess the best answer is "whatever the hell people used Web SQL for." Doesn't really answer the question, but alas.
Or need to collaborate on the data (i.e. a company with empoyees)
Or have regulations/controls on where data lives 'at rest'
This is a really powerful capability. You could build the equivalent of full desktop applications - things like Word, Excel, Access, Evernote, task trackers, Blender... all without any server side storage mechanism at all.
And it's an app that runs in a very robust sandbox, so much less risky than installing software.
For me, it is the last missing piece to make web apps as comfortable as native apps.
I use a lot of web apps I fine-tuned exactly to my liking. I do all my writing in this web app for example: https://www.gibney.org/writer - I hit F11 and boom! I am in distraction free writing heaven :)
If Firefox would support the File System Access API, it would be much more comfortable to load and save my writings.
File System Access considered harmful, will not be implemented: https://mozilla.github.io/standards-positions/
Note: in true Google fashion Chrome team implemented and released at least three different APIs all having something to do with files.
Status of File System Access? "not a W3C Standard nor is it on the W3C Standards Track." https://wicg.github.io/file-system-access/ Shipped in Chrome, of course.
https://mozilla.github.io/standards-positions/ is positive on it
and implementation is well underway: https://bugzilla.mozilla.org/show_bug.cgi?id=1748667
To hopefully add a bit of clarity: indeed, that page has OPFS flagged as positive under the label "File System." Further down the page is a "File System Access" entry which is flagged negative.
I didn't want to dig through all of them on mobile when I was responding.
Both Safari and Mozilla are open (and implement/have implemented) to Origin Private File System. Because it gives web sites an access to a file system without a chance of escaping and damaging user data. Can't remember which spec introduced it, and it doesn't really matter at this point.
For the more general part of File System Access Mozilla's and Safari's positions are: nope. https://github.com/mozilla/standards-positions/issues/154
There was also Storage Foundation API but it was thankfully never shipped (it was like a third way of handling files or something),and also received negative responses: https://chromestatus.com/feature/5670244905385984
They seem quite positive to parts of the spec. Don't know if that's the parts relevant here or not.
Coup d'état: French, "stroke (coup) over/of the State (état)".
https://en.wikipedia.org/wiki/Coup_d%27%C3%A9tat
/pedantry
Hell, even the $LARGE_CORPORATION I work at has all its developer tooling (including documentation, custom extensions, etc.) on Chrome. I've reported countless Firefox-specific issues, often due to missing API support, because no one internally tests on anything other than Chrome. You have to meet your users where they are.
It's not broken because they are fussy on standards.
it's broken because their marketshare dropped so low companies that make money on developing web stuff are often not contractually obliged to even support it. Few of our clients have contracts where we're obliged to support any browser above 5% market share and FF is already below even that!
Somehow "everything that Chrome ships" is core functionality now
> broken or slow on Firefox but work fine on Chrome.
Somehow you blame Firefox for this. Even though "only works in IE" isn't even ancient history
They might when their files get exfiltrated or encrypted. The file system access API UX is far too easily abused to misleading users into granting access to things they didn’t intend.
Nothing on my screen except two areas: The writing area and the margin around it.
I want to be able to easily resize the writing area the way I can resize the textarea.
I want to be able to easily change the font size via ctrl+ and ctrl-.
what's wrong with the so called "zen mode" that has been available on every moderately popular editor for decades?
See also JRR Martin still using WordStar 4.0 for DOS
https://cdn.eteknix.com/wp-content/uploads/2014/05/37719_2_g...
The result today: A single SQL implementation with no standard (beyond SQLite) and therefore no easy way for anyone to create a compatible alternate implementation.
SQLite not right for a project? DuckDB has a WASM build too.
Heck, so does PostgreSQL now! https://www.crunchydata.com/blog/crazy-idea-to-postgres-in-t...
A SQL standard never precluded a separate filesystem access standard and implementing databases on top of it.
But rejecting the Web SQL standard means that every SQL-using webapp will be tied to its own database - replicating the SQL incompatibility mess when we had a chance to finally enforce a little standardization based on current SQL standards - and require depending on WASM when WASM might have not been necessary.
Web SQL was dropped for precisely this reason:
> The specification reached an impasse: all interested implementors have used the same SQL backend (Sqlite), but we need multiple independent implementations to proceed along a standardisation path.
http://www.w3.org/TR/webdatabase/
Without a magic want to force multiple implementations, all of those web apps would have been tied to a single implementation anyway _and_ it would have been harder to update it so even after something was fixed you'd need to wait until the oldest browsers were updated before you could rely on it. That is possible, of course, but it's a recipe for problems with something like a SQL database.
For a portable application file format, you'd want to pick a SQL implementation (probably SQLite), decide on a schema, and probably wrap it in a library, but once you do that it could be used in multiple apps.
Think about the DOM APIs: jQuery was super popular in the 2000s. Say all of the browsers had decided to bundle it like WebSQL bundled SQLite. Would you be happy using a copy of jQuery 1.7 until all of Apple, Microsoft, Mozilla, and Google shipped 1.8 and all of your users upgrade or would you prefer to update your site to reference the version with the features you want to use? (or switch to a different framework in 5 years)
Browser developers always have to balance the tension of adding something new with the knowledge that they're going to need to support it for long periods of time. WASM is a good compromise position because it reduces performance as the reason why something should live in the browser engine rather than being shipped as an app resource.
This ignores the fact that SQL already has standards with multiple implementations and is very well established. It's not a recent-ish JS library. It's not new tech. It's an almost 50 year old tech predating the internet.
Standardizing on a basic standard subset using the current SQL standards would have been enough for nearly all apps, and would have allowed alternate implementations without any real SQLite path dependency since SQL already has standards and well trotted paths for implementing them (at least a basic subset).
[EDIT: I don't wish to spam the comments. If you wish to reply to this, please use the other thread you also replied to? I should have done it myself, sorry about that.]
I'd polyfill 1.8 until enough browsers support it like is done for every other browser api
I miss when the web was essentially a document viewer.
said unironically on a web app
Yes, iOS is a black box hellscape. Android less so.
And webapps are the epitome of walled garden. The programs literally require a host server to function. All you get is front end.
I take your point on accessibility. And that is the main draw for a lot of people and devs I imagine: I can access the thing I like from nearly anywhere and anything!
And I can respect that. And it has its uses.
My complaint is that this won’t be a choice eventually for most things. It’ll be “use this web version or nothing”.
You are already seeing negative aspects of a lot of this even on desktop programs. Like look at Steam. It’s convenient. People have flocked to it.
If you are offline you lose access to everything. Unless a cached credential is still working.
If you lose access to your account, you’ve lost all your games. Blah blah.
I’ve had personal experiences with this. It blows.
It won’t stop it. People are fine till it happens to them. But then they forget it five seconds later and right back at it.
*aaS is irritating as fuck
So you end up with piss poor “web apps” that half the time require a specific browser to work remotely well and have kludged “offline” modes that break every other day.
Do not want. I know I’m probably in the minority but it’s damned irritating. The UX on most is atrocious and you have to deal with a complete hodgepodge of interface styles and ideas and designs and also hope your browser keeps running smoothly after trying to use multiple more advanced webapps simultaneously.
Oh, but all these advancements on wasm and all will continue improving performance and fixing problems!!!
… you mean stuff that was already solved with native programs? “But you can work on your stuff from anywhere with just an account!”
Oh, like a native app’s data synchronization?
But but…
It would be nice if we had both and both were equals. But that isn’t the case. It won’t be the case. And most companies see this as a wonderful way to vendor lock in even more than before and implement more and more IAP and subscription crap.
No thanks.