Closed TwinFan closed 4 years ago
Aircraft invalidation happens from the "CalcPosThread" (LTFlightData.cpp:657
in LTFlightData::DataCleansing()
), which can now crash XP. Has been reported twice in the support forum (one, two) and looks like this in the log:
1:54:40.620 LiveTraffic DEBUG LTFlightData.cpp:1534/IsPosOK: AB6784 N834DC: Invalid vector <h 282, 108m @ -83kt, -nan(ind)ft/m> with headingDiff = 151
1:54:40.620 LiveTraffic DEBUG LTFlightData.cpp:1534/IsPosOK: AB6784 N834DC: Invalid vector <h 139, 801m @ 173kt, 1912ft/m> with headingDiff = -144
1:54:40.620 LT/XPMP2 ERROR Aircraft.cpp:615/SetInvalid: Aircraft 0xAB6784 set INVALID
1:54:40.620 E/SYS: THREAD FATAL ASSERT: rel_assert Error! Possibly an out of range vector! Attach the debugger and see who called this!
1:54:40.620 E/SYS: THREAD FATAL ASSERT: !THREAD_is_inited() || THREAD_is_main_thread()
1:54:40.620 E/SYS: THREAD FATAL ASSERT: XPDestroyInstance
1:54:40.620 E/SYS: THREAD FATAL ASSERT: Please report this to Laminar Research.
1:54:40.620 E/SYS: THREAD FATAL ASSERT: C:\jenkins\design-triggered\source_code\engine\plugins\glue\XPCallbacks.cpp:2658
--=={This application has crashed!}==--
Technically all done.
But we'll need to fix a shortcoming in logging, especially in picking the network time, with which all log lines start: In the current implementation there is no guarantee that the cached value is update before the first fetch in a new flight loop cycle. Rather, update is called from fixed points. That means that sometimes messages are logged with outdated network time stamps if they happen before the update is called.
We probably need to handle the cache differently: Always fetch the dataRef and update the cache value when in main thread.
Describe the bug Calling X-Plane SDK functions from outside XP's main thread is and has always been forbidden. A recent crash unveiled that there might be overlooked examples.
Ben Supnik in a mail also very clearly stated that restrictions might be enforced even more in future versions:
In the above mentioned case, calls to
SHOW_MSG
were handled by deferring creation of the message area window.Todo
std::async
and friends:FetchAllData
,ProcessFetchedData
, andDoDisabledProcessing
dataRefs.GetViewPos()
, which usesXPLMReadCameraPosition
andXPLMLocalToWorld
To be changed centrally:
LOG_MSG
centrally by keeping a backlog of texts to write out toXPLMDebugString
. Should be combined with message handling in the upcoming information window #121 as that will require a list of message anyway. Keep a flag in there if it had been written out toLog.txt
already or not.XPMP2::Aircraft::SetInvalid()
subsequently callsXPLMDestroyInstance
(this is currently already causing crashes).XPMP2::Aircraft::DestroyInstances
setting a flag if not in main thread.XPLMGetData...
but only if using historic data (ie. not urgent, historic data not currently supported)Technical Info:
Additional Info Blog post on thread-validation in Beta 14