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

Unintended window size changes (DisplayServer regression) #58032

Closed
Tracked by #37734
h0lley opened this issue Feb 12, 2022 · 4 comments · Fixed by #71523
Closed
Tracked by #37734

Unintended window size changes (DisplayServer regression) #58032

h0lley opened this issue Feb 12, 2022 · 4 comments · Fixed by #71523

Comments

@h0lley
Copy link

h0lley commented Feb 12, 2022

Godot version

4.0.alpha2

System information

Ubuntu 21.10, Nvidia GTX 970, Vulkan

Issue description

When a call to DisplayServer.window_set_size() is followed by TranslationServer.set_locale() (and presumably other functions that meet certain requirements), then Godot may change the window size a second time for an undiscernible reason.

Steps to reproduce

Start a project with this in _ready():

await get_tree().process_frame
DisplayServer.window_set_size(Vector2i(200, 600))
TranslationServer.set_locale(OS.get_locale())

And notice that instead of the specified window size, the window appears with the default size from project settings.
When listening to the viewport's size_changed signal, we can see that Godot changed the window twice: initially to the intended size, and then right back to the default one.

Start a project with this in _ready():

DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
await get_tree().create_timer(1.0).timeout
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
DisplayServer.window_set_size(Vector2i(200, 600))
TranslationServer.set_locale(OS.get_locale())

And notice that upon exiting fullscreen mode, the window size is changed a total of four times:

  1. to 1024, 629 (no idea why, but it seems to be default window size + decoration)
  2. to 1024, 600 (this is the default window size from project settings)
  3. to 200, 600 (this is our intended size)
  4. to 1920, 1015 (no idea why, but it seems to be full screen size - decoration - taskbar)

Minimal reproduction project

Please have a look at this minimal project, toggle fullscreen via F11 and observe the log.

godot_4_window_size_bug.zip

@Calinou
Copy link
Member

Calinou commented Feb 12, 2022

@h0lley Can you reproduce this in 3.4.2?

Also, please test on Windows or macOS if you have access to hardware running those operating systems 🙂

@jmb462
Copy link
Contributor

jmb462 commented Feb 12, 2022

Under Windows 10, cannot reproduce the first part (TranslationServer.set_locale() do not change window size)

Window size changed to (200, 600) (intentional)

For the second part, here is what I get with a native 1920x1080 monitor :

Entering fullscreen
Window size changed to (214, 637) (why???)
Window size changed to (1918, 1078) (why???)
Exiting fullscreen
Window size changed to (1904, 1041) (why???)
Window size changed to (200, 600) (intentional)

It could have a link with window decoration add/remove on switch.

@h0lley
Copy link
Author

h0lley commented Feb 12, 2022

@h0lley Can you reproduce this in 3.4.2?

Also, please test on Windows or macOS if you have access to hardware running those operating systems slightly_smiling_face

It's Godot 4 only - I encountered it while porting.
And indeed it doesn't seem to be an issue on Windows. I cannot easily test macOS.

@Calinou Calinou changed the title Unintended window size changes Unintended window size changes (DisplayServer regression) Feb 12, 2022
@YeldhamDev
Copy link
Member

YeldhamDev commented Jan 13, 2023

This happens because the value of the Window node aren't updated when changed via the DisplayServer singleton. TranslationServer.set_locale() triggers a NOTIFICATION_TRANSLATION_CHANGED notification, that calls the _update_child_controls() method, which finally triggers a size update on the Window (which currently always happens, it should be changed so it's only called when Window.wrap_controls is enabled), that have the incorrect values.

The DisplayServer.window_set_* functions are lower level stuff, called by the Window node when changing its values from there, which would be the Correct ™ way to do it. I think the documentation for it should be changed to reflect that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants