Hi devs,
I would like to introduce an optional AI feature in my extension that would require ~75MB assets (onnx model + the wasm of onnxruntime-web). The assets will be used by a web worker created by a content script. I'm considering how can the extension store that data.
The straightforward way is to package the assets into the crx. In this way, the web worker can reference the assets through chrome-extension:// URLs if I add them into web_accessible_resources in manifest.json. But this will affect the installation time of my extension, and also waste 75MB disk space for everyone not using this feature, which I would like to avoid.
To exclude the assets from crx and download them on demand, we have the unlimitedStorage permission and chrome.storage.local API. However, chrome.storage.local can only store strings and it's also unavailable in web workers. It will be very inefficient to load the assets in the content script, decode the string back to blob, and then pass it to the web worker.
An alternative approach is to download the assets in web worker and store it into indexedDB or cacheStorage. However, these Web APIs are bound to the injected domain, so it cannot be shared across multiple injected domains and chrome-extension:// pages. It also lacks the guarantee of data persistence.
Has anyone encountered similar use cases? Any help is appreciated.