LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Starves CPU core when zoom factor of a picture indicator is changed through property nodes.

Hi,

 

I have designed a LabVIEW application that generates a Map drawing and displays it as a picture indicator. I added a zoom functionality into this picture using property nodes 'Zoom Factor' method.

The issue is whenever I zoom into the picture the logical processor of my CPU on which the LabVIEW UI thread is running starves and slows down the whole application. The more I zoom into the picture the more prominent this effect is. I have tried multiple methods to shift the load from UI thread to processing thread but the issue persists. As soon as I zoom into the picture even if the core is completely free it get completely utilized by LabVIEW and slows down other loops running in parallel. Kindly help me out on this issue what could be the root cause?

 

Regards,

Nouman.

0 Kudos
Message 1 of 15
(1,159 Views)

As a first step, attach a simplified VI that demonstrates the problem.

 

How big is the "map" (in pixels)? What are the zoom factors you are trying to use? How big is the picture indicator?

If you are zooming with a slider and a value change event, how is the event queue configured? (see also)

0 Kudos
Message 2 of 15
(1,123 Views)

I'm guessing that, because LabVIEW uses unaccelerated graphics to draw stuff, resizing is done on the CPU.  Further following this rabbit wherever it goes, I would further assume that, since it is front panel related, it has to occur in the UI thread.  Lots of guesses, and maybe leaning a bit more towards "wild" than "educated".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 15
(1,086 Views)

Hi,

 

I am attaching a drastically simplified VI that shows the implementation I have used. Although the issue is not visible in this VI you can get an idea of it. In my original application I have used an event based producer consumer architecture. To answer your questions the image is 895x895 pixels,

the zoom factors I use are 1x up to 4x, The picture indicator is the same size as the image map drawn. I am zooming in using mouse wheel event, the queue size is configured to be 5. I have also attached the screenshot that shows the logical core being starved while zooming.

 

Edit: The image generated in the VI is a simple square that's why the issue might not be prominent but when checked with real map data after pasting it onto the picture indicator I was able to reproduce the issue in this simplified VI as well.

Download All
0 Kudos
Message 4 of 15
(1,054 Views)

Unless you do a "save for previous" (2020 or below), I won't be able to look at your code for a while.

0 Kudos
Message 5 of 15
(1,016 Views)

@NoumanFaheem wrote:

I have also attached the screenshot that shows the logical core being starved while zooming.

3.PNG ‏75 KB

 


as Billiko said, this conduct is pretty likely due to the UI  thread root loop:

https://www.genuen.com/blog/the-ui-thread-root-loop-and-labview-what-you-need-to-know/

 

 


@NoumanFaheem wrote:

To answer your questions the image is 895x895 pixels,


this appears to be a reasonable size, but please attach again saved in Labview 2020

 

 

you might try to enable/disable Smooth Updates:

 

 

Spoiler
alexderjuengere_0-1692195633503.png

 

moreover,  the zoom property node appears to switch from resizing (with interpolation) to resizing (without interpolation) when some conditions are met (if smooth updates are enabled)

 

Spoiler


with interpolation without
alexderjuengere_1-1692197072248.png alexderjuengere_2-1692197088705.png

    how to reproduce:
https://forums.ni.com/t5/Example-Code/Conway-s-Game-of-Life-Simulation/ta-p/3521032
Spoiler
resize-resample.gif


 

if you need to zoom into your picture, you might consider to resampling instead of resizing

Message 6 of 15
(1,002 Views)

@NoumanFaheem wrote:

I am zooming in using mouse wheel event, the queue size is configured to be 5.


You should definitely set that to 1. There is absolutely no need to process any zoom value except the last one seen.

 

Events for changes of "analog style" operations (slider change, mouse scroll, cursor move, etc.) can queue up a huge number of events, so if the queue is set to 5, it will process the last five values in order when the movement ends. the first four of those are a complete waste!

 

For illustration, have a look at my ancient example (i.e. before the event queue configuration was available) and set the queue size of the middle event to 1 or 5 and compare.

0 Kudos
Message 7 of 15
(993 Views)

@NoumanFaheem wrote:

Edit: The image generated in the VI is a simple square that's why the issue might not be prominent but when checked with real map data after pasting it onto the picture indicator I was able to reproduce the issue in this simplified VI as well.


Well, then attach the code with the map data! Is the "map" just a "image" or a huge collection of lines and other drawing objects?

 

In your example, you still lock the panel and don't limit the queue size. So please change that! I think you can also simplify the event case to make it easier to read. There is no reason to hide two identical property nodes in the two cases of a case structure.

 

altenbach_0-1692202440380.png

 

I would also recommend to keep the shift register as an integer (e.g. 2x the zoom factor), and multiply it by 0.5 for the property node. This will avoid accumulation of floating point errors. You probably also want to coerce it to 1 and above in that case (a zoom factor of negative or zero seems unreasonable).

 

Why not do it exponential (half or double the zoom factor with each step, for example.)

 

altenbach_0-1692203172739.png

 

( ... and please don't maximize front panel and diagram to the screen. That's extremely annoying)

 

Message 8 of 15
(978 Views)

The VI was created just to give you an idea of the implementation that's why it's in such a crude form. The Map data is actually a huge collection of lines and other drawing objects which for obvious reasons I can't share on this platform. I have tried these optimizations you mentioned in the last two messages but it doesn't improve the performance.

0 Kudos
Message 9 of 15
(934 Views)

Hi the actual question is why doesn't the core utilization go back to normal after it has zoomed the picture. if it goes back to normal it won't starve the UI thread. Also is there way to shift it from UI to processing thread?

 

I enabled/disabled smooth updates but it doesn't do any good.

Resampling is not a possibility for me as the image is drawn at run time and redrawing it every time I zoom would slow down the process even more.

 

 

0 Kudos
Message 10 of 15
(932 Views)