Closed
Description
Godot version
v4.1.3.stable.official [f06b6836a]
System information
Godot v4.1.3.stable - macOS 14.1.1 - Vulkan (Forward+) - integrated Apple M2 Pro - Apple M2 Pro (10 Threads)
Issue description
Moving between the various window modes will throw exceptions that cause the application to crash when switching back from WINDOW_MODE_FULLSCREEN with the borderless flag set to true, and any other display mode. In general, returning from a FULLSCREEN mode to a windowed one on MacOS will result in a crash.
Steps to reproduce
extends Control
@onready var option_button:OptionButton = $HBoxContainer/OptionButton as OptionButton
@onready var label:Label = $HBoxContainer/Label as Label
const WINDOW_MODE_ARRAY : Array[String] = [
"Fullscreen",
"Windowed",
"Borderless Window",
"Borderless Fullscreen"
]
func _ready():
option_button.item_selected.connect(on_window_mode_selected)
add_window_mode_items()
func add_window_mode_items() -> void:
for window_mode in WINDOW_MODE_ARRAY:
option_button.add_item(window_mode)
func on_window_mode_selected(index: int) ->void:
match index:
0: #fullscreen
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, false)
1: #windowed
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, false)
2: #borderless windowed
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, true)
3: #borderless fullscreen
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, true)
Attaching this control to a scene will illustrate the issue. You can go easily from the windowed modes, but if you go to WINDOW_MODE_FULLSCREEN (option 3), and you try to go to any other mode - you will get the error listed below.
Minimal reproduction project
E 0:00:17:0148 window_mode_button.gd:-1 @ on_window_mode_selected(): NSException: NSWindowStyleMaskFullScreen cleared on a window outside of a full screen transition. Called from (
0 AppKit 0x000000018fdc4b90 __25-[NSWindow setStyleMask:]_block_invoke + 140
1 AppKit 0x000000018fdc4ab0 NSPerformVisuallyAtomicChange + 108
2 AppKit 0x000000018fdc4990 -[NSWindow setStyleMask:] + 176
3 Godot 0x00000001046967a0 _ZN9DirAccess15_create_builtinI14DirAccessMacOSEE3RefIS_Ev + 91612
4 Godot 0x0000000107380f28 _ZN15RasterizerDummy15_create_currentEv + 95776
5 Godot 0x0000000107380b4c _ZN15RasterizerDummy15_create_currentEv + 94788
6 Godot 0x000000010496e924 _ZN18VariantInitializerI6VectorI5ColorEE4initEP7Variant + 61560
7 Godot 0x000000010484b458 _ZN7ClassDB7creatorI14ENetConnectionEEP6Objectv + 111820
8 Godot 0x00000001083e4220 _ZNK6Object15get_instance_idEv + 1512
9 Godot 0x000000010807cd68 _ZNK4JSON8get_dataEv + 1189000
10 Godot 0x00000001083e8108 _ZNK6Object15get_instance_idEv + 17616
11 Godot 0x0000000107352d60 _ZN29TileSetScenesCollectionSource17get_scene_tile_idEi + 1853744
12 Godot 0x000000010670f548 _ZN8ItemList16get_v_scroll_barEv + 346768
13 Godot 0x00000001083e8108 _ZNK6Object15get_instance_idEv + 17616
14 Godot 0x0000000107352d60 _ZN29TileSetScenesCollectionSource17get_scene_tile_idEi + 1853744
15 Godot 0x000000010671d008 _ZN8ItemList16get_v_scroll_barEv + 402768
16 Godot 0x000000010673c700 _ZN8ItemList16get_v_scroll_barEv + 531528
17 Godot 0x00000001083e8108 _ZNK6Object15get_instance_idEv + 17616
18 Godot 0x000000010655aecc _ZNK9SceneTree8get_rootEv + 476660
19 Godot 0x00000001065589a4 _ZNK9SceneTree8get_rootEv + 467148
20 Godot 0x000000010651afd0 _ZNK9SceneTree8get_rootEv + 214776
21 Godot 0x000000010651b84c _ZNK9SceneTree8get_rootEv + 216948
22 Godot 0x00000001065589fc _ZNK9SceneTree8get_rootEv + 467236
23 Godot 0x0000000106576004 _ZNK9SceneTree8get_rootEv + 587564
24 Godot 0x0000000104685428 _ZN9DirAccess15_create_builtinI14DirAccessMacOSEE3RefIS_Ev + 21092
25 Godot 0x000000010800cd64 _ZNK4JSON8get_dataEv + 730244
26 Godot 0x000000010800a054 _ZNK4JSON8get_dataEv + 718708
27 Godot 0x0000000104699638 _ZN9DirAccess15_create_builtinI14DirAccessMacOSEE3RefIS_Ev + 103540
28 Godot 0x000000010467ef64 Godot + 4042596
29 Godot 0x00000001046a917c _ZN20RendererCompositorRD15_create_currentEv + 46508
30 dyld 0x000000018c1510e0 start + 2360
)
<C++ Source> platform/macos/os_macos.mm:728 @ run()
<Stack Trace> window_mode_button.gd:-1 @ on_window_mode_selected()