The update callbacks are a way for WASM modules to better handle the Microsoft Flight Simulator 2024 frame updates so that you can run code at specific intervals and better adapt to the simulation state at any given time.

Frame Timings

In previous versions of the simulation, a frame would be split up in the following manner:

Legacy Frame Timings

So, during the “update” part, the simulation runs first, then any RPN, and then finally the WebAssembly is executed. However, the problem with this is that it can problematic for addons which manipulate cameras, physics, or systems, since the WASM occurs too late in the frmae, which can lead to a noticeable frame shift.

In MSFS 2024, however, a frame will now be split up as follows:

Modern Frame Timings

We have now an initial simulation phase which is dedicated only to the physics simulation. At the end of this phase, the position of the aircraft is then determined and the simulation will formulate the new position of the camera (which will have an impact on LOD selection). This means that you can now use the Update API callbacks to target the initial phase before the final camera position is calculated to prevent any graphical issues.

For those modules that don’t change any of the physics or move the camera, the update API also has callbacks that can target before and after the simulation systems update, giving you a lot more granual control of how and when things will happen. There is also a final update phase for WebAssembly which can be used for garbage collection or anything that must be performed at the end of the update phase.

Using The Callbacks

The update callbacks are all used in the same way:

void function_name(float dTime);

To see how a file might be structered using these callbacks, below you can find a bare-bones schema for a stand-alone module (the concept is the same for gauges and airports):

#include <stdio.h>
#include "$safeprojectname$.h"

extern "C"
{
	MSFS_CALLBACK void module_init(void)
	{
		// This is called when the module is initialized
	}

	MSFS_CALLBACK void module_pre_sim_physics_update(float dTime)
	{
		// This is called each frame before the physics part of the simulation is computed.
		// dTime is the time between the previous frame and this one
	}

	MSFS_CALLBACK void module_post_sim_physics_update(float dTime)
	{
		// This is called each frame after the physics part of the simulation is computed.
		// dTime is the time between the previous frame and this one
	}

	MSFS_CALLBACK void module_pre_sim_systems_update(float dTime)
	{
		// This is called each frame after the physics part of the simulation is computed.
		// At this stage, the position of simobjects has aleady been determined. Only simojects' systems will be updated
		// dTime is the time between the previous frame and this one
	}

	MSFS_CALLBACK void module_post_sim_systems_update(float dTime)
	{
		// This is called each frame after the simulation is computed.
		// At this stage, simobjects' physics and systems have been determined
		// dTime is the time between the previous frame and this one
	}

	MSFS_CALLBACK void module_late_update(float dTime)
	{
		// This is called each frame at the end of it, just before the draw part.
		// dTime is the time between the previous frame and this one
	}

	MSFS_CALLBACK void module_deinit(void)
	{
		// This is called when the module is deinitialized
	}
}

Pre And Post Physics Callbacks

The callbacks available for the pre- and post- physics update events are as follows:

FunctionDescription
XXX_gauge_pre_sim_physics_updateCallback related to the “XXX” gauage that will be called before the physics update, where “XXX” is the name of the gauge as given in the [VCockpitN] of the panel.cfg.
XXX_gauge_post_sim_physics_updateCallback related to the “XXX” gauage that will be called after the physics update, where “XXX” is the name of the gauge as given in the [VCockpitN] of the panel.cfg.
XXX_system_pre_sim_physics_updateCallback related to the “XXX” gauage that will be called after the physics update, where “XXX” is the name of the gauge as given in the [WASM_SYSTEM.N] of the systems.cfgfile.
XXX_system_post_sim_physics_updateCallback related to the “XXX” gauage that will be called after the physics update, where “XXX” is the name of the gauge as given in the [WASM_SYSTEM.N] of the systems.cfgfile.
module_pre_sim_physics_updateCallback for a WebAssembly stand alone module that will be called before the physics update.
module_post_sim_physics_updateCallback for a WebAssembly stand alone module that will be called after the physics update.
airport_pre_sim_physics_updateCallback for a WebAssembly airport module that will be called before the physics update.
airport_post_sim_physics_updateCallback for a WebAssembly airport module that will be called after the physics update.

Pre And Post System Callbacks

The callbacks available for the pre- and post- system events are as follows:

FunctionDescription
XXX_gauge_pre_sim_systems_updateCallback related to the “XXX” gauage that will be called before the system update, where “XXX” is the name of the gauge as given in the [VCockpitN] of the panel.cfg.
XXX_gauge_post_sim_systems_updateCallback related to the “XXX” gauage that will be called after the system update, where “XXX” is the name of the gauge as given in the [VCockpitN] of the panel.cfg.
XXX_system_pre_sim_systems_updateCallback related to the “XXX” gauage that will be called before the system update, where “XXX” is the name of the gauge as given in the [WASM_SYSTEM.N] of the systems.cfgfile.
XXX_system_post_sim_systems_updateUCallback related to the “XXX” gauage that will be called after the system update, where “XXX” is the name of the gauge as given in the [WASM_SYSTEM.N] of the systems.cfgfile.
module_pre_sim_systems_updateCallback for a WebAssembly stand alone module that will be called before the system update.
module_post_sim_systems_updateCallback for a WebAssembly stand alone module that will be called after the system update.
airport_pre_sim_systems_updateCallback for a WebAssembly airport module that will be called before the system update.
airport_post_sim_systems_updateCallback for a WebAssembly airport module that will be called after the system update.

Pre And Post Update Callbacks

The callbacks available for the pre- and post- update events are as follows:

FunctionDescription
XXX_gauge_late_updateCallback related to the “XXX” gauage that will be called at the end of the frame update, before the draw, where “XXX” is the name of the gauge as given in the [VCockpitN] of the panel.cfg.
XXX_system_late_updateCallback related to the “XXX” gauage that will be called at the end of the frame update, before the draw, where “XXX” is the name of the gauge as given in the [WASM_SYSTEM.N] of the systems.cfgfile.
module_late_updateCallback for a WebAssembly stand alone module that will be called at the end of the frame update, before the draw.
airport_late_updateCallback for a WebAssembly airport module that will be called at the end of the frame update, before the draw.