Open AllenDang opened 1 month ago
Which Android device model did you test this on, and which rendering method are you using in the project?
Also, I'm curious why you need to change both the viewport size and the 3D scaling property. Typically, you change the viewport size (for 2D games) or the 3D scaling (for 3D games), not both.
PS: If you're using the disabled
or canvas_items
stretch mode, changing the root viewport size is not supported as it'll be overridden on window resize events. This includes restoring the activity on Android, due to possible orientation or display folding changes. You need to use the viewport
stretch mode to allow this instead, but viewport sizes that are not a divisor of the screen size will result in uneven pixel scaling (which looks bad).
Tested versions
4.3 Stable
System information
Android
Issue description
I'm implementing a viewport setting for my game, to let user select and change the viewport size at runtime.
With following project settings of window
Change window.size and window.scaling_3d_scale at runtime, will shrink the viewport size, but when I put the game in background and switch back, viewport size will scale to full screen size.
Here is the code I used
var viewport_width := 960 var viewport_height := 540 var scale := 1.0 match visual: HM_VISUAL.VISUAL_LOW: viewport_width = 960 viewport_height = 540 scale = 1.0 HM_VISUAL.VISUAL_MED: viewport_width = 1280 viewport_height = 720 scale = 1.33 HM_VISUAL.VISUAL_HIGH: viewport_width = 1920 viewport_height = 1080 scale = 2.0 var win := get_window() win.size = Vector2i(viewport_width, viewport_height) win.scaling_3d_scale = scale
Here is a video to show the effect
20241011-211821.mp4
Steps to reproduce
Like the video shows
- change the visual to 'low'
- put the game in background
- switch back to the game
Minimal reproduction project (MRP)
N/A
Provide a example project to test.
Which Android device model did you test this on, and which rendering method are you using in the project?
Also, I'm curious why you need to change both the viewport size and the 3D scaling property. Typically, you change the viewport size (for 2D games) or the 3D scaling (for 3D games), not both.
PS: If you're using the
disabled
orcanvas_items
stretch mode, changing the root viewport size is not supported as it'll be overridden on window resize events. This includes restoring the activity on Android, due to possible orientation or display folding changes. You need to use theviewport
stretch mode to allow this instead, but viewport sizes that are not a divisor of the screen size will result in uneven pixel scaling (which looks bad).
@Calinou
The issue happens on all our android devices, for stretch mode, like the screen shot I provided in the issue, are set to:
Stretch mode: viewport Aspect: expand Render method: mobile
For the reason why I change viewport size and 3d scaling, check https://docs.godotengine.org/en/stable/tutorials/3d/resolution_scaling.html#resolution-scaling-options, I do it for better performance.
@UnderGamer05 Sure, I added the MVP project in the post, you can also download it here. repoissue98088.zip
Ok, this is happening with me either.
Any update?
@AllenDang window_set_size
is not supported on Android. The viewport size change is a bug. I’ll work on a fix and submit a PR soon.
Can Someone confirm if this issue occurs on Wayland and iOS?
Tested versions
4.3 Stable
System information
Android
Issue description
I'm implementing a viewport setting for my game, to let user select and change the viewport size at runtime.
With following project settings of window
Change window.size and window.scaling_3d_scale at runtime, will shrink the viewport size, but when I put the game in background and switch back, viewport size will scale to full screen size.
Here is the code I used
Here is a video to show the effect
https://github.com/user-attachments/assets/7eaac904-aa4b-4409-8b3d-d739e80e98be
Steps to reproduce
Like the video shows
Minimal reproduction project (MRP)
repoissue98088.zip