JDK-8172847 : [macos] If you hit the escape key repeatedly to close the subwindow, the process crashes
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u112,9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2017-01-09
  • Updated: 2017-09-07
  • Resolved: 2017-06-13
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.
JDK 8 JDK 9
8u151Fixed 9Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_111"
java version "1.8.0_112"


ADDITIONAL OS VERSION INFORMATION :
macOS Sierra 10.12.2

EXTRA RELEVANT SYSTEM CONFIGURATION :
Mac Book Pro with TouchBar

A DESCRIPTION OF THE PROBLEM :
If you hit the escape key repeatedly to close the subwindow, the process crashes.

This problem can be avoided in the case of Dialog, but it is very serious as it can not be avoided with FileChooser and DirectoryChooser.
(As a matter of course, it can not be said not to use the Scope Key for the user)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Execute the test program
2) Press the button of the crash case
3) Press the escape key repeatedly to close the window
4) If the process does not crash, repeat steps 2 to 3

* Probably to reproduce this problem I think we need a 2016 latter model with TouchBar.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Process crashes
ACTUAL -
Process does not crash

ERROR MESSAGES/STACK TRACES THAT OCCUR :
2017-01-10 00:40:08.168 java[3261:451661] *** Assertion failure in -[NSTouch normalizedPosition], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.76/AppKit.subproj/NSTouch.m:87
2017-01-10 00:40:08.195 java[3261:451661] *** Assertion failure in -[NSTouch normalizedPosition], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.76/AppKit.subproj/NSTouch.m:87
2017-01-10 00:40:09.636 java[3261:451661] *** Assertion failure in -[NSTouch normalizedPosition], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.76/AppKit.subproj/NSTouch.m:87
2017-01-10 00:40:09.637 java[3261:451661] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot get normalizedPosition for this type of NSTouch'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fffb596ce7b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fffca557cad objc_exception_throw + 48
	2   CoreFoundation                      0x00007fffb5971b82 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fffb73bbd50 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
	4   AppKit                              0x00007fffb3760975 -[NSTouch normalizedPosition] + 155
	5   libglass.dylib                      0x0000000128864227 -[GlassTouches(hidden) sendJavaTouchEvent:] + 2023
	6   libglass.dylib                      0x000000012886398c listenTouchEvents + 92
	7   SkyLight                            0x00007fffc7347e80 processDecodedEventRef + 204
	8   SkyLight                            0x00007fffc734766a processEventTapData + 544
	9   SkyLight                            0x00007fffc71f2cb0 _XPostEventTapData + 280
	10  SkyLight                            0x00007fffc73473f4 eventTapMessageHandler + 137
	11  CoreFoundation                      0x00007fffb58eb803 __CFMachPortPerform + 291
	12  CoreFoundation                      0x00007fffb58eb6c9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
	13  CoreFoundation                      0x00007fffb58eb641 __CFRunLoopDoSource1 + 465
	14  CoreFoundation                      0x00007fffb58e3525 __CFRunLoopRun + 2389
	15  CoreFoundation                      0x00007fffb58e2974 CFRunLoopRunSpecific + 420
	16  HIToolbox                           0x00007fffb4e6eacc RunCurrentEventLoopInMode + 240
	17  HIToolbox                           0x00007fffb4e6e809 ReceiveNextEventCommon + 184
	18  HIToolbox                           0x00007fffb4e6e736 _BlockUntilNextEventMatchingListInModeWithFilter + 71
	19  AppKit                              0x00007fffb3414ae4 _DPSNextEvent + 1120
	20  AppKit                              0x00007fffb3b8f21f -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2789
	21  libglass.dylib                      0x000000012885172c +[GlassApplication enterNestedEventLoopWithEnv:] + 172
	22  libglass.dylib                      0x000000012885216a Java_com_sun_glass_ui_mac_MacApplication__1enterNestedEventLoopImpl + 74
	23  ???                                 0x0000000110b219f4 0x0 + 4575074804
	24  ???                                 0x0000000110b12040 0x0 + 4575010880
)
libc++abi.dylib: terminating with uncaught exception of type NSException


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

public class WindowCrashTest extends Application{

	@Override
	public void start(Stage primaryStage) throws Exception {
		
		Button fileChooserButton1 = new Button("FileChooser.showOpenDialog()");
		Button fileChooserButton2 = new Button("FileChooser.showOpenMultipleDialog()");
		Button fileChooserButton3 = new Button("FileChooser.showSaveDialog()");
		Button directroyChooserButton = new Button("DirectoryChooser.showDialog()");
		Button dialogButton1 = new Button("Dialog.showAndWait()");
		Button dialogButton2 = new Button("Dialog.show()");

		fileChooserButton1.setOnAction((e)->{
			FileChooser chooser = new FileChooser();
			chooser.showOpenDialog(primaryStage);
		});
		fileChooserButton2.setOnAction((e)->{
			FileChooser chooser = new FileChooser();
			chooser.showOpenMultipleDialog(primaryStage);
		});
		fileChooserButton3.setOnAction((e)->{
			FileChooser chooser = new FileChooser();
			chooser.showSaveDialog(primaryStage);
		});
		directroyChooserButton.setOnAction((e)->{
			DirectoryChooser chooser = new DirectoryChooser();
			chooser.showDialog(primaryStage);
		});
		dialogButton1.setOnAction((e)->{
			Dialog<ButtonType> dialog = new Dialog<>();
			dialog.initOwner(primaryStage);
			dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL);
			dialog.showAndWait();
		});
		dialogButton2.setOnAction((e)->{
			Dialog<ButtonType> dialog = new Dialog<>();
			dialog.initOwner(primaryStage);
			dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL);
			dialog.show();
		});
		VBox root = new VBox(
			new Label("Crash case"),
			fileChooserButton1,
			fileChooserButton2,
			fileChooserButton3,
			directroyChooserButton,
			dialogButton1,
			new Label("Not Crash case"),
			dialogButton2
		);
		
		
		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.show();
		
	}
	
	public static void main(String[] args) {
		Application.launch(args);
	}
	
	
}

---------- END SOURCE ----------


Comments
Also, we want to backport this to JDK 8. If the backport applies cleanly after adjusting the file path (which I believe it does), then no need for a new webrev. Approved to push to 8u-dev for 8u152.
13-06-2017

http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/b298c353d43e
13-06-2017

Fix request approved Approved to push to FX 9-dev for JDK 9.
13-06-2017

Fix Request: This fix prevents pretty common crash on latest MacBooks with Touch Bar.
12-06-2017

This looks good now. +1
12-06-2017

> [touch performSelector:@selector(type)] Thanks. I figured it was something like that (the objective-C equivalent of using reflection). I'll do a quick test to make sure it compiles OK on OS X 10.9.5 (it should do) and then finish my review.
09-06-2017

http://cr.openjdk.java.net/~azvegint/jdk/10/8172847/02/ As I said I tested it only with a touchpad. typedef NS_ENUM(NSInteger, NSTouchType) { NSTouchTypeDirect, // A direct touch from a finger (on a screen) NSTouchTypeIndirect, // An indirect touch (not a screen) } NS_ENUM_AVAILABLE_MAC(10_12_2); So it looks like that touch screen events might be affected, I've filed JDK-8181848, but I haven't hardware to check it before/after this fix.
09-06-2017

That looks correct to me, but I am getting the following warnings, which may mean that something slightly different than '[touch type]' is needed: /Users/kcr/javafx/9-kcr/jfx/rt/modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m:338:20: warning: multiple methods named 'type' found || [touch type] == 1 /* NSTouchTypeIndirect */) { ^~~~~~~~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSNetServices.h:114:38: note: using @property (readonly, copy) NSString *type; ^~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:264:1: note: also found - (NSEventType)type; ^~~~~~~~~~~~~~~~~~~~ /Users/kcr/javafx/9-kcr/jfx/rt/modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m:338:27: warning: 'NSTouch' may not respond to 'type' || [touch type] == 1 /* NSTouchTypeIndirect */) { ~~~~~ ^ /Users/kcr/javafx/9-kcr/jfx/rt/modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m:338:33: warning: comparison between pointer and integer ('NSString *' and 'int') || [touch type] == 1 /* NSTouchTypeIndirect */) { ~~~~~~~~~~~~ ^ ~ 3 warnings generated.
06-06-2017

1. AWT doesn't have such issue because the normalizedPosition selector is not used. 2. I've verified only regular touchpad processing. I don't have touch screen Mac either. Ah, missed that touch.type is a part of the new API too. http://cr.openjdk.java.net/~azvegint/jdk/10/8172847/01/
06-06-2017

You will probably need something like: if (![touch respondToSelector:@selector(type)] || [touch type] == 1 /* NSTouchTypeIndirect */) {
06-06-2017

This fails to compile on our official release build environment of OS X 10.9.5, Xcode 5.1.1, and SDK 10.9 /Users/kcr/javafx/9-kcr/jfx/rt/modules/javafx.graphics/src/main/native-glass/mac/GlassTouches.m:338:19: error: property 'type' not found on object of type 'NSTouch *' if (touch.type == 1 /* NSTouchTypeIndirect */) { ^ 1 error generated.
06-06-2017

This looks like a very safe fix. A couple of questions: 1) Does AWT have a similar problem? (and if not, why not?) 2) Have you verified that normal touch events are still processed? I don't have a Mac with a touch screen to verify.
06-06-2017

http://cr.openjdk.java.net/~azvegint/jdk/10/8172847/00/ 10.12.1 update introduced two touch types: direct and indirect. Both of these types are poorly described in official documentation[0][1]. However allowedTouchTypes should be set to direct to handle events on the Touch Bar(the one above the keyboard)[2]. We doesn't support the Touch Bar currently, so this fix doesn't report events with direct type. [0] https://developer.apple.com/documentation/appkit/nstouchtype/nstouchtypedirect?language=objc [1] https://developer.apple.com/documentation/appkit/nstouchtype/nstouchtypeindirect?language=objc [2] https://developer.apple.com/documentation/appkit/nstouchbar?language=objc#2587738
06-06-2017

Attached test program for convenience.
26-05-2017

Raising the priority to P2 since this is a crash with no known workaround.
20-05-2017

Additional information from submitter of JDK-8179220 regarding if crash happening on JDK 9: -------------------------------------------------------------------------------------------------------------------------- Yes, it is, downloaded the idk 9 ea today and it still crashes > java -version java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+166) Java HotSpot(TM) 64-Bit Server VM (build 9-ea+166, mixed mode) 2017-04-25 10:44:26.686 java[31980:26002264] *** Assertion failure in -[NSTouch normalizedPosition], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.82.104/AppKit.subproj/NSTouch.m:87 2017-04-25 10:44:26.687 java[31980:26002264] Apple AWT Internal Exception: Cannot get normalizedPosition for this type of NSTouch 2017-04-25 10:44:26.687 java[31980:26002264] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot get normalizedPosition for this type of NSTouch' *** First throw call stack: ( 0 CoreFoundation 0x00007fff950a937b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00007fffa9e9d48d objc_exception_throw + 48 2 CoreFoundation 0x00007fff950ae082 +[NSException raise:format:arguments:] + 98 3 Foundation 0x00007fff96af5ce0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 AppKit 0x00007fff92e67ff1 -[NSTouch normalizedPosition] + 155 5 libglass.dylib 0x0000000138773277 -[GlassTouches(hidden) sendJavaTouchEvent:] + 2023 6 libglass.dylib 0x00000001387729dc listenTouchEvents + 92 7 SkyLight 0x00007fffa6c55312 processDecodedEventRef + 204 8 SkyLight 0x00007fffa6c54afc processEventTapData + 544 9 SkyLight 0x00007fffa6b7d083 _XPostEventTapData + 280 10 SkyLight 0x00007fffa6c54886 eventTapMessageHandler + 137 11 CoreFoundation 0x00007fff9502829d __CFMachPortPerform + 253 12 CoreFoundation 0x00007fff95028189 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41 13 CoreFoundation 0x00007fff95028101 __CFRunLoopDoSource1 + 465 14 CoreFoundation 0x00007fff9501fd75 __CFRunLoopRun + 2389 15 CoreFoundation 0x00007fff9501f1c4 CFRunLoopRunSpecific + 420 16 Foundation 0x00007fff96a31572 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 277 17 libglass.dylib 0x000000013875f808 +[GlassApplication enterNestedEventLoopWithEnv:] + 136 18 libglass.dylib 0x00000001387602aa Java_com_sun_glass_ui_mac_MacApplication__1enterNestedEventLoopImpl + 74 19 ??? 0x000000011a72cdb5 0x0 + 4738698677 ) libc++abi.dylib: terminating with uncaught exception of type NSException ----------------------------------------------------------------------------------------------------
25-04-2017

I'll check with submitter if its reproducible with JDK 9, as required MacBook Pro with touch bar is not available.
25-04-2017

Priyanka, Curtis, Abhijit, does it affect 9 as well?
24-04-2017

ILW==MMH==P3 Impact = Medium - Multiple users are facing this issue on MacBook Pro with touch bar Likelihood = Medium - user are experiencing the problem in some common use cases also. Workaround = H - No workaound.
24-04-2017

Happens all the time for me on a MacBook Pro with touch bar. Using jdk1.8.0_121 and macOS 10.2.3 and 10.2.4
31-03-2017

Tried this issue against JDK 8u121 b13 on MacOS Sierra (Mac mini Late 2014) version 10.12.3 and could not reproduce the issue.
10-02-2017

We need a new macbook pro with touchbar to reproduce it, since I don't have one I can't reproduce this issue.
30-01-2017

Alex, does it affect 9?
30-01-2017

I am not able to reproduce this bug on OS X 10.9.5 or 10.11. We will need to track down a machine with MacOS 10.12 (Sierra) and test it on that release of MacOS.
19-01-2017

does it affect 9?
17-01-2017