[vtkusers] VTK 6.1 on Mac: from JDK 6 to JDK 8, compilation notes and changes in window handling
Alexandre Dufour
adufour at pasteur.fr
Wed Apr 9 14:32:46 EDT 2014
Hi everyone,
We are using VTK via Java for 3D rendering purposes in the open-source Icy platform for bioimaging (http://icy.bioimageanalysis.org), and it has been a great experience so far (especially on Windows). Less so on Mac however, mostly due to Apple’s custom JVM implementation (1.6) messing with the lightweight/heavyweight thingy, and the dramatic changes when switching to Java 1.8 (Oracle).
— The story starts when compiling VTK with Java bindings (after I installed Oracle’s JDK 8 on Mavericks 10.9.2, Xcode 5.1). At runtime, vtk viewers that used to work under JDK 6 suddenly cause a bad crash (note that this also happened with Oracle’s JDK 7):
_NSJVMLoadLibrary: NSAddLibrary failed for /libjawt.dylib
JavaVM FATAL: lookup of function JAWT_GetAWT failed. Exit
— I figured VTK probably wasn’t properly talking to JDK 8, and noticed in CMakeLists that the JAVA_XXX flags were pointing to some weird bits of Java frameworks inside Xcode (in a MacOS10.9 resource bundle), therefore I changed them to:
JAVA_AWT_INCLUDE_PATH /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/include
JAVA_AWT_LIBRARY /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/libjawt.dylib
JAVA_INCLUDE_PATH /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/include
JAVA_INCLUDE_PATH2 /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/include/darwin
— This change wouldn’t compile anymore, due to the following line (appears twice in Wrapping/Java/vtkJavaAwt.h):
temp0->SetWindowId(dsi_mac->cocoaViewRef);
(problem: the cocoaViewRef field does not exist anymore). Commenting this line however resumes compilation (but could cause the issue below).
— Once compiled, I took the sample code from this web site: http://www.particleincell.com/blog/2011/vtk-java-visualization/. Here is the outcome:
— — Under JDK 6: the vtk panel nicely sits “inside” the main frame, where it is supposed to be (expected behaviour).
— — Under JDK 8, the vtk panel opens in a new (native Mac) window entitled “Visualization Toolkit - Cocoa #1”, while the main frame sits there with all other UI components, except the center zone is empty (it is like “sucked away” into the native window:)). Additionally, the Apple toolkit at runtime is complaining with the following console warning:
2014-04-09 19:05:10.178 java[2935:790f] Cocoa AWT: Not running on AppKit thread 0 when expected. (
0 libawt_lwawt.dylib 0x00000001255c3887 -[AWTWindow windowDidResignKey:] + 40
1 CoreFoundation 0x00007fff90f8ce0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
2 CoreFoundation 0x00007fff90e80a6d _CFXNotificationPost + 2893
3 Foundation 0x00007fff862bb7ba -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
4 AppKit 0x00007fff89156760 -[NSWindow resignKeyWindow] + 702
5 AppKit 0x00007fff8905b363 -[NSWindow _changeKeyAndMainLimitedOK:] + 768
6 AppKit 0x00007fff89053856 -[NSWindow _makeKeyRegardlessOfVisibility] + 100
7 AppKit 0x00007fff890537c0 -[NSWindow makeKeyAndOrderFront:] + 29
8 libvtkRenderingOpenGL.jnilib 0x000000012c854d71 _ZN20vtkCocoaRenderWindow13CreateAWindowEv + 2113
9 libvtkRenderingOpenGL.jnilib 0x000000012c855af8 _ZN20vtkCocoaRenderWindow10InitializeEv + 344
10 libvtkRenderingOpenGL.jnilib 0x000000012c851e6d _ZN20vtkCocoaRenderWindow5StartEv + 29
11 libvtkRenderingCore.jnilib 0x0000000129db9fad _ZN15vtkRenderWindow14DoStereoRenderEv + 29
12 libvtkRenderingCore.jnilib 0x0000000129db9f6c _ZN15vtkRenderWindow10DoFDRenderEv + 1612
13 libvtkRenderingCore.jnilib 0x0000000129db98fd _ZN15vtkRenderWindow10DoAARenderEv + 1837
14 libvtkRenderingCore.jnilib 0x0000000129db8ec2 _ZN15vtkRenderWindow6RenderEv + 2418
15 libvtkRenderingCoreJava.jnilib 0x0000000129b2f291 Java_vtk_vtkRenderWindow_Render_19 + 49
16 ??? 0x000000010ec0a66e 0x0 + 4542473838
17 ??? 0x000000010ebfd2e0 0x0 + 4542419680
In both cases, the viewers behave identically.
I apologise for the long post, but I assume this is sufficiently complete to describe and reproduce the problem.
Has anyone experienced this lately? Any hints on why the behaviour is different? I could not find any similar issue on the forum…
Many thanks for your attention, and looking forward to updates on the Mac port!
Best wishes
Alexandre
---
Alexandre Dufour, Ph.D.
Institut Pasteur - Bio Image Analysis Group
25, rue du Docteur Roux, Paris, France
Research: http://www.bioimageanalysis.org/dufour
Software: http://icy.bioimageanalysis.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140409/14eb9e4e/attachment.html>
More information about the vtkusers
mailing list