CTD with C:fs9gps:FlightPlanDepartureAirportIdent

This line:

var departuId=SimVar.GetSimVarValue('C:fs9gps:FlightPlanDepartureAirportIdent', 'String');

generates a CTD when the flight plan is manually entered into the GPS. However
it works correctly if the flight plan is made from the map before the flight.
It doesn’t matter that the line puts it between a Try Catch… the result is
still CTD. Tested with G530 from C172 classic with the new update today. The
same with:

var arrivalId=SimVar.GetSimVarValue('C:fs9gps:FlightPlanDestinationAirportIdent', 'String');

Am I doing something wrong or am I missing some detail?

Hello @ErDebugger I am not sure to understand, where are you making those
calls? Are you editing the WT530 files? Regards, Sylvain

I am expanding some options of my addon ALL IN ONE (it’s an ingame panel). I
want to display the flight plan on the tablet with the percentage of flight
flown, but if the user enters the flight plan manually, that call fails.
However if the flight plan is entered into the map before going on the flight,
it works fine.

Can you provide us with a version of your package that produces the crash as
well as instructions to trigger it? My guess is that those vars depend on the
user SimObject and your ingame panel sends requests while this SimObject is
not ready yet. But that’s a blind guess and it would neeed to be confirmed.
Regards, Sylvain

This is reproducible with the PMS50 GPS for MSFS2020 as well:

  1. Start flight without flight plan
  2. Wait until the flight is loaded
  3. Press “Ready to fly”
  4. Open PMS50
  5. Enter a departure airport
  6. Enter an arrival airport
  7. Open Coherent GT Debugger, then open the debugger for any addon
  8. Run this in the JS console: SimVar.GetSimVarValue("C:fs9gps:FlightPlanDestinationAirportIdent", "string")

The sim will freeze immediately and CTD within a second or so.

I would not recommend attempting to use any FS9GPS simvars any longer. The code they exist in is very legacy without good threading support and is subject to some race conditions.

If you’re in WASM it is probably still safe to use these as WASM presently executes on the main thread along with these vars, but if you’re in JS I would use the Coherent calls for the sim flight plan instead.

Thanks,
Matt

1 Like