When stretch mode is "viewport", what exactly is the size of "get_tree().root"?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thornySoap

I got this basic script to print out my viewport size:

extends Node

@onready var viewport = get_tree().root

func _process(delta: float) -> void:
    if Input.is_key_pressed(KEY_SPACE):
        print("New window size: ", viewport.size)

Somehow it returns the size of the window rather than the viewport size I declared in project settings. But the on-screen canvas items “scale” the right way. If I had set stretch mode to “canvas_item” this would have been the right behaviour, wouldn’t it? But as I understanded this article (“Multiple resolutions”) the size should be just what I declared in settings as I have set stretch mode to “viewport” and aspect to “keep”.

Is this a bug or what is wrong with my understandings?