Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi John,

months ago, I participated a little in the debugging of the WASM client API, now I use it extensively, mainly through the the function "executeCalclatorCode". Currently, I use FSUIPC 7.3.6 (as reported in FSUIPC7's log file) and my client based on the github version 0.5.10 released "10 days ago" = end of May. I also use "FSUIPC7|WASM|List Lvars" so as to track the Lvar changes.
I found 1 problem and a potential one:

Problem 1: "WASM.h" (version 0.5.9) says that the MAX_CALC_CODE_SIZE is 1024 by default. I passed 415 characters to executeCalclatorCode without any issue. But when I try to pass 552 characters, I find the relevant line in FSUIPC_WASM.log, but it is the last line even if other executeCalclatorCode calls come afterwards. And eventually, MSFS crashes. Note that I get the same result by passing the long string to "FSUIPC7|WASM|Execute Calculator Code...". It is not a major issue, since I have a workaround, i.e. split my calculator code in 2 independent and shorter strings. I would prefer to know the real max size, and where it comes from (FSUIPC, MSFS, aircraft loaded in the sim, ..?).

Potential problem 2: "WASM.h" says that it allows for "3*1024" Lvars. When I load Red Wing's Super Constellation in the sim, "FSUIPC7|WASM|List Lvars" gives 1926 Lvars (so does my own client), which is fine; this number stays stable until I shutdown MSFS. When I restart MSFS and load PMDG's DC-6, I get 3066 Lvars, among these are Lvars belonging to the previous aircraft. I am aware of this behaviour, but since 3066 is very close to 3*1024, I might hit the limit some day. May I safely change MAX_NO_VALUE_CDA from 3 to, say, 4, recompile my client and use it with the current FSUIPC7_WASM.wasm?

 

Posted
9 hours ago, d147 said:

Problem 1: "WASM.h" (version 0.5.9) says that the MAX_CALC_CODE_SIZE is 1024 by default. I passed 415 characters to executeCalclatorCode without any issue. But when I try to pass 552 characters, I find the relevant line in FSUIPC_WASM.log, but it is the last line even if other executeCalclatorCode calls come afterwards. And eventually, MSFS crashes. Note that I get the same result by passing the long string to "FSUIPC7|WASM|Execute Calculator Code...". It is not a major issue, since I have a workaround, i.e. split my calculator code in 2 independent and shorter strings. I would prefer to know the real max size, and where it comes from (FSUIPC, MSFS, aircraft loaded in the sim, ..?).

It should be 1024. I suspect that it is a logging statement somewhere that doesn't have a buffer big enough (using sprintf rather than sprintf_s as I should...!). I will look into it and get back to you.

10 hours ago, d147 said:

Potential problem 2: "WASM.h" says that it allows for "3*1024" Lvars. When I load Red Wing's Super Constellation in the sim, "FSUIPC7|WASM|List Lvars" gives 1926 Lvars (so does my own client), which is fine; this number stays stable until I shutdown MSFS. When I restart MSFS and load PMDG's DC-6, I get 3066 Lvars, among these are Lvars belonging to the previous aircraft. I am aware of this behaviour, but since 3066 is very close to 3*1024, I might hit the limit some day.

3066 is currently the maximum of lvars available via the WASM, as this is also restricted by the number of LVAR CDAS:

#define MAX_NO_LVAR_CDAS        21 // 21 is max and allows for 3066 lvars - the max allowed for the 3 value areas (8k/8) is 3072

So you have already hit the limit.

10 hours ago, d147 said:

May I safely change MAX_NO_VALUE_CDA from 3 to, say, 4, recompile my client and use it with the current FSUIPC7_WASM.wasm?

No. First, the  WASM.h file is shared between the WASM and the WAPI and any changes to that file would require both the WAPI and the WASM to be recompiled.
Second. as the current limit is actually defined by MAX_NO_LVAR_CDAS, this would also need increasing (you need 7 LVAR CDAs for each lvar value CDA created).

MSFS seems to load/keep lvars from previously loaded aircraft, as well as from aircraft just installed in your Community folder. It is recommended to clear your Community folder of aircraft not being used (as well as anything else) before you start MSFS/ Lots of people use the MSFS Add-on Linker program (freeware) to do this.

Posted
25 minutes ago, John Dowson said:

It should be 1024. I suspect that it is a logging statement somewhere that doesn't have a buffer big enough (using sprintf rather than sprintf_s as I should...!). I will look into it and get back to you.

Yes, this is definitely the case - . I will need to rebuild/update the WASM. I will post a version here for you to test when done.

Posted

Shame on me, how could I miss the comment after "#define MAX_NO_LVAR_CDAS        21"? I assume this value cannot be modified to solve the issue. I'll try MSFS Add-on Linker, thanks for your patience and advise.

I used the 3 files provided to patch your plugin, and yes, my 552 characters calculator string works as expected, no more crash.

Thanks a lot for your reactivity!

Posted
6 minutes ago, d147 said:

I assume this value cannot be modified to solve the issue.

No. That file is the interface to the WASM module and any changes would require a WASM rebuild, as well as code changes.
I have only just increased the lvar limit from 2044 to 3066 lvars. This should really be more than enough and I am not planning on increasing this again - at least for the foreseeable future.

John

Posted

I have installed MSFS Add-on Linker. The junctions it creates or erases according to the pre-selected aircraft(s) are actually an efficient way to reduce the number of LVars. Switching from the DC-6 alone to the Connie alone gives me 1961 LVars at the first run, 1912 at the second run (instead of 1926, previously). The DC-6 gives me 1724 LVars and works better; now, I understand why some LVars I wanted to use were missing when the 3066 limit was hit, and why they were not missing when I re-started the game with the same aircraft as that one loaded at the previous FS session.

Thanks again!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.