godot icon indicating copy to clipboard operation
godot copied to clipboard

Game renders too small on some iOS devices

Open marius-se opened this issue 2 years ago • 1 comments

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

marius-se avatar Nov 27 '22 21:11 marius-se

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 avatar Nov 28 '22 00:11 adamscott

@adamscott done ✅

marius-se avatar Nov 28 '22 21:11 marius-se

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 avatar Dec 09 '22 17:12 bruvzg

@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

marius-se avatar Dec 11 '22 18:12 marius-se

@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.

marius-se avatar Dec 12 '22 21:12 marius-se

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)

marius-se avatar Dec 13 '22 08:12 marius-se

What's DisplauServer.screen_get_scale() returning?

bruvzg avatar Dec 13 '22 08:12 bruvzg

2.88000011444092

marius-se avatar Dec 13 '22 08:12 marius-se

And DisplayServer.screen_get_usable_rect returns [P: (0, 0), S: (750, 1624)]

marius-se avatar Dec 13 '22 08:12 marius-se

Found it! (In device_metrics.m) Working on a fix...

marius-se avatar Dec 13 '22 16:12 marius-se

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

marius-se avatar Dec 13 '22 17:12 marius-se

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.

marius-se avatar Dec 13 '22 17:12 marius-se

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)

marius-se avatar Dec 13 '22 18:12 marius-se