-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore StorageContainer API #8518
Comments
I can see if I can share the implementation of our internal save data manager. It doesn't fit the What I did is a sort of in-memory-database system where you write to "named streams" which are virtual file containers, and when you do a "commit", it locks the streams for writing and starts a thread to call the platform specific API stuff (or just writes files on PC). It also prevents too many I/O on consoles where there is an I/O limit and issues warnings. If nobody takes on it, I might have a look at it, but anyone is welcome as I don't know when I'll be able to afford that time. |
Do we want to keep the exact same API? I can see some limitations in the original API. For instance, it assumes immediate writing of data when pushing something to a stream, which is not desirable on most platforms and there is no global "flush" command to control that. I would slightly change the API to make it obvious that changes are first staged in-memory, and that you need to manually commit/flush them. |
@mrhelmut I can have a stab at just bringing it back to life and as @tomspilman mentioned getting it to use the new partial classes structure. Then we can always enhance it down the line in a separate PR. |
Feel free to! I think we should get the API planned ahead and the rest can be done later (we just need to avoid the public API to move if we push it to a public release). |
Yes that is the main limitation is no explicit "commit" call to flush results. We can add one to make the issue visible to developers, but i would make it optional to use it that way. The design of the old API requires you So i think we could make the safe assumption that once If the user's code doesn't Dispose... that is a bug and on them. If the user's code is written in a way that uses lots of So i think it could work as is... thoughts? |
Also, we might want to keep a But yeah, I guess the public API may just work as-is. These are implementation concerns. |
Technically it even happens on FileStream if you dispose without closing/flushing it does it for you during Dispose. So I think it is ok. We would still have a new explicit Commit() call in there for users that want to be explicit about it.
My worry about having it all in memory is I've seen some games with really big save data files. Now these game struggle on consoles, but you can do it. So we may keep this caching to small file and hit disk for large ones.
One thing we may have to deal with is that on some platforms you cannot keep save storage open for a long period of time. Not sure fully yet how we enforce that beyond just documenting the limit and offering warnings on PC platforms. |
What I have in mind and did internally, is that when you create the manager, save data are opened->read/cached->closed and then you access the cached data to avoid having too many I/O or leave the save data open. But that assumes that save data are small enough to be directly cached. It is indeed not suitable for large save data. Maybe we could give control to the caching system. E.g. an overload to We can likely implement threshold detections and generate warnings when certification would fail due to I/O ops. |
Intent
We need to restore the old XNA StorageContainer APIs to provide a more generate way for developers to work with save data.
See the version last released in MG 3.5:
https://github.com/MonoGame/MonoGame/blob/v3.5/MonoGame.Framework/Storage/StorageContainer.cs
Motivation
We need a cross platform way for developers to access save data on PCs, consoles, and mobile.
While the
StorageContainer
has some old ideas (theAsyncCallback
system) in general it does abstract file access well enough hide the complexity of console save game access.Some extra features and documentation could complete things and make it a good solution.
What would need to happen:
StorageContainer
.This could be made into one or more bounties if we need to accelerate the development.
The text was updated successfully, but these errors were encountered: