bell-sw / LibericaNIK

Native Image Kit
8 stars 0 forks source link

[Liberica Native Image] Swing window resizing crashes application on macOS #15

Open edigonzales opened 1 year ago

edigonzales commented 1 year ago

I was able to compile an older, small Swing application with Liberica NIK. I used the agent as suggested in the docs. I'm able to run the application but trying to resizing the application ends with a crash. I tried it with different os and arch versions. Some combinations seem to work (but not always, which is odd): I was able to resize the window if I compiled and ran the application on Apple M1. But sometimes the app crashed even before showing the window.

Ubuntu 22.04 seems to work fine.

Using Liberica NIK 22.2 / Java 17.

Error message (compiled and ran on macOS Catalina):


❯ ./build/native/nativeCompile/ili2c
2022-10-24 10:22:34.572 ili2c[19312:148723] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff30de1627 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff69ae45bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff30e9032e -[__NSCFString characterAtIndex:].cold.1 + 0
    3   CoreFoundation                      0x00007fff30e8e303 -[__NSArrayM insertObject:atIndex:].cold.2 + 0
    4   CoreFoundation                      0x00007fff30d01ab5 -[__NSArrayM insertObject:atIndex:] + 1155
    5   ili2c                               0x00000001080de0e2 IsolateEnterStub__VmLocatorSymbol__vmLocatorSymbol__bec84cad1f8708102cd8814ef3e496531bf6ff5b__bbf2dbb2d6a07a8e1dae8a3072b01ad86ecc1a50 + 33665010
    6   ili2c                               0x00000001080df3d3 IsolateEnterStub__VmLocatorSymbol__vmLocatorSymbol__bec84cad1f8708102cd8814ef3e496531bf6ff5b__bbf2dbb2d6a07a8e1dae8a3072b01ad86ecc1a50 + 33669859
    7   AppKit                              0x00007fff2e08495a -[NSAccessibilityAttributeAccessorInfo getAttributeValue:forObject:] + 58
    8   AppKit                              0x00007fff2e641c49 ___NSAccessibilityEntryPointValueForAttribute_block_invoke.805 + 1674
    9   AppKit                              0x00007fff2e63da94 NSAccessibilityPerformEntryPointObject + 16
    10  AppKit                              0x00007fff2e3018c1 _NSAccessibilityEntryPointValueForAttribute + 168
    11  AppKit                              0x00007fff2e0846e4 NSAccessibilityChildren + 41
    12  AppKit                              0x00007fff2e084674 NSAccessibilityUnignoredChildrenForOnlyChild + 70
    13  ili2c                               0x00000001080ac864 IsolateEnterStub__VmLocatorSymbol__vmLocatorSymbol__bec84cad1f8708102cd8814ef3e496531bf6ff5b__bbf2dbb2d6a07a8e1dae8a3072b01ad86ecc1a50 + 33462132
    14  AppKit                              0x00007fff2e08495a -[NSAccessibilityAttributeAccessorInfo getAttributeValue:forObject:] + 58
    15  AppKit                              0x00007fff2e641c49 ___NSAccessibilityEntryPointValueForAttribute_block_invoke.805 + 1674
    16  AppKit                              0x00007fff2e63da94 NSAccessibilityPerformEntryPointObject + 16
    17  AppKit                              0x00007fff2e3018c1 _NSAccessibilityEntryPointValueForAttribute + 168
    18  AppKit                              0x00007fff2e0846e4 NSAccessibilityChildren + 41
    19  AppKit                              0x00007fff2e0861dd NSAccessibilityUnignoredChildren + 220
    20  AppKit                              0x00007fff2e085e7a NSAccessibilityGetObjectForAttributeUsingLegacyAPI + 371
    21  AppKit                              0x00007fff2e085401 NSAccessibilityGetObjectValueForAttribute + 1565
    22  AppKit                              0x00007fff2e08495a -[NSAccessibilityAttributeAccessorInfo getAttributeValue:forObject:] + 58
    23  AppKit                              0x00007fff2e641c49 ___NSAccessibilityEntryPointValueForAttribute_block_invoke.805 + 1674
    24  AppKit                              0x00007fff2e63da94 NSAccessibilityPerformEntryPointObject + 16
    25  AppKit                              0x00007fff2e3018c1 _NSAccessibilityEntryPointValueForAttribute + 168
    26  AppKit                              0x00007fff2e0846e4 NSAccessibilityChildren + 41
    27  AppKit                              0x00007fff2e36da75 -[NSView(NSViewAccessibility) _accessibilityBasicHitTest:] + 150
    28  AppKit                              0x00007fff2e36d9c5 -[NSView(NSViewAccessibility) accessibilityHitTest:] + 22
    29  AppKit                              0x00007fff2e8804f7 -[NSWindow(NSWindowAccessibility) accessibilityHitTest:] + 317
    30  AppKit                              0x00007fff2e46f311 -[NSApplication(NSApplicationAccessibility) accessibilityHitTest:] + 342
    31  AppKit                              0x00007fff2e4457da CopyElementAtPosition + 170
    32  HIServices                          0x00007fff2f03a0ab _AXXMIGCopyElementAtPosition + 332
    33  HIServices                          0x00007fff2f05a408 _XCopyElementAtPosition + 369
    34  HIServices                          0x00007fff2f018f64 mshMIGPerform + 174
    35  CoreFoundation                      0x00007fff30d65d94 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
    36  CoreFoundation                      0x00007fff30d65ce0 __CFRunLoopDoSource1 + 541
    37  CoreFoundation                      0x00007fff30d64809 __CFRunLoopRun + 2270
    38  CoreFoundation                      0x00007fff30d638ce CFRunLoopRunSpecific + 462
    39  HIToolbox                           0x00007fff2f98fabd RunCurrentEventLoopInMode + 292
    40  HIToolbox                           0x00007fff2f98f7d5 ReceiveNextEventCommon + 584
    41  HIToolbox                           0x00007fff2f98f579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    42  AppKit                              0x00007fff2dfd6739 _DPSNextEvent + 883
    43  AppKit                              0x00007fff2dfd4f80 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
    44  ili2c                               0x0000000107e7cf3a IsolateEnterStub__VmLocatorSymbol__vmLocatorSymbol__bec84cad1f8708102cd8814ef3e496531bf6ff5b__bbf2dbb2d6a07a8e1dae8a3072b01ad86ecc1a50 + 31170122
    45  AppKit                              0x00007fff2dfc6c8e -[NSApplication run] + 658
    46  ili2c                               0x0000000107e7cd09 IsolateEnterStub__VmLocatorSymbol__vmLocatorSymbol__bec84cad1f8708102cd8814ef3e496531bf6ff5b__bbf2dbb2d6a07a8e1dae8a3072b01ad86ecc1a50 + 31169561
    47  ili2c                               0x00000001080fd489 IsolateEnterStub__VmLocatorSymbol__vmLocatorSymbol__bec84cad1f8708102cd8814ef3e496531bf6ff5b__bbf2dbb2d6a07a8e1dae8a3072b01ad86ecc1a50 + 33792921
    48  ili2c                               0x0000000107e7e89f IsolateEnterStub__VmLocatorSymbol__vmLocatorSymbol__bec84cad1f8708102cd8814ef3e496531bf6ff5b__bbf2dbb2d6a07a8e1dae8a3072b01ad86ecc1a50 + 31176623
    49  Foundation                          0x00007fff33439b4d __NSThreadPerformPerform + 204
    50  CoreFoundation                      0x00007fff30d657e2 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    51  CoreFoundation                      0x00007fff30d65781 __CFRunLoopDoSource0 + 103
    52  CoreFoundation                      0x00007fff30d6559b __CFRunLoopDoSources0 + 209
    53  CoreFoundation                      0x00007fff30d642ca __CFRunLoopRun + 927
    54  CoreFoundation                      0x00007fff30d638ce CFRunLoopRunSpecific + 462
    55  CoreFoundation                      0x00007fff30debf59 CFRunLoopRun + 40
    56  ili2c                               0x000000010607b159 ili2c + 7065945
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    19312 abort      ./build/native/nativeCompile/ili2c
AlexanderScherbatiy commented 1 year ago

Does the resizing crash is reproduces only with the the used older, small Swing application, or it is able to reproduce the crash with a simple Swing application or a demo like SwingSet2 as well?

Did you use the native-image-agent to prepare the configuration files with all usages of dynamic features during the Swing application resizing? It needs to run the code below and resize the app:

 java -agentlib:native-image-agent=config-output-dir=conf-dir -jar SwingApp.jar

and create the native image with the configuration files:

native-image -H:JNIConfigurationFiles=conf-dir/jni-config.json -H:ReflectionConfigurationFiles=conf-dir/reflect-config.json -H:ResourceConfigurationFiles=conf-dir/resource-config.json -H:SerializationConfigurationFiles=conf-dir/serialization-config.json ...
edigonzales commented 1 year ago

Does the resizing crash is reproduces only with the the used older, small Swing application, or it is able to reproduce the crash with a simple Swing application or a demo like SwingSet2 as well?

Will check that as soon as I'm able to login to oracle to download the demo...

Did you use the native-image-agent to prepare the configuration files with all usages of dynamic features during the Swing application resizing? It needs to run the code below and resize the app:

Yes.