Multithreading with graphics on el capitan

Dear ROOTers,

I recently updated to mac os 10.11 (el capitan) and have an issue with previously running code. The issue appears to be that running a TApplication inside a thread which is not the main thread causes persistent graphics not to be displayed (at least in compiled code). I attach a minimal working example (compiler commands listed below for completeness).

In the example attached if the TApplication is run in the main thread (commented out) then the TCanvas is displayed. If it is instead run in the TThread, nothing is displayed, and the program crashes on completion. In the list of running programs a graphics icon does appear to be listed (with name ‘test’), but no actual canvas is produced. I have tried both the latest root versions 5.34/36 and 6.04/16. Running with root 5.34/34 on linux (SLC 6) produces the TCanvas regardless of where the TApplication is run.

Is it possible that this is an issue of the operating system which still needs addressing? Or am I doing something obviously wrong?

Many thanks in advance,
Daniel

compilation commands:
g++ root-config --cflags -c multithreadingTest.C -o multithreadingTest.o
g++ -o test multithreadingTest.o root-config --glibs
multithreadingTest.C (707 Bytes)

I tried your program on Mac.

With the latest ROOT version.

With the X11 backend I get a white canvas and:

$ ./multithreadingTest 
Making new application
Making new canvas
Running app
Running app in thread
Sleeping
Warning in <TCanvas::Constructor>: Deleting canvas with same name: TrackCanvas
multithreadingTest(25257,0x7fff74b16000) malloc: *** error for object 0x7f84c542cdc0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

with the Cocoa backend I get no canvas and:

$ ./multithreadingTest  
Making new application
Making new canvas
Running app
Running app in thread
Sleeping
Warning in <TCanvas::Constructor>: Deleting canvas with same name: TrackCanvas
2016-04-08 13:28:50.886 multithreadingTest[25096:736800] Fatal error: requested non-existing drawable 99
2016-04-08 13:28:50.886 multithreadingTest[25096:736800] This window not found among allocated/deleted drawables

 *** Break *** segmentation violation
[<unknown binary>]
[<unknown binary>]
[/Users/couet/git/roottrunk-bin/lib/libGpad.so] TCanvas::SetDoubleBuffer(int) /Users/couet/git/roottrunk/graf2d/gpad/src/TCanvas.cxx:1868

Do you know with backend you are using ? the default one is cocoa now. May be you should go back to X11. To do that you need to configure ROOT with:

make -Dcocoa=OFF -Dx11=ON

Hi,

Thanks a lot! I downloaded the binaries for both root versions (cocoa is the default for binaries? Will this change?). I have now compiled the source code with x11 and everything seems to be back to normal.

Thanks again for your help,
Daniel

Ah ok… so that’s really a Cocoa issue… thanks

The author of the cocoa back end replied me: