Our system downloads media files from S3 and plays them from the local file system. We generally use UnityWebRequest (previously WWW) to load the local files so that we can take advantage of the media-specific properties and features (audioClip, texture, etc.).
This code seems to fail when loading files from indexedDB. We’re experimenting with different options, but before we bang our heads against the wall too much–is this supposed to work, or do we need to convert to System.IO calls to access data in indexedDB? I can’t seem to find any official guidance on this.
Those are System.IO calls. What I’m wondering is whether UnityWebRequest can be used to load media files from indexedDB. This works on all other platforms, but I haven’t been able to get it to work for WebGL.
Although I appreciate the insight, it would be great for someone from Unity to chime in on why this doesn’t work. There is no documentation that mentions this limitation that I can find. Is this a bug?
If you enable “Data Caching” under WebGL project Publishing Settings, then UnityWebRequest will utilize IndexedDB as an explicit caching mechanism for downloaded files. In that usage, the downloaded files will persist automatically and transparently into IndexedDB as the downloads occur for the first time. Manually saving the downloaded files to Application.persistentDataPath should not be needed (that would be storing the files twice)
If you have “Data Caching” disabled, then you should be able to write files under Application.persistentDataPath to persist them in IndexedDB. Anything that is saved there should be stored under “/idbfs” directory in IndexedDB. Check out the Chrome DevTool at Chrome DevTools | Chrome for Developers . You can use that to debug and diagnose what is persisted to IndexedDB at any given time.
And how about his question on whether a UnityWebRequest can access those files (ignoring whether that’s the right way to do it based on your info above)?