would there be any reason I should consider storing blobs (like screenshots that can be up to 12MB) in IndexedDB instead of the FileSystem?
unlimitedStorage doesn't apply to any web storage used by extension, it's applied only to chrome.storage.local. Web storage that can grow infinitely (i.e. IndexedDB, FileSystem but not localStorage) uses the global quota manager so it's subject to eviction when the free space on the disk is low and extensions aren't excluded from eviction as well. See https://crbug.com/1209236 for more info.
> storing blobs (like screenshots that can be up to 12MB) in IndexedDB instead of the FileSystem?
+ Cross-browser compatibility+ IndexedDB is arguably faster+ The sandboxed FileSystem will be deprecated it seems, https://crbug.com/695508#c20You can't use Blob/File directly in an img element on your page, but there are wrappers to emulate FS via IDB e.g. https://github.com/ebidel/idb.filesystem.js/IndexedDB had several bugs in the past that caused wipeouts or corruption of data but that's an inevitable consequence of being actively developed.
--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/7a1b9ccd-0347-45a6-838e-b8b43afb50f7n%40chromium.org.
- if I wanted to use another file system API it appears OPFS is the standard that is taking over for the HTML5 File System (but it is not as widely support as IndexedDB)
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/CAAgdh1KXpuUD0Xq0zkzktdvk_2yYYviynuwPfsfpiLQkZUaOyw%40mail.gmail.com.
Here is a new article from Chrome about this topic: Storage and cookies in extensions. The article states that:
By default, extensions are subject to the normal quota restrictions on storage, which can be checked by calling navigator.storage.estimate(). Storage can also be evicted under heavy memory pressure, although this is rare. To avoid this:
- Request the "unlimitedStorage" permission, which affects both extension and web storage APIs and exempts extensions from both quota restrictions and eviction.
- Call navigator.storage.persist() for protection against eviction.
I don't know if it's right.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/2d635608-2410-46ac-b24d-59c52f5d5af1n%40chromium.org.
[...] To me, that implies this persistence *is not* guaranteed for IndexedDB.
Since our data seems like it may qualify as “larger,” this reads as a recommendation *over* `IndexedDB` for our use case.
Which API has the **strongest persistence guarantees** for extensions, especially under heavy write load and eviction scenarios?
Would switching from one huge key to many smaller keys meaningfully reduce corruption risk in `chrome.storage.local` (or IndexedDB, if that is the ultimate recommendation here)?
yes but this does happen, with eviction pressure i think even unlimitedstorage permission is not able to protect user data, and then 'invalidstate' comes which is only fixed with browser restart