plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.

Please take a moment to read the platform’s guidelines before you get started!

question

FlyingRaccoon avatar image
FlyingRaccoon asked FlyingRaccoon commented

LocalStorage Persistence in general and for panels specifically

Hi,

We are providing authenticated services to a steadily increasing amount of 3rd party aircraft including the more popular ones. As our services are authenticating using OpenID we rely on being able to use minimal persistent storage for keeping a refresh-token (simple string) persistent over restarts of flights and the simulator itself. Currently, all implementations that authenticate through the Coherent javascript environment are using localStorage for saving this token. It seems to work most of the time, but we can see from our logs that there are cases of the state randomly being lost. I assume this is a known bug that is being worked on?

We also just soft-released an InGamePanel with our Charts product loaded as an iframe. The localStorage in the InGamePanel is consistently being reset after each flight, forcing our users to re-login several times during one gaming session. This is seriously impacting the user experience and we would really want to have it sorted out.

Our guess is that the panel reloads after each flight but that the local folder for the InGamePanel is not set in Coherent so that it uses the fallback in-memory store that is being reset? Is this a correct assumption, if so could this be fixed in a future update or are there any workarounds or best practices for keeping persistence?

Kind regards,

Markus
Product Design Lead
Navigraph

gauges
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

pms50 avatar image
pms50 answered

Some kind of flush function for the local storage would help here so we can save it when necessary.
Currently if you don't leave the sim by the welcome "quit to desktop" screen, the changes in the local storage may be lost.

10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

dga avatar image
dga answered dga edited

Don't confuse LocalStorage (non persistent) with DataStore (savegame persistent).

What you should be using is the DataStore, which you can pull in using datastore.js

This way you can set/get key value pairs that are persisted across sim sessions.
During a sim session it should keep the value. So when you read from there when your InGamePanel is loaded, the token should always be there.

A known limitation to DataStore right now is, that it is often only properly persisted across sessions when the game is closed gracefully. Not via CTD or killing the process.

-- dga | Working Title

10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

pms50 avatar image
pms50 answered FlyingRaccoon commented

A known limitation to DataStore right now is, that it is often only properly persisted across sessions when the game is closed gracefully. Not via CTD or killing the process.

Do we have a chance for that to be fixed in SU5?

1 comment
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Unfortunately, it won't be fixed in SU5. We will let you know when this is fixed.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.