VTK + Java + Mac + Swing

Compiling on a Mac (Catalina) with Java bindings, the following error is produced:
2020-03-10 18:39:49.820 java[89250:2491420] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! when launching from Eclipse.

Running with the JVM option -XstartOnFirstThread solves the problem, but causes the Swing based GUI to block.

Has anyone run into this issue ?

Hello.
Are you using JOGL as the method used by VTK to render to Java panels?

As far as I know, starting from Java 7 (JDK 1.7, i.e., the first non-Apple JDK on MacOS), VTK won’t be able to “directly” render to Java panels through the JAWT interface, due to some changes in the JDK packages/classes and in the related native interfaces.
Hence, right now, the only option left to use VTK with Java on MacOS is by using JOGL (at least, if you need VTK rendering / interaction functionalities).

So, you will need to download JOGAMP, and then build VTK with JOGL options enabled and related CMake settings appropriately setup.

Are you already working this way, i.e., with JOGL?

Regards,

Marco

Yes, I’m using JOGL.
In order to run I need the -XstartOnFirstThread jvm option, but apparently Swing doesn’t like that.
I didn’t manage to find a working example of this combination of Java Swing + VTK under OSX.

Hello,

I will also need to “fight” with VTK + Java + JOGL + Swing on Mac in the upcoming weeks, so maybe I will be able to share my experience on that environment as well.

As of now, I am working with JOGL on Windows, and I am already encountering some issues unfortunately (see Rendering/interaction issues with VTK 8.2 (Java) + JOGL on Windows for details).

Regarding your problem, you told that the Swing GUI will block if you launch your application with the “-XstartOnFirstThread” JVM parameter. Can you provide more details? When will the Swing GUI block? As soon as the Swing GUI shows up on screen? Will it lock forever, or what?

Please provide some more details, I will check if I have suggestions to provide.

Also, you may want to take a look at this thread:

Not sure if this user was indeed using Swing in his application, but it looks like he was successful in having VTK 8.2 + Java + JOGL to work under macOS.

Best regards,

Marco Sambin

That warning comes from JOGL. I have built 8.2 with more bleeding edge jogl jars and that warning goes away. I’m curious what the 9.0 build will depend on (assuming they have java bindings enabled). I’ll try to update my other thread with some details in the next few days as to what needs to be done, and also put in a merge request for the changes.

1 Like