I've narrowed down where in the code (javascript in the HTML) the error is happening. I have a simple UIPanelObject with an HTML page showing various types of information. I removed most functionality from the loop statement containing only the code that causes the crash.
At runtime, the program works great; however, when reloading the scenario, closing the scenario, or loading a different scenario the program will crash.
The Event Viewer gives Exception code: 0xc0000005, which I believe there is an attempt to write to RAM in an area where we no longer have permission. This has not been very helpful in my troubleshooting.
Here is the offending bit of javascript:
Code: Select all
function loop(timestamp)
{
init();
var leftInput = VarGet("L:KNL-Left", "number");
var rightInput = VarGet("L:KNL-Right", "number");
window.requestAnimationFrame(loop);
}
window.requestAnimationFrame(loop); // Starts first call of loop
NOW, the weird bit I have found, is when I remove the act of saving the results of VarGet but still call it,
the crashing disappears.
Example below:
Code: Select all
function loop(timestamp)
{
init();
VarGet("L:KNL-Left", "number");
VarGet("L:KNL-Right", "number");
window.requestAnimationFrame(loop);
}
window.requestAnimationFrame(loop); // Starts first call of loop
Without saving the information of VarGet I tried to call that function everywhere in my code where I would have called the variable I saved it to (inefficient, i know). This reintroduces the crashing, which leads me to believe that it is the API in P3D that is causing the crash, but only when I use these functions.
Another bit of information that leads me to believe this is when I try using another function of the Javascript API IsSimPaused(), it crashes in the exact same way.
Code: Select all
function loop(timestamp)
{
init();
if (IsSimPaused())
{
// Empty!
}
window.requestAnimationFrame(loop);
}
window.requestAnimationFrame(loop); // Starts first call of loop
Other things I have tried:
- Encasing the VarGet calls in a try catch statement.
- Checking if the function VarGet exists before calling it everytime
Has anyone else experienced this type of issue, or know other troubleshooting steps I could take?
Thank you for reading about my problem and I'll take any help I can get.