You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to copy or paste using command-C or command-V in a native FileDialog (in other words copy or paste into the filename field) the application crashes on macOS.
Looking at the crash log it looks like it's getting into some infinite loop trying to pass on the key event.
Getting this to correctly copy/paste the content into the text field would of course be great, but preventing the crash is a perhaps more important as it might mean data loss with the crash just at the point the user was attempting to save their work.
VM Region Info: 0x16f1cbff0 is in 0x16b9c8000-0x16f1cc000; bytes after start: 58736624 bytes before end: 15
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
MALLOC_LARGE 159410000-15b00c000 [ 28.0M] rw-/rwx SM=PRV
GAP OF 0x109bc000 BYTES
---> STACK GUARD 16b9c8000-16f1cc000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0
Stack 16f1cc000-16f9c8000 [ 8176K] rw-/rwx SM=SHM thread 0
Regarding the crash it seems like it's actually related to NativeMenu. After testing some more it seems that the crash only occurs if I have added NativeMenu menus and try to copy or paste in a save dialogue. So the copy-paste situation was just a red herring as that's how I discovered it and thought I could initially reproduce it (as I happened to have a NativeMenu Edit menu I).
The crash seems related to NativeMenu shortcut key processing that turns into an endless loop with the native modal save dialogue active.
Here's some updated code that should let you reproduce the crash:
## first add a native menu item with a Command A shortcut
var native_menu_rid:RID = NativeMenu.create_menu()
#add it to the menu bar
var globalMenuRID:RID = NativeMenu.get_system_menu(NativeMenu.MAIN_MENU_ID)
NativeMenu.add_submenu_item(globalMenuRID,"My Menu",native_menu_rid,2)
#then set up our item
var native_menu_item_index:int = NativeMenu.add_item(native_menu_rid,"My Item")
NativeMenu.set_item_accelerator(native_menu_rid,native_menu_item_index,(KEY_MASK_META | KEY_A))
## then open a native save dialogue
var browseDialog:FileDialog = FileDialog.new()
browseDialog.initial_position = Window.WINDOW_INITIAL_POSITION_CENTER_MAIN_WINDOW_SCREEN
browseDialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
browseDialog.use_native_dialog = true
browseDialog.access = FileDialog.ACCESS_FILESYSTEM
add_child(browseDialog)
browseDialog.popup()
In the save dialogue, hit Command-A to trigger your NativeMenu item, and you should get the crash.
lostminds
changed the title
Crash on copy or paste filename in macOS native FileDialog
Crash on triggering NativeMenu keyboard shortcut in macOS while native FileDialog is open
Sep 30, 2024
Tested versions
4.3.stable
System information
macOS 14.7
Issue description
If you try to copy or paste using command-C or command-V in a native FileDialog (in other words copy or paste into the filename field) the application crashes on macOS.
Looking at the crash log it looks like it's getting into some infinite loop trying to pass on the key event.
Getting this to correctly copy/paste the content into the text field would of course be great, but preventing the crash is a perhaps more important as it might mean data loss with the crash just at the point the user was attempting to save their work.
Crash log
------------------------------------- Translated Report (Full Report Below) -------------------------------------Process: Godot [1804]
Path: /Applications/Godot.app/Contents/MacOS/Godot
Identifier: org.godotengine.godot
Version: 4.3 (4.3)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
User ID: 501
Date/Time: 2024-09-25 11:47:52.7503 +0200
OS Version: macOS 14.7 (23H124)
Report Version: 12
Anonymous UUID: 91382402-D388-42AC-F11B-5915CCDF5380
Time Awake Since Boot: 7800 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000016f1cbff0
Exception Codes: 0x0000000000000002, 0x000000016f1cbff0
Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [1804]
VM Region Info: 0x16f1cbff0 is in 0x16b9c8000-0x16f1cc000; bytes after start: 58736624 bytes before end: 15
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
MALLOC_LARGE 159410000-15b00c000 [ 28.0M] rw-/rwx SM=PRV
GAP OF 0x109bc000 BYTES
---> STACK GUARD 16b9c8000-16f1cc000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0
Stack 16f1cc000-16f9c8000 [ 8176K] rw-/rwx SM=SHM thread 0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x187138964 kdebug_is_enabled + 4
1 libsystem_kernel.dylib 0x187138a74 kdebug_trace + 48
2 CoreFoundation 0x187259974 __CFRunLoopDoSource1 + 500
3 CoreFoundation 0x187258350 __CFRunLoopRun + 2244
4 CoreFoundation 0x187257434 CFRunLoopRunSpecific + 608
5 ViewBridge 0x18f9a32c4 __invokeRunLoopInModeForDuration_block_invoke_2 + 36
6 ViewBridge 0x18f9a31b4 invokeRunLoopInModeForDuration + 212
7 ViewBridge 0x18f9a30d4 __29-[NSCFRunLoopSemaphore wait:]_block_invoke_3 + 108
8 ViewBridge 0x18f9a3060 CONSIDER_WHO_REQUESTED_THIS_WAIT_BEFORE_SENDING_BUG_TO_VIEWBRIDGE + 24
9 ViewBridge 0x18f9a3014 __29-[NSCFRunLoopSemaphore wait:]_block_invoke_2 + 144
10 ViewBridge 0x18f9a2efc __29-[NSCFRunLoopSemaphore wait:]_block_invoke + 208
11 ViewBridge 0x18f9a2b38 +[NSCFRunLoopSemaphore _observe:whilePerforming:] + 272
12 ViewBridge 0x18f9a270c -[NSCFRunLoopSemaphore wait:] + 180
13 ViewBridge 0x18fa005e4 __30-[NSRemoteViewSemaphore wait:]_block_invoke + 56
14 ViewBridge 0x18fa005a4 CONSIDER_VIEW_SERVICE_BEFORE_SENDING_BUG_TO_VIEWBRIDGE + 24
15 ViewBridge 0x18fa00580 -[NSRemoteViewSemaphore wait:] + 100
16 ViewBridge 0x18fa08768 -[NSRemoteView _waitOnSemaphore:withPatience:] + 416
17 ViewBridge 0x18fa0e7c4 -[NSRemoteView forwardKeyboardEvent:withSemaphore:] + 188
18 ViewBridge 0x18fa0ec48 __37-[NSRemoteView performKeyEquivalent:]_block_invoke + 32
19 libsystem_trace.dylib 0x186ecaeb4 os_activity_apply_f + 88
20 ViewBridge 0x18fa004bc -[NSRemoteViewSemaphore applyActivity:] + 64
21 ViewBridge 0x18fa0ebb4 -[NSRemoteView performKeyEquivalent:] + 208
22 AppKit 0x18ad25574 -[NSView performKeyEquivalent:] + 140
23 AppKit 0x18b57435c -[NSWindow _commonPerformKeyEquivalent:conditionally:] + 68
24 AppKit 0x18b2adfac routeKeyEquivalent + 224
25 AppKit 0x18ad40580 -[NSWindow keyDown:] + 84
26 AppKit 0x18ac5227c forwardMethod + 252
27 AppKit 0x18abe3578 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 404
28 AppKit 0x18abe3210 -[NSWindow(NSEventRouting) sendEvent:] + 284
29 Godot 0x100c26864 0x100438000 + 8317028
30 AppKit 0x18ad261ac -[NSMenu _performKeyEquivalentWithDelegate:] + 100
31 AppKit 0x18ad262ac -[NSMenu _performKeyEquivalentWithDelegate:] + 356
32 AppKit 0x18ad26020 -[NSMenu performKeyEquivalent:] + 180
33 AppKit 0x18b2ae088 routeKeyEquivalent + 444
34 AppKit 0x18ad40580 -[NSWindow keyDown:] + 84
35 AppKit 0x18ac5227c forwardMethod + 252
36 AppKit 0x18abe3578 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 404
37 AppKit 0x18abe3210 -[NSWindow(NSEventRouting) sendEvent:] + 284
38 Godot 0x100c26864 0x100438000 + 8317028
39 AppKit 0x18ad261ac -[NSMenu _performKeyEquivalentWithDelegate:] + 100
40 AppKit 0x18ad262ac -[NSMenu _performKeyEquivalentWithDelegate:] + 356
41 AppKit 0x18ad26020 -[NSMenu performKeyEquivalent:] + 180
42 AppKit 0x18b2ae088 routeKeyEquivalent + 444
43 AppKit 0x18ad40580 -[NSWindow keyDown:] + 84
44 AppKit 0x18ac5227c forwardMethod + 252
45 AppKit 0x18abe3578 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 404
46 AppKit 0x18abe3210 -[NSWindow(NSEventRouting) sendEvent:] + 284
47 Godot 0x100c26864 0x100438000 + 8317028
48 AppKit 0x18ad261ac -[NSMenu _performKeyEquivalentWithDelegate:] + 100
49 AppKit 0x18ad262ac -[NSMenu _performKeyEquivalentWithDelegate:] + 356
50 AppKit 0x18ad26020 -[NSMenu performKeyEquivalent:] + 180
51 AppKit 0x18b2ae088 routeKeyEquivalent + 444
52 AppKit 0x18ad40580 -[NSWindow keyDown:] + 84
53 AppKit 0x18ac5227c forwardMethod + 252
54 AppKit 0x18abe3578 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 404
55 AppKit 0x18abe3210 -[NSWindow(NSEventRouting) sendEvent:] + 284
56 Godot 0x100c26864 0x100438000 + 8317028
57 AppKit 0x18ad261ac -[NSMenu _performKeyEquivalentWithDelegate:] + 100
58 AppKit 0x18ad262ac -[NSMenu _performKeyEquivalentWithDelegate:] + 356
59 AppKit 0x18ad26020 -[NSMenu performKeyEquivalent:] + 180
60 AppKit 0x18b2ae088 routeKeyEquivalent + 444
61 AppKit 0x18ad40580 -[NSWindow keyDown:] + 84
62 AppKit 0x18ac5227c forwardMethod + 252
63 AppKit 0x18abe3578 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 404
64 AppKit 0x18abe3210 -[NSWindow(NSEventRouting) sendEvent:] + 284
65 Godot 0x100c26864 0x100438000 + 8317028
66 AppKit 0x18ad261ac -[NSMenu _performKeyEquivalentWithDelegate:] + 100
67 AppKit 0x18ad262ac -[NSMenu _performKeyEquivalentWithDelegate:] + 356
68 AppKit 0x18ad26020 -[NSMenu performKeyEquivalent:] + 180
(keeps repeating the last couple of lines)
Steps to reproduce
Open a native FileDialog in your project, for example using:
Minimal reproduction project (MRP)
Code above should be sufficient
The text was updated successfully, but these errors were encountered: