IndexedDB and LocalStorage Issue on macOS
Safari has in built security restrictions which stops the data blobs from accessing the localStorage and/or calling the indexedDB functions. You can use the following repo to test replicate this issue.
Issue
Unable to use WebView storage on macOS
Resources Used
-
window.localStoragefor localstorage access - Dexie.js for IndexedDB operations
What I found out is that it's probably not security related as much as it's simply a limitation of embedding the html inside your binary.
When you feed webview a html string as opposed to a file it makes it navigate to a url that looks like this: data:text/html,<your entire html here>.
Now localStorage stores key-value pairs for each domain, but what's your domain here? It might even change when the DOM changes, I'm not so sure about that.
Also apparently chromium's blink engine specifically treats all data urls as unique, even when they're the exact same (source).
You can try it out in any regular browser by navigating to an address that starts with data:text/html and then has some html after that, and then trying to access window.localStorage.
I've tested this on epiphany (gnome web), firefox and chromium (all on linux) and have gotten similar messages on all of them.
A solution I came up with is to use webview's binding capabilities to emulate some sort of storage api for when my app runs in a native wrapper (I'd like to support running it in a browser as well), but it doesn't seem like that's possible right now because only js -> rust communication is possible and not the other way (at least that's what I got from looking through the issues).