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

4.1 SubViewport.size is always (2, 2)? #77815

Closed
rakkarage opened this issue Jun 3, 2023 · 5 comments · Fixed by #78009
Closed

4.1 SubViewport.size is always (2, 2)? #77815

rakkarage opened this issue Jun 3, 2023 · 5 comments · Fixed by #78009

Comments

@rakkarage
Copy link
Contributor

Godot version

v4.1.dev.custom_build [543750a]

System information

Windows 11, Core i5-12400F, RX 6600

Issue description

extends SubViewport

func _ready():
	print(size)
  • in 4.0.3- this prints the resolution of the window (1152, 648)
  • in 4.1 this prints (2, 2)

Thanks.

Steps to reproduce

  • new Control scene
    • add SubViewportContainer child
      • set Anchor to Full Rect
      • turn Stretch on
      • add SubViewport child
        • add Camera2D child
          • set Anchor Mode to Fixed Top Left
        • attach script that prints size

Minimal reproduction project

https://github.com/rakkarage/TestSubViewportSize

@AThousandShips
Copy link
Member

Is this restricted to the first frame, does it happen if you reload the scene? Could be a limitation on showing for the first time

@Sauermann
Copy link
Contributor

Please try as workaround:

extends SubViewport

func _ready():
	call_deferred("print_size")


func print_size():
	print(size)

@rakkarage
Copy link
Contributor Author

Ya that fixes it. thanks. :)

@AThousandShips

This comment was marked as outdated.

@Rindbee
Copy link
Contributor

Rindbee commented Jun 4, 2023

A regression from #77651.

Previously, _size_changed() was called during NOTIFICATION_VISIBILITY_CHANGED. Only necessary for the first display, more like a call is needed after entering the tree when it's shown:

notification(NOTIFICATION_VISIBILITY_CHANGED); // Considered invisible until entered.

Seems unnecessary to call every time the control is shown.

Control::_notification(NOTIFICATION_ENTER_TREE) will be called after CanvasItem::_notification(NOTIFICATION_ENTER_TREE). _size_changed() can be called there (if it's necessary) and the visibility is already determined. There is already a call in NOTIFICATION_POST_ENTER_TREE.

_size_changed();

Seems like it's not working as expected due to propagation order? Node::_propagate_ready()

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