<div dir="ltr">Hi all,<div><br></div><div>I made some experiments with VTK + JOGL in the recent past. I managed to make it work (more or less) on several platforms including Mac, but as far as I remember I had some issues with the size of the viewport on the output panel, and I abandoned the effort at that time: I did not have much time to spend on that topic; moreover, my VTK-based application was a Java Web Start application, and the overhead of including JOGL with it was not completely acceptable.</div>
<div><br></div><div>I will probably come back to the "VTK + Mac" topic in the near future. </div><div><br></div><div><div class="gmail_extra"><div>In the release notes of Java 7u40 (<a href="http://www.oracle.com/technetwork/java/javase/2col/7u40-bugfixes-2007733.html">http://www.oracle.com/technetwork/java/javase/2col/7u40-bugfixes-2007733.html</a>) among other points, I can see:</div>
<div><br></div><div>[...]</div><div>(Bug fix): NSView-based implementation of sun.awt.EmbeddedFrame</div><div>[...]</div><div><br></div><div>So basically, recent versions of Java 7 offer again compatibility with "NSView JAWT embedding", which is the kind of JAWT embedding traditionally supported by VTK. The same holds true with the recently-released Java 8.</div>
<div><br></div><div>Now, though I am not a Mac expert as a developer, from the information that I gathered, some changes will still need to be applied to VTK to make it work with the latest Java 7 / Java 8. For instance, the NSView-based subclass of sun.awt.EmbeddedFrame was previously "<span style="color:rgb(0,0,0);font-size:12px;white-space:pre-wrap">apple.awt.CEmbeddedFrame</span>" (in Apple's Java 6, which worked with VTK), while now it should be "<span style="color:rgb(0,0,0);white-space:pre-wrap">sun.lwawt.macosx.CViewEmbeddedFrame</span>". Hence, at least some naming should be fixed. Then, it is likely that some methods signatures have slightly changed. Overall, it should be possible to make VTK work again "directly" with the latest Java 7 / Java 8, without the need for JOGL. This would be a very important step in my opinion.</div>
<div><br></div><div>Again, although I am not a Mac expert as a developer, I am willing to dedicate some efforts on this in the near future, if some of you (maybe Seb?) could point me to the points in VTK where these JAWT Mac classes are referenced, in such a way I could maybe make some experiments with the re-introduced NSView-based classes.</div>
<div><br></div><div>Thank you in advance for your feedback.</div><div>Best regards,</div><div><br></div><div>Marco Sambin</div><div><br></div><br><div class="gmail_quote">On Wed, Apr 9, 2014 at 9:49 PM, Alexandre Dufour <span dir="ltr"><<a href="mailto:adufour@pasteur.fr" target="_blank">adufour@pasteur.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="auto"><div>Thanks Sebastien for the fast and detailed answer.</div>
<div><br></div><div>Indeed it seemed to me like a known issue (especially the light / heavy weight one), but my searches didn't bring me far enough I guess.</div>
<div><br></div><div>Will switch to OpenGL panels as soon as possible!</div><div><br></div><div>Alexandre<br><br></div><div>On 9 avr. 2014, at 20:09, Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>> wrote:<br>
<br></div><blockquote type="cite"><div><div dir="ltr">Hi Alexandre,<div><br></div><div>So your problem is a somewhat well known issue. Basically Oracle Java 7 and 8 changed their API with the Cocoa code which break the old rendering technique used for Java.</div>
<div>To overcome that issue we provide a vtkJoglPanel / vtkJoglCanvas where VTK handle the OpenGL code and we let the JOGL code do the graphical integration.</div><div><br></div><div>To enable them, you will need to get JOGL and build VTK with it with additional options and paths.</div>
<div>But we are in the process of providing binaries of VTK for each platform in an automatic manner. Unfortunately that process is not complete yet, but you can download those binaries from the web by going to the VTK dashboard (<a href="http://open.cdash.org/index.php?project=VTK" target="_blank">http://open.cdash.org/index.php?project=VTK</a>) and downloading the generated files by clicking on the yellow box.</div>
<div><br></div><div>Also another known issue is that altair.kitware does not properly compile the Java files, which means that it's generic vtk-6.0.1.jar does not contains any class files.</div><div>But you can get that same file from any other platform.</div>
<div><br></div><div>Here is how you can try those binaries:</div><div><br></div><div># Use maven to download the JOGL dependencies</div><div><div>$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=<a href="http://repo1.maven.org/maven2" target="_blank">http://repo1.maven.org/maven2</a> -Dartifact=org.jogamp.gluegen:gluegen-rt:2.0.2</div>
<div>$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=<a href="http://repo1.maven.org/maven2" target="_blank">http://repo1.maven.org/maven2</a> -Dartifact=org.jogamp.jogl:jogl-all:2.0.2</div></div>
<div><br></div><div>
<span style="font-family:arial,sans-serif;font-size:13px">1) Download and uncompress the native jar into a /.../lib directory.</span></div><div style="font-family:arial,sans-serif;font-size:13px">2) export DYLD_LIBRARY_PATH=/.../lib</div>
<div style="font-family:arial,sans-serif;font-size:13px">3) java -cp vtk-6.1.jar:/Users/seb/.m2/repository/org/jogamp/jogl/jogl-all/2.0.2/jogl-all-2.0.2.jar:/Users/seb/.m2/repository/org/jogamp/gluegen/gluegen-rt/2.0.2/gluegen-rt-2.0.2.jar vtk.sample.rendering.JoglConeRendering</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Hope that helps,</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
Seb</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 9, 2014 at 12:32 PM, Alexandre Dufour <span dir="ltr"><<a href="mailto:adufour@pasteur.fr" target="_blank">adufour@pasteur.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">Hi everyone,<div><br></div>
<div>We are using VTK via Java for 3D rendering purposes in the open-source Icy platform for bioimaging (<a href="http://icy.bioimageanalysis.org" target="_blank">http://icy.bioimageanalysis.org</a>), 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). </div>
<div><br></div><div>— 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):</div>
<div><div><span style="white-space:pre-wrap"> </span>_NSJVMLoadLibrary: NSAddLibrary failed for /libjawt.dylib</div><div><span style="white-space:pre-wrap"> </span>JavaVM FATAL: lookup of function JAWT_GetAWT failed. Exit</div>
</div><div><br></div><div>— 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:</div>
<div><span style="white-space:pre-wrap"> </span>JAVA_AWT_INCLUDE_PATH<span style="white-space:pre-wrap"> </span>/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/include <br>
<span style="white-space:pre-wrap"> </span>JAVA_AWT_LIBRARY<span style="white-space:pre-wrap"> </span>/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/libjawt.dylib <br>
<span style="white-space:pre-wrap"> </span>JAVA_INCLUDE_PATH<span style="white-space:pre-wrap"> </span>/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/include <br>
<span style="white-space:pre-wrap"> </span>JAVA_INCLUDE_PATH2<span style="white-space:pre-wrap"> </span>/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/include/darwin</div><div><br></div><div>— This change wouldn’t compile anymore, due to the following line (appears twice in Wrapping/Java/vtkJavaAwt.h):</div>
<div><span style="white-space:pre-wrap"> </span>temp0->SetWindowId(dsi_mac->cocoaViewRef);</div><div>(problem: the cocoaViewRef field does not exist anymore). Commenting this line however resumes compilation (but could cause the issue below).</div>
<div><br></div><div>— Once compiled, I took the sample code from this web site: <a href="http://www.particleincell.com/blog/2011/vtk-java-visualization/" target="_blank">http://www.particleincell.com/blog/2011/vtk-java-visualization/</a>. Here is the outcome:</div>
<div><br></div><div>— — Under JDK 6: the vtk panel nicely sits “inside” the main frame, where it is supposed to be (expected behaviour).</div><div><br></div><div>— — 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:</div>
<div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo">2014-04-09 19:05:10.178 java[2935:790f] Cocoa AWT: Not running on AppKit thread 0 when expected. (</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>0 libawt_lwawt.dylib 0x00000001255c3887 -[AWTWindow windowDidResignKey:] + 40</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>1 CoreFoundation 0x00007fff90f8ce0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>2 CoreFoundation 0x00007fff90e80a6d _CFXNotificationPost + 2893</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>3 Foundation 0x00007fff862bb7ba -[NSNotificationCenter postNotificationName:object:userInfo:] + 68</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>4 AppKit 0x00007fff89156760 -[NSWindow resignKeyWindow] + 702</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>5 AppKit 0x00007fff8905b363 -[NSWindow _changeKeyAndMainLimitedOK:] + 768</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>6 AppKit 0x00007fff89053856 -[NSWindow _makeKeyRegardlessOfVisibility] + 100</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>7 AppKit 0x00007fff890537c0 -[NSWindow makeKeyAndOrderFront:] + 29</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>8 libvtkRenderingOpenGL.jnilib 0x000000012c854d71 _ZN20vtkCocoaRenderWindow13CreateAWindowEv + 2113</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>9 libvtkRenderingOpenGL.jnilib 0x000000012c855af8 _ZN20vtkCocoaRenderWindow10InitializeEv + 344</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>10 libvtkRenderingOpenGL.jnilib 0x000000012c851e6d _ZN20vtkCocoaRenderWindow5StartEv + 29</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>11 libvtkRenderingCore.jnilib 0x0000000129db9fad _ZN15vtkRenderWindow14DoStereoRenderEv + 29</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>12 libvtkRenderingCore.jnilib 0x0000000129db9f6c _ZN15vtkRenderWindow10DoFDRenderEv + 1612</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>13 libvtkRenderingCore.jnilib 0x0000000129db98fd _ZN15vtkRenderWindow10DoAARenderEv + 1837</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>14 libvtkRenderingCore.jnilib 0x0000000129db8ec2 _ZN15vtkRenderWindow6RenderEv + 2418</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>15 libvtkRenderingCoreJava.jnilib 0x0000000129b2f291 Java_vtk_vtkRenderWindow_Render_19 + 49</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>16 ??? 0x000000010ec0a66e 0x0 <a href="tel:%2B%204542473838" value="+4542473838" target="_blank">+ 4542473838</a></div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>17 ??? 0x000000010ebfd2e0 0x0 <a href="tel:%2B%204542419680" value="+4542419680" target="_blank">+ 4542419680</a></div></div><div><br></div><div>
<br></div><div>In both cases, the viewers behave identically.</div><div><br></div><div>I apologise for the long post, but I assume this is sufficiently complete to describe and reproduce the problem.</div><div>Has anyone experienced this lately? Any hints on why the behaviour is different? I could not find any similar issue on the forum…</div>
<div><br></div><div>Many thanks for your attention, and looking forward to updates on the Mac port!</div><div><br></div><div>Best wishes</div><div>Alexandre</div><div><br><div>
<div style="text-indent:0px;letter-spacing:normal;text-align:start;text-transform:none;white-space:normal;word-wrap:break-word;word-spacing:0px"><div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;white-space:normal;font-family:Didot;word-wrap:break-word;word-spacing:0px">
<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;white-space:normal;font-family:Didot;word-wrap:break-word;word-spacing:0px">
<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;white-space:normal;font-family:Didot;word-wrap:break-word;word-spacing:0px">
<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;white-space:normal;font-family:Didot;word-wrap:break-word;word-spacing:0px">
<div style="font-size:16px">---</div><div style="font-size:16px"><div>Alexandre Dufour, Ph.D.</div><div>Institut Pasteur - Bio Image Analysis Group</div><div>25, rue du Docteur Roux, Paris, France</div></div><div style="font-size:16px">
Research: <a href="http://www.bioimageanalysis.org/dufour" target="_blank">http://www.bioimageanalysis.org/dufour</a></div><div style="font-size:16px">Software: <a href="http://icy.bioimageanalysis.org" target="_blank">http://icy.bioimageanalysis.org</a></div>
</div></div></div></div></div>
</div>
<br></div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
</div></blockquote></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div></div></div>