Multithreading support for graphical classes such as TCanvas

ROOT Version: Any
Platform: Any
Compiler: Any

I am having a hard time trying to run ROOT in a multithreaded environment.
I can use all the ROOT non-graphical classes (such as TTree) with a certain degree of success,
but ROOT breaks horribly as soon as I try to use the graphical functions such as TCanvas.
Please notice that in my scripts I never print to screen (or intend to print to screen). I just would like to save plots to png file.

Until now all my efforts have been vain. I am not giving any further info because the problem occurs on every single machine and every single ROOT version that I tried, but do notice that I am not using the ROOT TThread class but just the Python threading library.

Should I use the ROOT TThread class for better support of multithreaded graphical functions?

If you think there is a way and it is possible, please give me a hint and I will try to write a code sample to show you.

Any help is appreciated.

This was addressed here I think.

1 Like

Thank you very much for the link.
I did not understand all the details but it seems that the conclusion is that it is not supported yet.

Correct me if I am wrong, but my understanding is that ROOT needs to allocate some global objects and variables to make the Cling interpreter possible.

I understand that Cling is a nice and useful feature and all … but I would give it up 100 times, if this would result in better multithreading support. That’s just my two cents …

Now it is Cling not CINT. But it is still the same . ROOT has globals like gPad which I think prevent to have multithreading. May be somebody knowing more about multithreading can give more details.

@linev Doesn’t the new GUI address this?

Yes, new RCanavas class will be thread safe - with some limitations.
Idea that each instance of RCanvas can be used safely in separate thread.
But it will be not possible to use same RCanvas from different threads without extra locking.
But RCanvas class is still in development phase - we do have only very basic drawing of several classes.

1 Like

I am very very pleased to learn that this issue is being addressed. Thank you very much for letting me know. Keep up the good work. I am looking forward to use the new RCanvas.

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