EulalieCoevoet / AdaptiveMerging

With adaptive merging we reduce computation time in rigid body simulations.
https://eulaliecoevoet.github.io/AdaptiveMerging/
42 stars 11 forks source link

How to run src/mergingBodies3D/LCPApp3D on Mac OSX? #35

Open alecjacobson opened 4 years ago

alecjacobson commented 4 years ago

I'm looking forward to trying this demo. Thank you for sharing the code.

The README.md mentions running the app src/mergingBodies3D/LCPApp3D. I can't find that file. I do find src/mergingBodies3D/LCPApp3D.java, but it's been a long time since I've compiled/run java code.

I tried issuing javac src/mergingBodies3D/LCPApp3D but I got 100s of errors.

What's the right way to build/run the 3D demo?

paulkry commented 4 years ago

I'm not one to try these things on the command line. Are you using oracle java? 1.8 is recommended due to the JOGL opengl bindings. The release has all the class files in a jar, and can be run if you just want to give it a spin, otherwise it is perhaps easiest to open it up in an IDE.

Here is a link to the release: https://github.com/EulalieCoevoet/AdaptiveMerging/releases/tag/20.05

alecjacobson commented 4 years ago

This got farther!

I downloaded the zip from that release then double-clicked on AdaptiveMerging.jar.

This window briefly appears, then disappears and the app closes. Not sure how to debug this.

Screen Shot 2020-08-18 at 2 55 14 PM

I downloaded java from here https://www.oracle.com/java/technologies/javase-jdk14-downloads.html . I'm on a new mac laptop.

paulkry commented 4 years ago

oops... seems the release zip is missing the readme we included at submission time (the link for the JDK download). You shouldn't need to do anything more than click on the jar (would think java 1.8 would be best for JOGL). But that said, I wonder if the OSX migration away from opengl could be a problem. We've only tested on windows, and I suspect our gentle use of GLSL for shadows might be the thing that prevents the 3D view from opening (i.e., we use a compatability profile for Opengl... best mix of old and new). So much for cross platform simplicity of Java. Do you have a linux or windows machine on which to give it a spin?

alecjacobson commented 4 years ago

Other opengl apps (via C++) work OK on this mac. For example, if I compile and run https://github.com/alecjacobson/glversion I see

OpenGL version 4.1.0

Supported OpenGL is 4.1 INTEL-14.7.8

Supported GLSL is 4.10

paulkry commented 4 years ago

Yeah, the real issue is that we're not using a core OpenGL profile. I should really take the time to weed out all the old school OpenGL stuff from my code so we can drop the need for a compatability profile (there are probably not too many glBegins in the code, but they are there... for drawing points?). I think the JOGL OSX bindings will still work... Otherwise, perhaps we'll update the code to check if running on a MAC to turn off the GLSL shadow code.

EulalieCoevoet commented 4 years ago

Hi Alec,

Thank you for reporting this issue!

We just made some changes to the code for MacOS. With the latest version you should be able to run the app, and see the objects merge as you go through the examples. Unfortunately, it seems that the picking (interaction with the objects in the scene) may not work on MacOS, we're trying to fix that issue.

alecjacobson commented 4 years ago

Latest version still closes after briefly showing that window. If it would help I could send debug output; I just don't know where/how to get it.

paulkry commented 4 years ago

I might guess that if you are running the release from the command line, i.e., go to the folder and run "java AdaptiveMerging.jar" then it might dump some error messages onto the console? Alternatively, I have also seen that sometimes on macs the 3D view window opens but is super tiny and you need to make it bigger. You could also check that the command line is actually running the right version of java with a "java --version" command. I have two students with Macs that I'm recruiting to help debug this too... we saw it work on one mac so far, but perhaps it is an older machine with older OS and less OpenGL deprecation than your shiny new machine? I'd really like to fix this!

alecjacobson commented 4 years ago

java --version

java 14.0.2 2020-07-14

Java(TM) SE Runtime Environment (build 14.0.2+12-46)

Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

java AdaptiveMerging.jar

Error: Could not find or load main class AdaptiveMerging.jar

Caused by: java.lang.ClassNotFoundException: AdaptiveMerging.jar

[and it doesn't even open the window]

alecjacobson commented 4 years ago

Is this helpful?

java -jar AdaptiveMerging.jar

loading scenes3D/factoryTest2.xml

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (rsrc:jogamp-fat.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)

WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

2020-08-18 19:37:56.057 java[32378:1318348] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'

*** First throw call stack:

(

0 CoreFoundation 0x00007fff37d88b57 __exceptionPreprocess + 250

1 libobjc.A.dylib 0x00007fff70a365bf objc_exception_throw + 48

2 CoreFoundation 0x00007fff37db134c -[NSException raise] + 9

3 AppKit 0x00007fff34fab5ec -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 310

4 AppKit 0x00007fff34f93052 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416

5 AppKit 0x00007fff34f92ac3 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42

6 libnativewindow_macosx.jnilib 0x00000001a7f783fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398

7 ??? 0x0000000111eed6b0 0x0 + 4595832496

)

libc++abi.dylib: terminating with uncaught exception of type NSException

zsh: abort java -jar AdaptiveMerging.jar

paulkry commented 4 years ago

The first warnings are expected, as JOGL is happier with java 1.8, and this MIGHT fix things, but I'm not sure it is worth installing an old version of java at this point on the off chance that it helps.

paulkry commented 4 years ago

I've committed a small program to probe what profiles are available. I've also pushed a runnable jar to make this easier (12 MB simply because it also contains the jogamp fat jar with opengl bindings). Run as "java -jar CheckGLProfiles.jar", and please let me know what you get! On my machine I get:

Default GLProfile is GLProfile[GL4bc/GL4bc.hw] Requested GL4bc Got GLProfile[GL4bc/GL4bc.hw] Requested GL3bc Got GLProfile[GL3bc/GL4bc.hw] Requested GL2 Got GLProfile[GL2/GL4bc.hw] Requested GL4 Got GLProfile[GL4/GL4.hw] Requested GL3 Got GLProfile[GL3/GL4.hw] Requested GLES3 Got GLException Requested GL4ES3 Got GLProfile[GL4ES3/GL4.hw] Requested GL2GL3 Got GLProfile[GL2GL3/GL4bc.hw] Requested GLES2 Got GLException Requested GL2ES2 Got GLProfile[GL2ES2/GL4.hw] Requested GLES1 Got GLException Requested GL2ES1 Got GLProfile[GL2ES1/GL4bc.hw]

Incidentally, I believe the bc endings mean "backwards compatible", so you can do all the cool core stuff in GL4 while mixing it with some glBegin( GL_LINES ) ... glEnd for quick hacking!

alecjacobson commented 4 years ago

On my old mac running Mac OS 10.13, I get:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (rsrc:jogamp-fat.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Default GLProfile is GLProfile[GL2/GL2.hw]
Requested GL4bc Got GLException 
Requested GL3bc Got GLException 
Requested GL2 Got GLProfile[GL2/GL2.hw]
Requested GL4 Got GLProfile[GL4/GL4.hw]
Requested GL3 Got GLProfile[GL3/GL4.hw]
Requested GLES3 Got GLException 
Requested GL4ES3 Got GLProfile[GL4ES3/GL4.hw]
Requested GL2GL3 Got GLProfile[GL2GL3/GL4.hw]
Requested GLES2 Got GLException 
Requested GL2ES2 Got GLProfile[GL2ES2/GL4.hw]
Requested GLES1 Got GLException 
Requested GL2ES1 Got GLProfile[GL2ES1/GL2.hw]

On my new mac running Mac OS 10.15, I get:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (rsrc:jogamp-fat.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-08-22 10:33:01.300 java[41665:3654586] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff37d88b57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff70a365bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff37db134c -[NSException raise] + 9
    3   AppKit                              0x00007fff34fab5ec -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 310
    4   AppKit                              0x00007fff34f93052 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
    5   AppKit                              0x00007fff34f92ac3 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
    6   libnativewindow_macosx.jnilib       0x000000013be373fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
    7   ???                                 0x0000000112f3c6b0 0x0 + 4612933296
    8   ???                                 0x0000000112f369d0 0x0 + 4612909520
)
libc++abi.dylib: terminating with uncaught exception of type NSException
zsh: abort      java -jar ~/Downloads/CheckGLProfiles.jar
paulkry commented 4 years ago

Ok... Thank you! Presuming that was with Java 1.8 on the new Mac, pretty discouraging. It probably runs somewhat now with Eulalie's updates on the old mac, without shadows. Seeing the core GL4 profile gives me incentive to update things... And I see jogl is still active with test builds this year, but the bindings we are using (last release) are now 5 years old, which is probably not helping. I'll leave this issue open (renamed to running on OSX) but I think we might be stuck here for now.