Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error opening a new project for the first time on Linux: "ERROR: Index p_screen = -5 is out of bounds (screen_count = 1)." #101317

Closed
akien-mga opened this issue Jan 8, 2025 · 4 comments · Fixed by #101381

Comments

@akien-mga
Copy link
Member

Tested versions

  • Reproducible in 4.4.dev1 and later, including 4.4.dev (a659548)
  • Not reproducible in 4.3.stable

System information

Godot v4.3.stable - Fedora Linux 41 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX Vega (RADV VEGA10) - AMD Ryzen 7 2700 Eight-Core Processor (16 Threads)

Issue description

When creating a new project and editing it from the project manager, the following error is printed to the terminal, on Linux (X11 on XWayland):

ERROR: Index p_screen = -5 is out of bounds (screen_count = 1).
   at: screen_get_usable_rect (platform/linuxbsd/x11/display_server_x11.cpp:1204)

This -5 indeed seems to be used as a default sentinel value here:

$ rg INITIAL_SCREEN_AUTO --sort=path
editor/editor_settings.cpp
440:    EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/editor_screen", EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO, ed_screen_hints)

editor/editor_settings.h
65:             INITIAL_SCREEN_AUTO = -5, // Remembers last screen position.

main/main.cpp
2870:                                                                   restore_editor_window_layout = value.operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO;
4199:                   restore_editor_window_layout = EditorSettings::get_singleton()->get_setting("interface/editor/editor_screen").operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO;

But it seems at least the X11 DisplayServer tries to use it as is when it doesn't make sense, when there's not yet any project metadata to read the last screen position from.

I haven't tested whether the error happens with other platforms. It doesn't seem to happen with the Wayland DisplayServer.

The regression seems to be caused by #97333, CC @bits-by-brandon (confirmed by reverting it locally on top of a659548). I also wonder how this change interfaces with #76085 which was merged shortly after (for 4.4.dev2).

Steps to reproduce

  • Create new project in project manager (started from terminal) with the X11 DisplayDriver
  • Edit it and check the terminal output

Minimal reproduction project (MRP)

Happens in any newly created project that doesn't have a .godot folder yet.

@permelin
Copy link
Contributor

permelin commented Jan 9, 2025

Can confirm that it also happens on Debian with XMonad and X11 all the way down (no XWayland).

@bruvzg
Copy link
Member

bruvzg commented Jan 9, 2025

Display server (on any platform) only handle special values down to SCREEN_WITH_MOUSE_FOCUS = -4, this -5 should be editor setting only and never sent to the display server.

@bruvzg
Copy link
Member

bruvzg commented Jan 9, 2025

Probably just need an extra check in case editor_layout.cfg is missing (I'll test it later):

diff --git a/main/main.cpp b/main/main.cpp
index 4a911af094..07c319c088 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2925,6 +2925,10 @@ Error Main::setup2(bool p_show_boot_logo) {
 			}
 		}
 
+		if (init_screen == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO) {
+			init_screen = DisplayServer::SCREEN_PRIMARY;
+		}
+
 		OS::get_singleton()->benchmark_end_measure("Startup", "Initialize Early Settings");
 	}
 #endif

@akien-mga
Copy link
Member Author

That seems to fix it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Not Critical
Development

Successfully merging a pull request may close this issue.

3 participants