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

evanburnsdev avatar image
evanburnsdev asked evanburnsdev edited

WASM Persistent Data not working once product is in the Marketplace

We've had some users experience this issue and I've confirmed it myself. Our avionics suite are designed in webassembly and save user settings to a file in the /work directory. When a change is made, I've verified that the file is updated correctly, so it seems the path is good. But when restarting the flight, none of the settings are read again.

The strangest part of this is that the same aircraft offered on justflight works just fine. I even threw the exact package that I uploaded to Microsoft in my community folder, persistent data works just fine. All of the settings are read and saved as expected.

It appears that something in the encryption process or some other step that Microsoft/Asobo do to prepare our product for the Marketplace is breaking this feature. If anyone has any experience with this issue and a possible workaround, that'd be a tremendous help.


--Edit: I should specify that this has only become an issue in the last month or so. It worked fine when the product was originally submitted and tested.


-- Edit 2: Adding abbreviated code from source:

I'm using fstream.

For reading:

bool Config::init() {
std::ifstream pers_data_file("/work/pers_data.cfg", std::ios::in);
std::string line;

if (!pers_data_file.is_open()) // if file doesn't exist, it will when writePersData() is called
return true;
while (getline(pers_data_file, line)) {
if (line.find("PMFD_page") != -1) {
std::istringstream sin(line.substr(line.find("=") + 2));
sin >> pers_data.PMFD_page;
}

// Loop continues for the rest of the variables
}
pers_data_file.close();
return true;
}

.

For writing:

bool Config::writePersData() {
std::ofstream pers_data_file("/work/pers_data.cfg", std::ios::out);
if (!pers_data_file.is_open()) {
return false;
}
std::string buff = "PMFD_page = " + std::to_string(pers_data.PMFD_page);
pers_data_file << buff << std::endl;

// Continues writing the rest of the variables
return true;
}

Can't figure out how indentation works with code blocks on this website, so please forgive the readability issues.

wasm
10 |10000

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

1 Answer

·
Simbol avatar image
Simbol answered evanburnsdev commented

What technology you using to save and read back?


I use persistent data on wasm for many products and never seen this issue.


R.

1 comment
10 |10000

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

evanburnsdev avatar image evanburnsdev commented ·

I'm using fstream.

For reading:

bool Config::init() {
std::ifstream pers_data_file("/work/pers_data.cfg", std::ios::in);
std::string line;

if (!pers_data_file.is_open()) // if file doesn't exist, it will when writePersData() is called
return true;
while (getline(pers_data_file, line)) {
if (line.find("PMFD_page") != -1) {
std::istringstream sin(line.substr(line.find("=") + 2));
sin >> pers_data.PMFD_page;
}

// Loop continues for the rest of the variables
}
pers_data_file.close();
return true;
}

.

For writing:

bool Config::writePersData() {
std::ofstream pers_data_file("/work/pers_data.cfg", std::ios::out);
if (!pers_data_file.is_open()) {
return false;
}
std::string buff = "PMFD_page = " + std::to_string(pers_data.PMFD_page);
pers_data_file << buff << std::endl;

// Continues writing the rest of the variables
return true;
}

Can't figure out how indentation works with code blocks on this website, so please forgive the readability issues.

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 19.1 MiB each and 23.8 MiB total.