TheAliceProject / alice3

The Alice 3 block-based IDE desktop application. Also contains a NetBeans plugin to extend development into java.
https://www.alice.org/
Other
154 stars 23 forks source link

New Project, NSWindow and the Main Thread #150

Open justingeeslin opened 4 years ago

justingeeslin commented 4 years ago

Running Alice with mvn exec:java -Dentry-point is successful and the IDE window is shown.

When in the Select Project window, I select ‘Grass’ and click OK, the Alice IDE crashes saying, 'NSWindow drag regions should only be invalidated on the Main Thread!’ (Full details captured below)

Attempting to solve this issue, I read that you might add a Java VM argument -XstartOnFirstThread, but with this the IDE window is never shown.

Any ideas? Thanks again for the help!

``` /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/bin/java Application Specific Information: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!' abort() called terminating with uncaught exception of type NSException Application Specific Backtrace 1: 0 CoreFoundation 0x00007fff33422b57 __exceptionPreprocess + 250 1 libobjc.A.dylib 0x00007fff6c2695bf objc_exception_throw + 48 2 CoreFoundation 0x00007fff3344b34c -[NSException raise] + 9 3 AppKit 0x00007fff306455ec -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 310 4 AppKit 0x00007fff3062d052 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416 5 AppKit 0x00007fff3062cac3 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42 6 libnativewindow_macosx.jnilib 0x00000001355263fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398 7 ??? 0x00000001192146c7 0x0 + 4716578503 ```
dabeshouse commented 4 years ago

Running with a slightly older version of java (1.8.0_162-b12) the issue is reported as a warning, with the phrase "This will throw an exception in the future".

It seems that future arrived somewhere between 162 & 261, or some other difference between the two machines. What version of the OS are you running?

I will see what we can do to get on the proper thread.

2020-08-26 11:21:03.847 java[59169:3175375] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
        0   AppKit                              0x00007fff2c2b7629 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 371
        1   AppKit                              0x00007fff2c29f052 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
        2   AppKit                              0x00007fff2c29eac3 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
        3   libnativewindow_macosx.jnilib       0x000000012baf63fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
        4   ???                                 0x0000000116cbe667 0x0 + 4677428839
)
justingeeslin commented 4 years ago

I am running MacOS 10.15.5 (Catalina).

dabeshouse commented 4 years ago

I am on 10.15.6, but had run on 10.15.5 before upgrading, so that seems unlikely as the cause. The java version does not seem to be the difference, since there are folks running other jogl using software under java 10 report still getting the less firm "This will throw an exception in the future".

Any chance you have files in /System/Library/Java/Extensions that are jogl or gluegen related?

justingeeslin commented 4 years ago

No, I do not. Just the Mac runtime jar in that directory.

Screen Shot 2020-08-27 at 10 47 21 PM
dabeshouse commented 4 years ago

Looks good to me. Same date on the toolkit I see in my machine. Your bundle is two months newer than what I have, but no discussion I have seen seems to point to that.

When jogl 2.4.0 is released it will contain a fix for the threading issue, but 2.4.0 has been a long time coming with no delivery date set.

I remain unsure why your build is stricter and terminates rather than simply logging a warning.

justingeeslin commented 4 years ago

Thanks for looking into this. I'll try building Alice on a fresh VM of Catalina to see if it is my setup.

steady137 commented 3 years ago

I was seeing this on Big Sur (11.2.3) and was able to continue running with an older JRE, as suggested above. JRE 152 in particular seems bundled by the Alice 3 and running well. Just some notes on getting that going:

  1. Archived versions of JRE can be found from https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html. You'll need an account there. I used jre-8u152-macosx-x64.tar.gz after trying the .dmg because the installer complained that I already had a newer version of Java installed. Unpack it to ~/Downloads/jre1.8.0_152.jre.
  2. $ sudo mv ~/Downloads/jre1.8.0_152.jre /Library/Java/JavaVirtualMachines/
  3. Verify it's installed for use:
    $ /usr/libexec/java_home -v 1.8.0_152
    /Library/Java/JavaVirtualMachines/jre1.8.0_152.jre/Contents/Home
  4. Change your Java version to 152: $ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jre1.8.0_152.jre/Contents/Home
  5. Per this advice, remove the quarantine attribute from the unsiged code: $ xattr -d com.apple.quarantine /Library/Java/JavaVirtualMachines/jre1.8.0_152.jre
  6. Now from alice-ide you can run it (using maven 3.6.3 only): $ ~/bin/apache-maven-3.6.3/bin/mvn exec:java -Dentry-point

Hope that helps.