JDK-8257242 : [macOS] Java app crashes while switching input methods
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2020-11-24
  • Updated: 2021-08-21
  • Resolved: 2020-12-01
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 11 JDK 13 JDK 15 JDK 16
11.0.10Fixed 13.0.6Fixed 15.0.4Fixed 16 b27Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
The patch for https://bugs.openjdk.java.net/browse/JDK-8248532 causes a crash, as it attempts to call a method selector on a class for an instance method (- keyboardInputSourceChanged).

REGRESSION : Last worked in version 15.0.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
With a Java app running, switch input methods.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should not crash.
ACTUAL -
This will always crash with:

2020-11-24 19:50:35.353 java[21393:1260549] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[AWTView keyboardInputSourceChanged:]: unrecognized selector sent to class 0x112b4b028'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff360c3b57 __exceptionPreprocess + 250
	1   libobjc.A.dylib                     0x00007fff6ef565bf objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff36142b37 __CFExceptionProem + 0
	3   CoreFoundation                      0x00007fff360283bb ___forwarding___ + 1427
	4   CoreFoundation                      0x00007fff36027d98 _CF_forwarding_prep_0 + 120
	5   CoreFoundation                      0x00007fff3603d80f __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
	6   CoreFoundation                      0x00007fff3603d7a3 ___CFXRegistrationPost1_block_invoke + 63
	7   CoreFoundation                      0x00007fff3603d718 _CFXRegistrationPost1 + 372
	8   CoreFoundation                      0x00007fff3603d384 ___CFXNotificationPost_block_invoke + 80
	9   CoreFoundation                      0x00007fff3600d4fd -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1554
	10  CoreFoundation                      0x00007fff3600c9a9 _CFXNotificationPost + 1351
	11  Foundation                          0x00007fff3868a786 -[NSNotificationCenter postNotificationName:object:userInfo:] + 59
	12  AppKit                              0x00007fff336968ae __NSSelectedKeyboardInputSourcesChangedNotification + 58
	13  CoreFoundation                      0x00007fff3603d80f __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
	14  CoreFoundation                      0x00007fff3603d7a3 ___CFXRegistrationPost1_block_invoke + 63
	15  libdispatch.dylib                   0x00007fff700a46c4 _dispatch_call_block_and_release + 12
	16  libdispatch.dylib                   0x00007fff700a5658 _dispatch_client_callout + 8
	17  libdispatch.dylib                   0x00007fff700b0cab _dispatch_main_queue_callback_4CF + 936
	18  CoreFoundation                      0x00007fff36086e81 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	19  CoreFoundation                      0x00007fff36046c87 __CFRunLoopRun + 2028
	20  CoreFoundation                      0x00007fff36045e3e CFRunLoopRunSpecific + 462
	21  HIToolbox                           0x00007fff34c72abd RunCurrentEventLoopInMode + 292
	22  HIToolbox                           0x00007fff34c727d5 ReceiveNextEventCommon + 584
	23  HIToolbox                           0x00007fff34c72579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	24  AppKit                              0x00007fff332b8039 _DPSNextEvent + 883
	25  AppKit                              0x00007fff332b6880 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
	26  libosxapp.dylib                     0x000000010a7c31c6 -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 166
	27  AppKit                              0x00007fff332a858e -[NSApplication run] + 658
	28  libosxapp.dylib                     0x000000010a7c2e6b +[NSApplicationAWT runAWTLoopWithApp:] + 171
	29  libawt_lwawt.dylib                  0x0000000112b04f74 +[AWTStarter starter:headless:] + 468
	30  libawt_lwawt.dylib                  0x0000000112b04d40 __20+[AWTStarter start:]_block_invoke + 64
	31  JavaNativeFoundation                0x00007fff3a962ff9 +[JNFRunLoop _performCopiedBlock:] + 15
	32  Foundation                          0x00007fff3871c0dd __NSThreadPerformPerform + 204
	33  CoreFoundation                      0x00007fff36047d52 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	34  CoreFoundation                      0x00007fff36047cf1 __CFRunLoopDoSource0 + 103
	35  CoreFoundation                      0x00007fff36047b0b __CFRunLoopDoSources0 + 209
	36  CoreFoundation                      0x00007fff3604683a __CFRunLoopRun + 927
	37  CoreFoundation                      0x00007fff36045e3e CFRunLoopRunSpecific + 462
	38  libjli.dylib                        0x000000010a5e1972 ParkEventLoop + 130
	39  libjli.dylib                        0x000000010a5e0a60 MacOSXStartup + 192
	40  libjli.dylib                        0x000000010a5e039f CreateExecutionEnvironment + 383
	41  libjli.dylib                        0x000000010a5d8c39 JLI_Launch + 617
	42  java                                0x000000010a5cfba4 main + 1108
	43  libdyld.dylib                       0x00007fff700fecc9 start + 1
)

CUSTOMER SUBMITTED WORKAROUND :
Revert the patch. (But where's the corresponding removeObserver, and why is addObserver called on every call to setInputMethod?)

FREQUENCY : always



Comments
Fix request (15u). I would like to backport the fix to jdk15u for parity with jdk11u. The original patch applied cleanly.
25-04-2021

Fix request (13u). I would like to backport the fix to jdk13u for parity with jdk11u. The original patch applied cleanly.
23-12-2020

Fix Request This problem was introduced in 11.0.10. 11.0.9 works fine as expected. It's regression issue for JDK-8254070. On Mac Catalina, if Input Source is changed, Java is crashed. The patch applied cleanly to 11u-dev and I verified this issue was gone. 11-bp label was there, so it may be OK. But I'd like to request jdk11u-critical-request just in case.
04-12-2020

Changeset: 822ee474 Author: Prasanta Sadhukhan <psadhukhan@openjdk.org> Date: 2020-12-01 03:21:57 +0000 URL: https://git.openjdk.java.net/jdk/commit/822ee474
01-12-2020

The issue is reported with JDK 16 ea build having JDK-8248532 fix. From the description, it appears that post applying the patch, the crash occurs as it attempts to call a method selector on a class for an instance method (- keyboardInputSourceChanged).
30-11-2020