PersistentDataPath returns different paths for differet builds

When building with Unity 5.4.0f3 my game returns persistentDataPath as “/idbfs” but the builds I make with 2017.3.1f1 return different paths like “/idbfs/faaebcb…”. And it’s a different path in each build.
Is this a bug? Shouldn’t it all return “idbfs” ? What do I need to do?
In the screenshot you can see the different SaveGame.dat files created by each build, because they all use different persistentDataPaths.

1 Like

In 2017, the persistentDataPath name contains a hash so that you can host multiple games at the same url without conflict. The hash is computed based on the url of the build json file.

This isn’t referred in the documentation at all, and it’s a serious issue because the savegame file cannot be found by the newer version of the game.
How can I overcome this issue? Would it be safe to directly use “/idbfs/MyGameName/SaveGame.dat” ?

1 Like

Let me clarify:

  • It is expected that 2017.3.1f saves at a different location than 5.4.0f3.
  • Now, the indexedDB path is contains a hash, however, it’s not supposed to change between builds.

Bases on your screenshot, I see 3 different hashes, which is not expected. If this is what you are seeing that might be a bug.
Unless, you uploaded different projects to the same domain, then it is expected and what you see is a saved game for each project.

Does this make sense?

It’s the same project, yes it is creating different path each builds. That’s what I’m saying.
I sent a bug report, they said they can’t reproduce it, I answered back to know what is wrong, they stopped answering.

How is this hash determined? If I decide to change my project name, would it change it?

what’s the bug number?

it’s computed based on page url. We strip the html file name and compute the hash. So, changing the project name should not affect it.

Is the url you are speaking of Application.dataPath? If that is the case, I’ve been uploading my game to itch.io as zip files. So each of them is contained in a different random path like //v6p9d9t4.ssl.hwcdn.net/html/837918/MyGamev1/index.html. So that must be the reason I got different path names each time. (although the page url I visit to play the game is “http: //MyNameHere.itch.io/MyGame”, so that url is constant between builds.

So in this case, my next question is: In this situation, is it possible to use the same save file with different versions of my game uploaded? Can I strip the hash part from persistentDataPath and use it as “idbfs/MyGame”? Would it be safe thing to do?

Just wonder how to get the names of the IndexedDB database and object store?
I need to put some data from pure JS before Unity starts, and later load it from the game script.

Well, already found, database is “idbfs/” and store is MD5(“proto://path.to.the.project”)

Hi, I’m having exactly the same problem as the OP. Is there a suggested workaround if different urls can’t be avoided if that’s the case on itch?

This also appears to be a problem for Unity WebGL games on Facebook when using Facebook’s web hosting for games (Web Hosting - Documentation - Meta for Developers). Every time a new build is posted there’s a change in the URL which results in a new hash for the idbfs path. It would be nice if Unity provided an option to set that path manually or a way to override it…

this is still an issue? i mean, there is some way to store data/ persist data in a game on Itch?? tx

Haven’t looked at this stuff in a while but I’ll copy and paste my workaround from here: Persistent Data in (updatable) WebGL games - General Development - itch.io

*I’ve managed to work around this by saving to/loading from “idbfs/GameName” rather than Application.persistentDataPath in WebGL builds. I saw metinevren suggested that here too: https://forum.unity.com/threads/persistentdatapath-returns-different-paths-for-d… *
HOWEVER, PlayerPrefs and a bunch of other unity stuff still use the persistentDataPath (eg “/idbfs/b647bc5784577…”.) and I’m not sure how to change that. I’m not using PlayerPrefs so it’s not an issue for me.
Also don’t know if this workaround is icky for other reasons. But I can now upload new builds as much as I like and my savegame persists!

Hope this helps!

6 Likes