whosonfirst / whosonfirst-www-spelunker

A simple Flask-based spelunker for poking around Who's On First data
BSD 3-Clause "New" or "Revised" License
7 stars 9 forks source link

Infinite requests for local storage on Safari #126

Open matteblair opened 7 years ago

matteblair commented 7 years ago

Encountered on macOS 10.12.6, Safari 10.1.2

To reproduce, navigate to a page in the Spelunker on Safari, following a link such as: https://whosonfirst.mapzen.com/spelunker/brands/420574927/. You must be visiting it for the first time in this browser or have cleared storage preferences for the domain (Safari -> Preferences -> Privacy -> Manage Website Data... -> mapzen.com -> Remove).

You should encounter an alert like this: screen shot 2017-08-31 at 2 24 33 pm

If you click "Don't Allow", the alert is immediately recreated. While the alert is shown, you cannot close tabs, change settings, open a developer console, or quit Safari. The browser is locked until you agree to allow however much local storage the page needs.

I think this alert is only triggered when a page requests more than 5MB of storage, so maybe this is do to a recent change in the local storage usage? Whatever the cause, can we let the page fail in this case rather than locking the whole browser?

thisisaaronland commented 7 years ago

Hrm... yeah, the reason that's happening over and over again is because this...

https://github.com/whosonfirst/js-mapzen-whosonfirst/blob/master/src/mapzen.whosonfirst.net.js

...if fetching lots of files and not being smart about not invoking the cache/localforage hooks after they've been denied the first time.

thisisaaronland commented 7 years ago

Check for this and disable further cache sets if true...

SQLError {code: 4, message: "there was not enough remaining storage space, or t…reached and the user declined to allow more space", UNKNOWN_ERR: 0, DATABASE_ERR: 1, VERSION_ERR: 2, …}