• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

MSFS20 unknown wasm error

Messages
162
Country
italy
hello
i'm receive this error from the in-game dev console:

Code:
WASM: Exception c000001d in gauge warning_panel in module
 P:\MicrosoftFlightSimulator\Community\mycompany-aircraft-wasm-gauge\SimObjects\Airplanes\MyCompany_Gauge_Aircraft\panel\ssw_shared.wasm

nevertheless the module is compiled, initialized and loaded correctly, it works nicely as well.
Someone had same issue ?
Below the module code,
the SetRpmOverspeed() is triggered by a custom event originated in the behaviou xml when the PROP RPM overtakes 2600 rpm.
tia
/mario

Code:
#include "ssw_shared.h"
#include "simvars.h"
#include <engine.h>
struct S_WLIGHTS
{
    int iFont;
    NVGcontext* nvgctx;
    LocalSimVar* rpm_overspeed;
}; 
//////////////////
S_WLIGHTS wlights = {-1,0,0};
extern Engine* myEngine;

void SetRpmOverspeed(FLOAT64 overspeed) {
    if (myEngine) {
        RWSimVar* prop_rpm = myEngine->prop_rpm;
        RWSimVar* throttle = myEngine->throttle_pos;
        wlights.rpm_overspeed->Set(overspeed);
        if (prop_rpm && throttle && (prop_rpm->Get() > 2600)) {
            FLOAT64 thr = throttle->Get();
            thr -= 0.2;
            throttle->Set(thr);
        }
    }
}
///////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
void DrawWarnings(NVGcontext* nvgctx, sGaugeDrawData* p_draw_data, struct S_WLIGHTS* data) {
    if (data->iFont != -1) {
        char str[50] = "";
        //////////////////////////////////////////////////////////
        nvgFontFaceId(nvgctx, data->iFont);
        nvgFontSize(nvgctx, 0.20 * p_draw_data->winHeight);
        nvgTextAlign(nvgctx, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
        nvgFillColor(nvgctx, nvgRGB(250, 0, 0));
        if (data->rpm_overspeed->Get() > 0.0) {
            sprintf(str, "RPM OVERSPEED");
            nvgText(nvgctx, 0, 0.10f * p_draw_data->winHeight, str, (const char*)NULL);
        }
    }
}
////////////////////////////////////////////////
extern "C" {
    
    MSFS_CALLBACK bool warning_panel_gauge_callback(FsContext ctx, int service_id, void* pData)
    {
        
        switch (service_id)
        {
        /**/
        case PANEL_SERVICE_PRE_INSTALL:
        {
            
        }
        break;
        ////////////////////////
        case PANEL_SERVICE_POST_INSTALL:
        {
            NVGparams params;
            wlights.rpm_overspeed = dynamic_cast<LocalSimVar*>(GetSimVar("rpm_overspeed"));
            ///////////
            params.edgeAntiAlias = true;
            params.userPtr = ctx;
            params.edgeAntiAlias = true;
            params.userPtr = ctx;
            wlights.nvgctx = nvgCreateInternal(&params);
            if (wlights.nvgctx)
                wlights.iFont = nvgCreateFont(wlights.nvgctx, "serif", "./data/Roboto-Regular.ttf");
        }
        break;
        /////////////////
        case PANEL_SERVICE_PRE_DRAW:
        {            
            /// /////////////
            sGaugeDrawData* p_draw_data = (sGaugeDrawData*)pData;
            float pxRatio = (float)p_draw_data->fbWidth / (float)p_draw_data->winWidth;
            NVGcontext* nvgctx = wlights.nvgctx;
            nvgBeginFrame(nvgctx, p_draw_data->winWidth, p_draw_data->winHeight, pxRatio);
            {
                NVGpaint imgPaint;
                int imgw, imgh;
                // Black background
                nvgFillColor(nvgctx, nvgRGB(0, 0, 0));
                nvgBeginPath(nvgctx);
                nvgRect(nvgctx, 0, 0, p_draw_data->winWidth, p_draw_data->winHeight);
                nvgFill(nvgctx);
                // draws warning lights
                DrawWarnings(nvgctx, p_draw_data, &wlights);
            }
            nvgEndFrame(nvgctx);
        }
        break;
        //////////////////
        case PANEL_SERVICE_PRE_KILL:
        { 
            NVGcontext* nvgctx = wlights.nvgctx;
            nvgDeleteInternal(nvgctx);
            FlushVarList();        
        }
        break;
        //////////////////
        default:
            return false;
        } /////////////////////////
        return true;
    }
}
 
Someone had same issue ?
Yes, I have tried you module.
Unfortunately as stated in WASM's known limitations: "C++ exceptions are not supported." So you can't try-catch your exception.
But I have located the problem's point using ugly debug.
Code:
WASM: Compiled module DemoModule1.wasm in 58 seconds (Init: 0 ms / Compile: 1062 ms / Optim: 0 ms / Link Init: 749 ms / Link Generate: 56223 ms / Link LLVM: 107 ms).
WASM: Module DemoModule1.wasm loaded...
WASM: Module DemoModule1.wasm initialized.
Begin PANEL_SERVICE_PRE_INSTALL
Begin PANEL_SERVICE_POST_INSTALL
True  PANEL_SERVICE_POST_INSTALL
Begin PANEL_SERVICE_PRE_INITIALIZE
True  PANEL_SERVICE_PRE_INITIALIZE
Begin PANEL_SERVICE_POST_INITIALIZE
True  PANEL_SERVICE_POST_INITIALIZE
Begin PANEL_SERVICE_PRE_UPDATE
True  PANEL_SERVICE_PRE_UPDATE
Begin PANEL_SERVICE_POST_UPDATE
True  PANEL_SERVICE_POST_UPDATE
Begin PANEL_SERVICE_PRE_DRAW
DRAWING IF
WASM: Exception c000001d in gauge warning_panel in module C:\MSFS SDK\Samples\GaugeAircraft\Packages\mycompany-aircraft-wasm-gauge\SimObjects\Airplanes\MyCompany_Gauge_Aircraft\panel\DemoModule1.wasm
So the problem is in the first execution of case PANEL_SERVICE_PRE_DRAW and more precisely is that code inside DrawWarning, maybe Get() method or something else. I have placed blobs over the code I doesn't have.
C++:
....
        nvgFillColor(nvgctx, nvgRGB(250, 0, 0));
        fprintf(stderr, "DRAWING IF\n");
        if (data->rpm_overspeed->Get() > 0.0) {   // <----- Somewhere here
            sprintf(str, "RPM OVERSPEED");
            nvgText(nvgctx, 0, 0.10f * p_draw_data->winHeight, str, (const char*)NULL);
        }
    }
    fprintf(stderr, "DRAWING END\n");
....
After showing Exception the gauge doesn't work at all and corresponding dll is unloaded.

P.S. Ugly debug example.
C++:
#include <cstdio>
#include <map>

...
    
std::map<int, const char *> service_name = {
    {PANEL_SERVICE_PRE_QUERY, "PANEL_SERVICE_PRE_QUERY"},
    {PANEL_SERVICE_POST_QUERY, "PANEL_SERVICE_POST_QUERY"},
    {PANEL_SERVICE_PRE_INSTALL, "PANEL_SERVICE_PRE_INSTALL"},
    {PANEL_SERVICE_POST_INSTALL, "PANEL_SERVICE_POST_INSTALL"},
    {PANEL_SERVICE_PRE_INITIALIZE, "PANEL_SERVICE_PRE_INITIALIZE"},
    {PANEL_SERVICE_POST_INITIALIZE, "PANEL_SERVICE_POST_INITIALIZE"},
    {PANEL_SERVICE_PRE_UPDATE, "PANEL_SERVICE_PRE_UPDATE"},
    {PANEL_SERVICE_POST_UPDATE, "PANEL_SERVICE_POST_UPDATE"},
    {PANEL_SERVICE_PRE_GENERATE, "PANEL_SERVICE_PRE_GENERATE"},
    {PANEL_SERVICE_POST_GENERATE, "PANEL_SERVICE_POST_GENERATE"},
    {PANEL_SERVICE_PRE_DRAW, "PANEL_SERVICE_PRE_DRAW"},
    {PANEL_SERVICE_POST_DRAW, "PANEL_SERVICE_POST_DRAW"},
    {PANEL_SERVICE_PRE_KILL, "PANEL_SERVICE_PRE_KILL"},
    {PANEL_SERVICE_POST_KILL, "PANEL_SERVICE_POST_KILL"},
    {PANEL_SERVICE_CONNECT_TO_WINDOW, "PANEL_SERVICE_CONNECT_TO_WINDOW"},
    {PANEL_SERVICE_DISCONNECT, "PANEL_SERVICE_DISCONNECT"},
    {PANEL_SERVICE_PANEL_OPEN, "PANEL_SERVICE_PANEL_OPEN"},
    {PANEL_SERVICE_PANEL_CLOSE, "PANEL_SERVICE_PANEL_CLOSE"}
    };

extern "C" {
    MSFS_CALLBACK bool warning_panel_gauge_callback(FsContext ctx, int service_id, void* pData)
    {
        fprintf(stderr, "Begin %s\n", service_name[service_id]);
        switch (service_id)
        {
....
        default:
            fprintf(stderr, "False %s\n", service_name[service_id]);
            return false;
        }
        fprintf(stderr, "True  %s\n", service_name[service_id]);
        return true;
    }
}
 
Thanks a lot, will investigate further.
Error shows erratically, not always and more often during the initial load when the aircraft has been cached, the second load/compile does not show the error (i mean after click on "flight now")
/Mario
 
Back
Top