JDK-8088742 : [Glass, Mac] JVM crashes on Mac OS X after FullScreen mode
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • Submitted: 2014-10-21
  • Updated: 2018-09-06
  • Resolved: 2017-09-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Relates :  
Description
Having a simple app like:

@Override
    public void start(Stage primaryStage) throws Exception {

        Scene scene = new Scene(new Label("Hello WORLD!!"));
        primaryStage.setScene(scene);
        primaryStage.show();

    }

When I run it on Mac OS 10.9.3 and click the fullscreen button (the button in the RIGHT corner with the diagonal arrows), and then return from fullscreen (by navigating to the top right corner and click the minimize button in the menubar), the application crashes with the following output. At least when I start the application out of IntelliJ.

(Tested with JDK 8u5 and 8u25)

2014-10-21 16:23:53.257 java[10323:d07] An uncaught exception was raised
2014-10-21 16:23:53.258 java[10323:d07] CALayer position contains NaN: [960 nan]
2014-10-21 16:23:53.258 java[10323:d07] (
	0   CoreFoundation                      0x00007fff8837425c __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x00007fff8f5b7e75 objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8837410c +[NSException raise:format:] + 204
	3   QuartzCore                          0x00007fff8c07a25e _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 158
	4   QuartzCore                          0x00007fff8c07a1b7 -[CALayer setPosition:] + 44
	5   QuartzCore                          0x00007fff8c07be97 -[CALayer setFrame:] + 858
	6   AppKit                              0x00007fff863f937e -[_NSFullScreenTransitionOverlayWindow positionLayers] + 1790
	7   AppKit                              0x00007fff863fa7e7 -[_NSFullScreenTransitionOverlayWindow startExitFullScreenAnimationWithDuration:completionHandler:] + 51
	8   AppKit                              0x00007fff863fbddb -[_NSFullScreenTransition _startFullScreenTransitionForCGWindow:targetFrame:duration:completionHandler:] + 294
	9   AppKit                              0x00007fff863fef29 -[_NSWindowFullScreenTransition _exitFullScreenModeForWindow:duration:completionHandler:] + 182
	10  AppKit                              0x00007fff85e3cf02 __76-[_NSWindowFullScreenTransition exitFullScreenTransitionForWindow:animated:]_block_invoke + 450
	11  libxpc.dylib                        0x00007fff8e1e1ca2 _xpc_connection_reply_callout + 47
	12  libxpc.dylib                        0x00007fff8e1e1c2e _xpc_connection_call_reply + 36
	13  libdispatch.dylib                   0x00007fff8c81b28d _dispatch_client_callout + 8
	14  libdispatch.dylib                   0x00007fff8c822ef0 _dispatch_main_queue_callback_4CF + 333
	15  CoreFoundation                      0x00007fff882db5a9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	16  CoreFoundation                      0x00007fff882967c4 __CFRunLoopRun + 1636
	17  CoreFoundation                      0x00007fff88295f25 CFRunLoopRunSpecific + 309
	18  HIToolbox                           0x00007fff88ffda0d RunCurrentEventLoopInMode + 226
	19  HIToolbox                           0x00007fff88ffd7b7 ReceiveNextEventCommon + 479
	20  HIToolbox                           0x00007fff88ffd5bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
	21  AppKit                              0x00007fff85b3a26e _DPSNextEvent + 1434
	22  AppKit                              0x00007fff85b398bb -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
	23  AppKit                              0x00007fff85b2d9bc -[NSApplication run] + 553
	24  libglass.dylib                      0x0000000120f20757 -[GlassApplication runLoop:] + 1783
	25  Foundation                          0x00007fff8bced13e __NSThreadPerformPerform + 229
	26  CoreFoundation                      0x00007fff882a5661 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	27  CoreFoundation                      0x00007fff88296d12 __CFRunLoopDoSources0 + 242
	28  CoreFoundation                      0x00007fff8829649f __CFRunLoopRun + 831
	29  CoreFoundation                      0x00007fff88295f25 CFRunLoopRunSpecific + 309
	30  java                                0x0000000107fa86cc CreateExecutionEnvironment + 871
	31  java                                0x0000000107fa465c JLI_Launch + 1952
	32  java                                0x0000000107faa68a main + 101
	33  java                                0x0000000107fa3eb4 start + 52
	34  ???                                 0x0000000000000008 0x0 + 8
)
2014-10-21 16:23:53.258 java[10323:d07] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [960 nan]'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff8837425c __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x00007fff8f5b7e75 objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8837410c +[NSException raise:format:] + 204
	3   QuartzCore                          0x00007fff8c07a25e _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 158
	4   QuartzCore                          0x00007fff8c07a1b7 -[CALayer setPosition:] + 44
	5   QuartzCore                          0x00007fff8c07be97 -[CALayer setFrame:] + 858
	6   AppKit                              0x00007fff863f937e -[_NSFullScreenTransitionOverlayWindow positionLayers] + 1790
	7   AppKit                              0x00007fff863fa7e7 -[_NSFullScreenTransitionOverlayWindow startExitFullScreenAnimationWithDuration:completionHandler:] + 51
	8   AppKit                              0x00007fff863fbddb -[_NSFullScreenTransition _startFullScreenTransitionForCGWindow:targetFrame:duration:completionHandler:] + 294
	9   AppKit                              0x00007fff863fef29 -[_NSWindowFullScreenTransition _exitFullScreenModeForWindow:duration:completionHandler:] + 182
	10  AppKit                              0x00007fff85e3cf02 __76-[_NSWindowFullScreenTransition exitFullScreenTransitionForWindow:animated:]_block_invoke + 450
	11  libxpc.dylib                        0x00007fff8e1e1ca2 _xpc_connection_reply_callout + 47
	12  libxpc.dylib                        0x00007fff8e1e1c2e _xpc_connection_call_reply + 36
	13  libdispatch.dylib                   0x00007fff8c81b28d _dispatch_client_callout + 8
	14  libdispatch.dylib                   0x00007fff8c822ef0 _dispatch_main_queue_callback_4CF + 333
	15  CoreFoundation                      0x00007fff882db5a9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	16  CoreFoundation                      0x00007fff882967c4 __CFRunLoopRun + 1636
	17  CoreFoundation                      0x00007fff88295f25 CFRunLoopRunSpecific + 309
	18  HIToolbox                           0x00007fff88ffda0d RunCurrentEventLoopInMode + 226
	19  HIToolbox                           0x00007fff88ffd7b7 ReceiveNextEventCommon + 479
	20  HIToolbox                           0x00007fff88ffd5bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
	21  AppKit                              0x00007fff85b3a26e _DPSNextEvent + 1434
	22  AppKit                              0x00007fff85b398bb -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
	23  AppKit                              0x00007fff85b2d9bc -[NSApplication run] + 553
	24  libglass.dylib                      0x0000000120f20757 -[GlassApplication runLoop:] + 1783
	25  Foundation                          0x00007fff8bced13e __NSThreadPerformPerform + 229
	26  CoreFoundation                      0x00007fff882a5661 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	27  CoreFoundation                      0x00007fff88296d12 __CFRunLoopDoSources0 + 242
	28  CoreFoundation                      0x00007fff8829649f __CFRunLoopRun + 831
	29  CoreFoundation                      0x00007fff88295f25 CFRunLoopRunSpecific + 309
	30  java                                0x0000000107fa86cc CreateExecutionEnvironment + 871
	31  java                                0x0000000107fa465c JLI_Launch + 1952
	32  java                                0x0000000107faa68a main + 101
	33  java                                0x0000000107fa3eb4 start + 52
	34  ???                                 0x0000000000000008 0x0 + 8
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Comments
Cannot reproduce anymore with OSX 10.12
28-09-2017

Attached is the debugging patch that I used to track into this issue.
03-06-2015

On Undecorated stage, when invoking setFullscreen(true) there's no crash but there no action. Everything worked fine with 8u20, since 8u40 setFullscreen(true) doesn't have any effect on the Stage; Thanks.
27-04-2015

@arnaud: the failure of fullscreen to work with undecorated stages is a different issue that is being tracked as RT-40624.
27-04-2015

SQE is ok to defer from 8u40.
18-11-2014

I have looked into this in great detail. From the stack and the looking at the setPosition calls that hit our CAOpenGLLayer (GlassLayer3D), the CALayer in question is a throwaway CALayer created for the exit full screen animation. This happens because the window size of 16 pixels high causes a NaN to be generated during the animation, and it seems that the only way we can get hooks into this are to use the NSWindowDelegate methods - (NSArray *)customWindowsToExitFullScreenForWindow:(NSWindow *)window and - (void)window:(NSWindow *)window startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration to generate our own exit full screen animation sequence. I'm not sure if this would solve it, but this seems to be the only hook into the failing animation. Deferring this to JDK9 seems prudent as this only occurs with a 16-pixel high window.
14-11-2014

Anyway, we can easily reproduce on 10.10, so Morris will be able to make progress. One thing to note about the bug itself is that the exception complains about NaN. I suspect what is happening is that some code hasn't been initialized with the correct size, leading to a divide by 0 or similar calculation that eventually produces a NaN.
11-11-2014

Very odd that we cannot reproduce on 10.9. Which update of 10.9 do you have, David?
11-11-2014

Not reproducible by me on 10.9
11-11-2014

I get this same crash on Yosemite - with a stack trace that is almost identical to the one above.
11-11-2014

Now that we can reproduce this it should be fairly easy to come up with a fix. Morris: you have Yosemite. Can you please try the attached test program with the following steps: 1) Launch the program on Mac OS 10.10 2) Click on the green "full screen" button --- DO NOT resize the app prior to doing this 3) Move your mouse to the top of the screen to expose the window decoration buttons 4) Click on the green button to restore the windows BUG) it will crash as described above.
11-11-2014

I can reproduce this crash on our HelloRectangle program if I remove the width and height in its Scene creation. Including the scene dimension in Scene creation for FullScreenCrash test program also workaround the problem.
11-11-2014

Attaching the test program for convenience.
11-11-2014

I can reproduce this with the simple test case as Steve mentioned on Mac OS X 10.10 (Yosemite) even when running from the command line. However if I resize the window before making it full screen it doesn't crash when exiting full screen.
11-11-2014

Yes, I ran from IDE and the javapackager generated jar file. Both print: "8.0.40-ea-b07". I also ran both with the verbose option. Both the same: Loaded /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/../libprism_es2.dylib from relative path JavaFX: using com.sun.javafx.tk.quantum.QuantumToolkit Loaded /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/../libglass.dylib from relative path Calling main(String[]) method 8.0.40-ea-b07 Loaded /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/../libjavafx_font.dylib from relative path
08-11-2014

You might try a newer EA version of 8u40 (b12 from last week is on java.net and I expect that b13 should be posted soon), but I suspect it will not make a difference. Question for you. If you run the JavaFX program from both the IDE and from the command line and print the version number, do they both say the same thing?
07-11-2014

Here are the infos from my MacBook Pro (10.9.4, Early 2011): Graphics Card: AMD Radeon HD 6750M 1024 MB JDK: 8.0.40-ea-b07 (as stated from System.getProperty("javafx.runtime.version")). -Dquantum.multithreading=false does not make a difference. Do you want me to install 8u40-ea also on the 10.9.3 iMac?
07-11-2014

@Christian: thank you for the additional information. On your 10.9.3 mac are the native .dylib libraries loaded from 8u25 (javafx.verbose will tell you) ? Also, let me know if you are getting the 8u40 ea on your system (and what build number you are using). One more thing you could try, but this is grasping at straws... can you run with "-Dquantum.multithreading=false" and see if that makes a difference?
07-11-2014

@Steve: The 10.9.3 is an iMac, I guess a pretty standard one (it's not mine). Graphics Card: Intel Iris Pro. The 10.9.4 Mac is my personal MacBook Pro from Early 2011, pretty standard model. I can't tell anything about the Graphics Card right now, but could provide it later. @Kevin: For the 10.9.3. Mac: "javafx.version = 8.0.25-b17" I can also check the version on my 10.9.4 Mac later, but I am pretty sure, it's an 8.0.40-ea version. I've tested with JDK 7 on my 10.9.4 and the issue is not present with it!
07-11-2014

@Christian: also, can you print the value of the javafx.runtime.version system property from the start(Stage) method of your app? That way you can verify that it is also 8u40 (to match your DLLs). System.out.println("javafx.version = " + System.getProperty("javafx.runtime.version"));
27-10-2014

What on earth could be going on? What kind of Mac do you have and what is the graphics card? Do you have multiple displays or any other different hardware? Are you running using retina? Christian, you say it crashes with 8u5 and 8u25. Can you try an older version of JavaFX, perhaps FX 2.x as shipped with JDK7?
27-10-2014

I've created a double-clickable FullScreenCrash.jar with javapackager (you renamed it from javafxpackager?) and double clicked the jar, which successfully launches it. But after making it fullscreen and the back to normal it crashes :-(
25-10-2014

@Steve: Yes your code does crash at my system. (Mac OS 10.9.4). Started from IntelliJ 13.1.2, tried both debug mode and non-debug mode. I started with: -Djavafx.verbose=true Output: Loaded /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/../libprism_es2.dylib from relative path JavaFX: using com.sun.javafx.tk.quantum.QuantumToolkit Loaded /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/../libglass.dylib from relative path Calling main(String[]) method Loaded /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/ext/../libjavafx_font.dylib from relative path I will try to use javafxpackager.
25-10-2014

Christian: since this only occurs to you when running from the IDE can you confirm that you are getting jfxrt.jar and the native .dylib files from the same version of JDK? When running from the IDE it's pretty easy to get a mismatch if you have multiple versions of JDK on your system. One thing you can try is to run with "-Djavafx.verbose=true" which will tell you where the native libraries are loaded from.
23-10-2014

I ran the above program under IntelliJ and it did not crash for me (OS X 10.9.5). Christian, can you make the crash happen running from the command line?
23-10-2014

I've had the opportunity to test it also on Mac 10.9.4 with JDK 8u40-ea. The same problem occurs. I've tried a few things and curiously it seems only to occur with my sample app: Scene scene = new Scene(new Label("Hello WORLD!!")); primaryStage.setScene(scene); primaryStage.show(); If I put a TextField or a Button instead of the Label it doesn't occur! But the Label Text doesn't matter. What's also important is, that you must not resize the window prior to making it fullscreen. It's a bit strange, with all other apps I have, the problem doesn't occur. I didn't use javafxpackager, but ran the application right out of the IDE in debug mode. I think I also tried without debug mode, but same behavior.
23-10-2014

Christian, can you confirm that this code crashes for you (it does not crash for me)? import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.stage.Stage; public class FullScreenCrash extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { Scene scene = new Scene(new Label("Hello WORLD!!")); primaryStage.setScene(scene); primaryStage.show(); } }
23-10-2014

Dave or Dmitry: do you have a Mac 10.9.3 system you could try? We are unable to reproduce this on the latest version (10.9.5).
22-10-2014

It seems from the description this i Mac OS 10.9.3 and JDK 8u5 and 8u25. Do we know anyone with 10.9.3 that can verify this crash?
22-10-2014

Christian, Could you provide the java version you are using?
21-10-2014

Using OSX 10.9.5, java version "1.8.0_05" (hum ... need to update) 8udev and HelloRectangle Not seeing the problem
21-10-2014

A simple app does not crash for me in 8udev on OS X 10.9.5. It seems weird that we would have shipped 8 and 8u25 with so obvious an error. I wonder if something else is going on. Can you run from the command line and not from IntelliJ?
21-10-2014

I have not seen this error before. We have made some improvements to full screen mode for Mac in 8u40. Does it still crash in 8u40?
21-10-2014