TApplication freeze while updating canvas

Hello,

I build a simple UI made of a couple of tabs. In each tab I display a canvas which is divided into several related 2D histograms read from a ROOT file. This is meant to be an online monitor updating the histogram every time a new file comes.
The problem being that whenever the canvas are updated (with canvas->Update()) after loading the new histogram, the UI completely freezes until this very lengthy operation is finished. In the complete program, this means it is frozen for several minutes, while we would like to still be able to navigate between tabs during that time.

I have made a small working example that I attach. This one works with a TApplication->Run() and the update of the histogram in a separate thread, but I also tried to make my own event loop with gSystem->ProcessEvent() (in its own thread), but that call also hangs during the call to canvas->Update().

Thanks for any help/advice you can provide to make this run more smoothly.

I compiled the executable with

g++ GUI.C `root-config --cflags --libs --glibs`

GUI.C (5.0 KB)


_ROOT Version: 6.16/00
_Platform: CC7
_Compiler: 8.2.0


I guess @bellenot our GUI expert, may have something to say about it.

Hi,

I cannot run your code for the time being, but if you have a tight (and long) loop, try to insert gSystem->ProcessEvent() inside. Note this has to be in the main thread (as you have seen, creating a separate thread with gSystem->ProcessEvent() doesn’t work)

Cheers, Bertrand.

Hi,
I tried to add the gSystem->ProcessEvent() in the slow loop, unfortunately this does not help as the only slow instruction in that loop is the call to canvas->Update(). If I put one before that call and one after, it still freezes for the ~10 seconds that the Update call takes.

I’ll try to see if there is a solution, but if the graphics is the cause of the freeze, I’m afraid there is not much you can do…

Instead of “canvas->Update();” try “canvas->GetPad(iPad)->Update();”

BTW. You have “sleep(10);” there so why are you surprised that it “freezes” for 10 seconds?

1 Like

Just by curiosity how big are your 2D histograms (number of bins) ?
How many do you have in memory ?
I see you are using the default option (scatter plot) to draw them. Have you tried with an other option ? COL ? BOX ?

Yes, the sleep 10 is there to emulate waiting for a new file to be available. But actually during those 10 seconds the UI is actually very responsive. It’s outside that the freezing occurs.

I tried to update every pad separately and it helps indeed. It is not overall faster, but if I click on the interface, the action is done in between the pad updates instead of having to wait that the whole canvas is updated.

The 2D histograms are unfortunately quite big as we have one bin per channel in one dimension, and in this example time fine binning for channel alignment. So the plots here have 3072x2560 bins. We have many of them in memory.

I haven’t tried other drawing options, but they appear drawn with COLZ. I guess they were saved like that in the input ROOT file?

Try COL2 / COLZ2 … it is a faster COL / COLZ.

Thank you. I see a significant improvement with COLZ2. It now takes only a couple of seconds to update all the pads.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.