255 points · by feross · 5y ago · 231 comments
The vast majority of the time we spend diagnosing and working around browser bugs is devoted to Safari. As an iPhone/Mac user and lover of all things Web, I really, really want Apple to get their act together with Safari. We sadly keep running into issues like this.
Here are a few more recent examples:
https://twitter.com/feross/status/1386835131780931587
I've been reporting bugs to WK for years and none have been solved.
Did you know you can't set the dimensions of an iframe in iOS?
But yeah that's not a good idea, really.
We use WebTorrent behind-the-scenes, so we need random access to the end-to-end encrypted version of the files to satisfy requests from peers. So we try to put the files on disk using Filesystem Access API or IndexedDB, falling back to in-memory if there's not enough storage.
How can they get away with this? That's like 10 times worse than what Microsoft was doing with ie in 00s and they got fined over it so many times.
A few months ago, Chrome broke all WebView-based apps. Fortunately, they fixed it within a day. The IndexedDb bug was fixed after 6 weeks.
I reported a bug in 2016 and it's still open.
Another bug I reported in early 2020 doesn't even have an answer from the team.
I suppose if they feel like they are big enough to bully websites into just working around long standing bugs, that may be intentional as well.
Well done on your viral tweet that got some personal attention from Apple. Usually when I spend days narrowing down Safari bugs to minimal reproducible test cases, finding workarounds, and writing everything up in detail on the webkit bug tracker the only public response from Apple is the radar importer bot, and then everything goes quiet.
Btw, your original twitter thread implies you were the author of the bug report. Minor annoyance, but I did spend quite a while writing that up :)
I find the Chromium team much more willing to engage directly and constructively on their bug trackers at least.
Also: Didn’t mean to imply I wrote that report. We were about to open a duplicate issue before noticing yours. Thanks!
We've definitely had the same experience of Safari introducing way more issues with new releases than Chrome, and the fact it's part of the iOS image seems to make quick patching just never really an option.
I just wish they'd engage a bit more directly on the bug tracker - find it hard to believe that twitter is a more effective means to get attention on bugs.
Then I loaded up my 2005-vintage personal wiki which has been working fine for 15 years on all the browsers I use (Chrome and Firefox).
And it has a tabindex bug in Safari!
https://stackoverflow.com/questions/1848390/safari-ignoring-...
I'm not sure but isn't this a violation of the spec? Or is there some newer thing for tabindex? Either way I switched back to Firefox and Chrome.
I kinda like the idea of a browser that doesn't implement all the Chrome crap. But I also feel like it should interpret 15 year old pages correctly!
That's been my experience as well.
When reporting a bug to Chromium you get an answer in hours.
When reporting a bug to WebKit it's mostly crickets.
Then you can go to their code comparison page[2] and wonder what the hell they were on about.
> IndexedDB generally simplifies the programming model for interacting with databases, and allows for a wide number of use cases.
They can't be looking at the same code - what have they improved other than to use more Javascript?
The sooner it dies the sooner an alternative can appear… SQLite3, anyone?
[1] https://hacks.mozilla.org/2010/06/beyond-html5-database-apis...
[2] https://hacks.mozilla.org/2010/06/comparing-indexeddb-and-we...
But yeah the assertion that indexeddb is any good is hardly convincing.
Nowadays you can use sqlite3 through wasm if you want, though I don’t know how you’d handle the persistence layer.
There was a post on here in the last month or 2, atleast for reading, that used http range headers for reading the db pages.
as for writing, you're gonna hate this, but a vfs impl. for SQLite using indexedDB as the backing store is your best option (Safari stupidity not withstanding)
That was for a local SQLite doing remote loads/stores, I was thinking more local loads/stores, what websql would have provided.
> as for writing, you're gonna hate this, but a vfs impl. for SQLite using indexedDB as the backing store is your best option (Safari stupidity not withstanding)
Yeah that’s what I was figuring out but then it feels like the SQLite bits are significantly less useful, and I’m not sure how good indexeddb is at being a block device.
P.S. SQLite doesn't have a spec. Once you start really using it and bumping into version differences, extensions, etc., you'll really feel the pain caused by this.
Like, does anybody here really think their actual complaints are about some minutae about wording in a spec about "mandates" or whatever? Their rejection is quite clearly against the spirit of the design, and again because because they don't think multiple browsers each independently reproducing a whole SQL stack with equivalent semantics is viable. It's not about technical nits or wordsmithing, little coder-logic-tricks aren't going to work.
If you write the spec to not be compatible with SQLite then every browser has to implement its own SQL layer which is a huge effort and frankly a waste because SQL is kinda shit.
I've built a web-app heavily relying on IDB, and storage operations are generally much faster than the native app on Android using Realm DB. IDB is backed by leveldb on Chrome, which in benchmarks is consistently faster than sqlite. I'm happy we didn't end up with websql for one.
My biggest gripes are: - The incompatibility with ES6 promises early on (but IE11 still suffers from) was unfortunate. - The auto-commit behaviour of transactions is somewhat annoying and usually has an impact on your architecture if you want to write multiple things in one transaction, but it would have been easy to have memory leaks and deadlocks without this. - Quota management and eviction is wildly inconsistent between browsers, even on Chrome you get evicted when storage gets critically low. - Safari has a history of pretty bad IDB bugs.
SQLite has a _lot_ of great features. Many of them only introduced in recent versions, and many of them are optional extensions enabled at compile-time. There is no feasible way to standardize this to get the same functionality across all browsers.
IndexedDB may not be great to work with (at least not without helper libraries), but at least the API surface is small, and much easier to ensure you get the same behaviour in all browsers.
I'd rather advocate for a proper block-level filesystem API that could be used as backing storage for a WASM SQLite library.
No it was never the right choice and it didn't need to become standardized at first place. Writing a query builder is an easy task, implementing a RDBMS on top of indexedDB, ironically implemented on top of SQlite in Firefoxis a much harder tasks.
IndexedDB is absolutely atrocious API wise, and largely useless to query structured data.
This is happening at https://web.dev/storage-foundation/ fwiw
As for SQLite, as lovely as that'd be, NOONE wanted to spend R&D on building a "SQLite clone" for the web SQL spec, and I can't blame them, how the hell can you justify that effort when SQLite exists and is crazy well tested and proven?
Let's say you need to search for age > 19 and less than 30 for a person with the name of Jane or John.
That's nothing complicated, but indexedDB CANNOT DO THIS. I suppose you could do it by iterating every single data entry, but that's a performance no-go for even relatively trivial databases.
Likewise, joins on different stores simply don't exist. Iterating every entry in this case is O(N^2).
Might as well just store a giant JSON blob instead.
Quite literally, my only use of indexedDB these days is storing a SQLite file and whatever interactions PouchDB has (I think they are mostly limited to linking an ID with a JSON blob). Adding insult to injury, despite being a simple key/val store, it's SLOWER than SQLite too.
I’m pretty sure you can do that. You can create an IDBIndex that covers multiple fields, then narrow down the search using key ranges. Though, even with key ranges, narrowing down results based on multiple independent ranges requires some manual work:
https://gist.github.com/inexorabletash/704e9688f99ac12dd336
But at least algorithmically speaking, that’s roughly the same thing that a database natively supporting such queries would be doing, so the big-O performance should be the same. Though I wouldn’t be surprised at all if it’s slower in practice.
All doable, but quite a lot of work. Once you start looking at the details, every single database has its own SQL dialect and they're not all that compatible except for the simplest queries.
Which is implemented on top of Sqlite in many browsers, what a joke.
It's easier to implement IndexedDB on top of a SQL database than the other way around, so people claiming IndexedDB is "lower level" are ignorant.
There's even recent work to add even higher performance APIs into the Filesystem Access API and the reception from Firefox and Safari has been positive. Really early work is happening here: https://github.com/WICG/storage-foundation-api-explainer and the latest proposal is here: https://docs.google.com/document/d/121OZpRk7bKSF7qU3kQLqAEUV...
Positive as in: "FileSystem Access is a significant security risk and we're not going to implement this"? https://www.chromestatus.com/feature/6284708426022912
Positive as in "No, we don't want fifteen different file access apis, and we don't think Storage Foundation API is going anywhere"? https://www.chromestatus.com/feature/5670244905385984
And even though this is a draft created and authored exclusively by Googlers, even other Googlers are confused: https://github.com/WICG/storage-foundation-api-explainer/iss...
Right now the Mozilla position is 'defer', not 'harmful'. See https://mozilla.github.io/standards-positions/#native-file-s....
That means yes, they're not implemented today, but they're open to doing so later on, given further specification development and real-world investigation to confirm that the security implications are minimal.
> No, we don't want fifteen different file access apis
Looks like there is some ongoing work to synchronize these APIs to resolve that concern: https://docs.google.com/document/d/121OZpRk7bKSF7qU3kQLqAEUV...
---
I 100% agree Google is too aggressive at publishing and releasing these features without widespread consensus from other vendors. If they were doing so with just origin trials or behind a flag that would seem reasonable to me, but the widespread release is surely going to cause problems for these specs, when they must be aware that further development and changes is going to be required. I'm not clear how they intend to mature these standards without breaking the early adopters.
I don't agree they're not desirable features though. Honestly I desperately wish Safari & Firefox would engage more and drive these specs themselves! It would be better to get their voices in the decisions that'll define these specs, rather than letting Google define the future of the web all by themselves.
There's clearly demand for these features (read the comments of https://github.com/mozilla/standards-positions/issues/154 for some examples). It would be better to have privacy and security baked in with input from a broad group of actors (I think we can all agree that Firefox is going to be a more useful voice than Google in that sense). It's not helpful to let Google run off and write every standard themselves, with other browsers watching from the sidelines until it's sufficiently done (and unchangeable) and then having to either adopt the existing standard as-is by necessity or to refuse to support many real world web applications (for as long as that's tenable).
Make no mistake - Chromium has the market share to be a workable target, and these APIs work well for developers and are genuinely useful. They will be used. There will be (in some areas there already is) a whole world of web apps using these APIs which only work in Chromium by necessity, no matter how much they'd like to support other browsers. As those get adopted by users, that's only going to drive the web further towards Chromium, until other browsers have to die or adopt the (entirely Google-written) standards themselves too to support the next generation of webapps.
This is happening on desktop in some areas already. In IDEs, for example - if you buy any IoT based on Espruino, the primary dev tool only works in Chrome due to WebUSB/WebBluetooth (https://www.espruino.com/Web+IDE), while tools like Godot Editor are already talking about Chrome-only save/load support using these filesystem APIs (https://godotengine.org/article/godot-editor-running-web-bro...), and I'd be extremely surprised if GitHub Codespaces and other tools aren't looking at doing the same. These are popular tools - many users want to use them, and they will have to switch to a Chromium-based browser to do so.
Mobile is somewhat protected due to Safari being the only option on iPhone, but I wouldn't be surprised if the ongoing antitrust cases force them to open that up to make PWAs look like a plausible app store competitor, and the exact same thing happens there.
WebExtensions is a case study of the same effect in the past. Chromium has so much weight that once they fully design and adopt an API and build an ecosystem around it, other browsers have to follow or get cut off. If Firefox & Safari had engaged with WebExtensions much earlier, they could have been driving it themselves and building consensus. Instead, they've had to copy every Google API while just tweaking around the edges.
One exception, interestingly: Brave is doing some intriguing work on driving decentralization APIs for the web (native Web3, native IPFS). It's early days, but I'm hopeful that this might have the same effect in the opposite direction for those features!
Well, I could not help myself.
>> While versions of Safari, Chrome, and Opera support a technology called Web SQL Database, which uses SQL statements as string arguments passed to a JavaScript API, we think developer aesthetics are an important consideration, and that this is a particularly inelegant solution for client-side web applications.
>> We .. also spoke with Microsoft, who agree with us that IndexedDB is a good option for the web
OMG!! MS thought not doing what Apple and Google wanted was a good option. Earth shattering.
As for the code examples, both sets look horrible, but this and "_developer aesthetics_" don't go together. This is how they think their `JOIN` is "better" than SQL `JOIN`.
candyEaters = [];
function displayCandyEaters(event) {
var display = document.getElementById("purchaseList");
for (var i in candyEaters) {
display.textContent += ", " + candyEaters[i].name + "bought " +
candyEaters[i].count + "pieces";
}
};
var request = window.indexedDB.open("CandyDB",
"My candy store database");
request.onsuccess = function(event) {
var db = event.result;
var transaction = db.transaction(["kids", "candySales"]);
transaction.oncomplete = displayCandyEaters;
var kidCursor;
var saleCursor;
var salesLoaded = false;
var count;
var kidsStore = transaction.objectStore("kids");
kidsStore.openCursor().onsuccess = function(event) {
kidCursor = event.result;
count = 0;
attemptWalk();
}
var salesStore = transaction.objectStore("candySales");
var kidIndex = salesStore.index("kidId");
kidIndex.openObjectCursor().onsuccess = function(event) {
saleCursor = event.result;
salesLoaded = true;
attemptWalk();
}
function attemptWalk() {
if (!kidCursor || !salesLoaded)
return;
if (saleCursor && kidCursor.value.id == saleCursor.kidId) {
count++;
saleCursor.continue();
}
else {
candyEaters.push({ name: kidCursor.value.name, count: count });
kidCursor.continue();
}
}
}It's built on top of Sqlite in Firefox, it isn't "low level". Give me Sqlite directly instead of that horrible stuff.
Just because someone used this technique for some technical reason does not change the fact that indexedDb is an API, is not built on top of SQLite, and is lower level, because you could build SQL databases on top of it.
It made me really angry at Mozilla. WebSQL was so invaluable to me.
If you need to store more data, why not do it on the server? What are the use cases for having a full-blown relational db client-side?
So is PHP according the infallible SV pundits.
> it's also unnecessary, as you can store a significant amount of data in localStorage and the API is extremely simple to use.
Either you've never actually tried to store significant amounts of data in localstorage, or you're from the era of "640k is enough".
To say nothing of having no indexing functionality with localstorage, or paying the 33% base64 tax to put anything remotely binary into it.
> If you need to store more data, why not do it on the server?
"Because there is always, ALWAYS a high speed, low latency 100% uptime connection" /s
In answer to your last question, we have developed two PWAs reliant on local databases.
1. Was a product catalogue for use in stores, letting users filter down to select a particular appliance. two key requirements were that not all stores had great wifi coverage, and they wanted to easily update the catalogue (which meant no app recompilation).
So, Dexie atop IndexedDB, with indexes on the various facets for searching, and a simple settings page to run a sync. Dexie stored the product data, and a "immutable" SW cache strategy was used to keep the images available.
2. A detailed report generation app, Key requirement, must work with patchy connectivity as reports need to be taken in the field with unknown signal availability. Reports are locally stored and synced periodically (connection permitting). Again, Dexie atop IndexedDB, this time the images stored in the db as blobs prior to upload.
Sarcasm is unnecessary but I'll admit that so is the word "cancer".
Your first example is a great one, although the catalog would have to be really huge to not fit in memory; and since it is static (the users don't update it) it can be upgraded by downloading a json file regularly?
The second example doesn't explain why you would need a relational db.
Anyway my point is not to second guess applications that run well, and even less to argue with people who have already mastered IndexedDB -- good for them!
My point is for people on the fence to take a good, hard look at what's possible with localStorage and make sure that before they embark on the IndexedDB voyage, they are absolutely, positively certain that they have no other choice.
I recently came across an app that stores a couple of user preferences on IndexedDB; the funny part is that the comments complain for paragraphs about its quirks and general unpleasantness. The time spent complaining in the source would have been better spent switching to localStorage.
Irrelevant, nobody is forced to use PHP as a server side technology. On the other hand, browser API are limited with what browser vendors implement, so there is no choice.
Easier / cheaper to host only static files.
I must admit there's a bit of schadenfreude in knowing that Firefox is almost irrelevant now, while SQLite keeps going from strength to strength.
> I have identified the regression point and assigned the bug to somebody. Thank you for the bug report. We will try and get this fixed ASAP.
I just added a section on Safari's storage related bugs, of which there are many. Amazingly, IndexedDB broke in Safari 14.1.1 after localStorage broke in Safari 14.1, released a month earlier.
Bugs.
This is something that should have been caught by automated tests.
There’s basically no automated test suite even for CSS 2.1 that all vendors can rely on that matches behavior specified by the standards.
Luckily standards like that are so mature that it’s not needed as badly, but it definitely keeps incumbents safe from competition.
But for others who don't know:
https://web-platform-tests.org/
https://github.com/web-platform-tests/wpt/tree/master/css/CS...
They’re also tests that don’t actually point anything out.
Take the CSS2 tests for example, https://wpt.live/css/CSS2/, I can’t do basically anything with these. They don’t tell me whether or not a particular part of the implementation has failed. They’re all basically arbitrary tests that sort of cover the appropriate properties, sometimes, maybe.
The biggest glaring issue is that the test runners run in the browser. Well, if my user agent doesn’t have JavaScript… I can’t “run” the tests.
Further, there are some parts of the standard that can’t be automated simply because it’s up to user agents to decide how the final rasterization turns out. You can’t just compare rasterization output or even reliably look for element heights for verification based on the differences between font rasterization.
This is also why a part of the suite requires manual verification.
What I really need as an implementor is the ability to point my software at some .html files, get some failures, add more implementation, get less failures, and repeat. With, of course, the caveat being that you can only really do this for what is well-defined in the standards.
But you can’t do that easily with the wpts.
Because a cursory glance at Chromium src tells me they do have automated tests for IndexedDB:
https://source.chromium.org/chromium/chromium/src/+/main:con...
However, if you do stumble on some tests for basic things like the box model, I'd love to know where they are! Tests like those would allow other vendors to know whether or not they're adhering to specification, programmatically.
Earlier standards are very descriptive, rather than telling you how to implement the actual web technologies. That's left as an exercise for the reader. Seriously!
https://github.com/WebKit/WebKit/tree/main/LayoutTests/stora...
Testing browsers is a daunting task. A modern browser is 10-15 million lines of code with literally thousands of exposed APIs [2]
[1] https://www.pcgamer.com/a-google-chrome-update-breaks-the-au...
My favorite one was websites added to the home screen on an iPad would have the clock displayed above the websites if you rotate the iPad after opening a website. It wasn't fixed for years and it may still be there.
As with every race condition (cross process, too, so tools like TSAN don't help), testing for the absence of race conditions is hard.
Apple made it easy for themselves to have zero competition in browser engines.
im tempted to just x out the safari logo on mine since it likely cant be tested
It has the fastest UI, uses the least memory and uses a fraction of the battery life compared to all other browsers.
And from what we've seen in Monterey they are continuing to invest heavily in improving it.
My answer would be that the landscape of the web, advertising and software ecosystems are drastically different today.
If you're on about features? Ask Apple why they shy away from them on the web? Hard to justify imposing the 30% cut on a website/app.
Hell, Apple could have lead the charge on "web app privacy", implement the specs they've "missed" for web (notifications, background sync etc), and GATE THEM TO PWA/installed web apps, no more news sites asking to notify you when you just go to an article.
Heck, add keys to the web app manifest so as a developer I need an Apple Dev account and the holy $99 entry fee as well as my personal info in Apple's hands to make sites that do these things, so they have recourse to nuke the bad actors.
Being able to deploy a PWA that avoided the 30% cut Apple takes for all digital content would suit many users very, very well.
Another dev and I are creating a few 3D web projects, one of which is a decentralized web gaming platform for Unreal Engine 4 indie developers to ship their projects directly to their audience without needing to go through walled gardens like the App Store.
Will DM you on Twitter as well!
> * File System Access API (https://web.dev/file-system-access)
You realise, right, that Firefox is also not keen on implementing this api? [1] And many others [2]
Yeah, Mozilla used to be the beacon of Web standards, what happened to them? They always find some silly justification to refuse implementing a spec, like WebSQL, half of the Web Component spec, and many many other things, what gives?
Chrome might be "bad" cause Monopoly, but Google is much much more pro-active in implementing useful standard proposals.
That seems rather contradictory
That doesn't change the fact that the API we initially tried to use was completely broken.
Like, maybe the service we needed to supply with data had a REST API which turned out to be completely broken, so we ended up reverting to generating XML files and uploading that via SFTP. That the data ended up where it needed to doesn't change the fact that their REST API was broken.
We should focus on reducing browser feature creep. There's hundreds of features and most of them are barely used or legacy
And I think the answer is that, no, it did not. And I suspect that we'll end up in a wasm-first world eventually anyway, just with a lengthy and inconvenient detour. But it's worth remembering that IndexedDB predates wasm by several years.