I tried to change the Window Size at runtime but it didn't work on my iPhone

Godot Version

4.5.1

Question

I tried to set the window size to match the safe area rect at runtime, like this:

func _ready() -> void:

	var safe_area_rect = DisplayServer.get_display_safe_area()

	get_window().size = safe_area_rect.size
	get_window().position = safe_area_rect.position

but it didn’t work on my iPhone, the size looks still 720*720:

These are my project settings:

  • viewport size: 720*720
  • window mode: Windowed
  • stretch mode: canvas_items
  • stretch_aspect: keep

On phones, the app is already “fullscreen” by default, even if you set it to windowed. In this case, if you want it to take up more space, you’d set the stretch_aspect to expand.

See this for more details: Multiple resolutions — Godot Engine (stable) documentation in English