godot
godot copied to clipboard
Game renders too small on some iOS devices
Godot version
4.0.master (860884bde7)
System information
iOS 16/ macOS Ventura
Issue description
On some devices an exported iOS game (3D/ Vulkan) doesn't scale very well.
Display Settings:
- Stretch Mode = viewport
- Aspect = expand
On an iPhone 11 and iPhone 11 Pro the game renders fine, but on an iPhone 12 Mini or iPhone 7 Plus I'm getting this result:
Steps to reproduce
Export a game to iOS
Citing CONTRIBUTING.md
On the contributors' end, recreating a test project from scratch takes valuable time that can be saved by uploading a minimal project.
To speed up our work, please upload a minimal project that isolates and reproduces the issue. This is always the best way for us to fix it. We recommend attaching a ZIP file with the minimal project directly to the bug report, by drag and dropping the file in the GitHub edition field. This ensures the file can remain available for a long period of time. Only use third-party file hosts if your ZIP file isn't accepted by GitHub because it's too large.
We recommend always attaching a minimal reproduction project, even if the issue may seem simple to reproduce manually.
Please join a MRP.
@adamscott done ✅
I can't reproduce with on macOS 13.0.1 and iPadOS 16.1.1, so it's might be specific to devices with a smaller screen. Are there any errors/warnings in the Xcode log when running on an affected device?
@bruvzg Yeah it only occurs on smaller screens. As mentioned in the PR:
On an iPhone 11 and iPhone 11 Pro the game renders fine, but on an iPhone 12 Mini or iPhone 7 Plus I'm getting this result
I didn't spot any errors last time I checked, but I can check again tomorrow
@bruvzg I couldn't spot any interesting error messages. Can I somehow log the screen size Godot gets from iOS? To check if it actually knows the correct screen size.
Update: The screen size and DPI reported by DisplayServer
are completely wrong. On an iPhone 12 Mini:
DisplayServer.screen_get_size()
returns (750, 1624)
DisplauServer.screen_get_dpi()
returns 401
The correct values, for an iPhone 12 Mini, should be (1080, 2340)
and 476
(from Apple's website)
What's DisplauServer.screen_get_scale()
returning?
2.88000011444092
And DisplayServer.screen_get_usable_rect
returns [P: (0, 0), S: (750, 1624)]
Found it! (In device_metrics.m
) Working on a fix...
Part 1
- Fixed dpi in #70022
- However this won't fix the initial problem just yet
Part 2:
- I realised that
DisplayServer.screen_get_scale
is completely off - If you turn on Display Zoom in the iOS settings (Settings -> Display& Brightness -> Display Zoom at the very bottom) I'm pretty sure every project on any iOS device will break. Give it a try with any existing Godot app on your iOS device.
- Link to screen_get_scale
From StackOverflow:
This is without display zoom. If you enable display zoom, scale remains the same, at 3, since the intermediate buffer is still rendered at 1 point = 3 pixels. But native scale becomes 2.8.
Okay I didn't manage to solve this yet. If someone else could take a look at this I'd be very grateful. Essentially turn on/off the iOS Display Zoom and start debugging the screen_size/scale from there on. (any project)