What is CoherentGTUI Thread?

Hi Team, The FPS debug window shows CoherentGTUI Thread among other
information, can you please let me know what it is? I am developing gquges and
systems in JS for an aircraft we are creating and some testers who have low-
end CPUs say this CoherentGTUI Thread is often red with high values. They also
see micro-stutters in the sim animation. I would like to optimize my code to
avoid this but I don’t know where to start… because I don’t know what these
value represent. Of course I have a lot of Coherent.calls in my code, but
reducing them by ignoring parts of the code didn’t change much. Thanks for
your help.

1 Like

The time represented there is the total amount of time it takes to run all
JavaScript code for the aircraft. The JS code in the sim runs in parallel on a
separate thread, and all JS instruments run in sequence on this thread each
glass cockpit update frame. So if you are seeing large stutters and spikes, it
is likely that the aircraft’s JS code needs to be optimized. This could be
anything from issues with the algorithms, to generating too much garbage per
frame and the GC is doing a lot of collecting, to doing too much re-layout of
the DOM each frame, etc. In general, when you see spikier loads, it tends to
make me think a lot of DOM or HTML Canvas work being done that frame, or that
your code is generating a lot of objects that need to be GC’d and the GC is
coming along collecting them every while.

Thanks for the info. I use HTML canvas for my JS instruments, I don’t touch
the DOM at all. As far as I know there shouldn’t be so much GC because I use
few dynamic variables, but I will check this again. In fact I have all the
most important instruments in the same VCockpit section, do you think it can
explain this issue? Would it be better if the instruments were split into
several cockpit sections instead? Does the sim use a thread for each VCockpit
section or use 1 thread for all?

What Matt is saying is, be sure your code is not updating HTML components all
the time on every single frame. This causes lots of performance issues,
instead update HTML components only when required (such as, a variable changed
with enough variations to consider doing a change for example, and avoid
refreshing on each frame, there is not need for that…). Best, Raul

I understood this. I’m sorry if my reply was not clear but I can tell I almost
never update HTML components. I do it only once per instrument for
initialization purpose, so I can say this is not the reason for the spikes. It
may be garbage collection, especially if it is done for each frame, and it can
also be because most instruments are in the same cockpit section.

Even if I understand the number shown for CoherentGTUI Thread, I don’t
understand why it is much lower when the aircraft is on the ground than when
it is in flight. My JS instruments don’t use more CPU in flight than on the
ground… Do you have any idea?

Forget my question, I found the reason the the GTUI thread that took so much
time. There was a small bug that had big consequences, now fixed. I thank you
for your help in finding it.