godot
godot copied to clipboard
iOS Mobile Renderer Black Screen
Tested versions
- Reproduceable In: 4.4.dev.mono.custom_build.f0e971730
System information
Godot v4.4.dev.mono (f0e971730) - macOS 15.0.1 - Multi-window, 1 monitor - Metal (Forward+) - integrated Apple M2 (Apple8) - Apple M2 (8 threads)
Issue description
When exporting to iOS set to use the mobile renderer, it renders with a black screen:
When exporting to iOS set to use the Forward+ renderer, it renders just fine:
Here are the respective logs:
Note
The Forward+ Renderer Log has many errors, but that is the one that actually renders correctly. The Mobile Renderer log only has 1 error, but renders with a black screen.
Mobile Renderer Log
Godot Engine v4.4.dev.mono.custom_build.f0e971730 (2024-11-16 22:16:24 UTC) - https://godotengine.org
Metal 3.1 - Forward Mobile - Using Device #0: Apple - Apple A12 GPU (Apple5)
ERROR: Mouse is not supported by this display server.
at: mouse_get_position (servers/display_server.cpp:508)
Forward+ Renderer Log
Steps to reproduce
- Use Godot with double precision and mono support.
- I'm not certain if this is necessary as I haven't tested other builds, but that is what I am currently using.
- Open the MRP
- Export to iOS
- Install to an iPhone
- See that a black screen renders
- Change project settings mobile rendering method to Forward+
- Export to IOS
- Install to an iPhone
- See that cube renders
Minimal reproduction project (MRP)
Edit:
Here's the table of tested snapshots:
✅ = ~vulkan~ mobile works as expected ❌ = ~vulkan~ mobile blank screen
| Version | Status |
|---|---|
| 4.3.stable | ✅ |
| 4.4-dev1 | ❌ |
| 4.4-dev2 | ? |
| 4.4-dev3 | ? |
| 4.4-dev4 | ? |
| 4.4-dev5 | ❌ |
Edit:
I crossed out ~vulkan~ above. @bruvzg pointed out here that we are actually defaulting to the metal rendering device on ios now. Changing it back to use Vulkan in the project settings as described in that comment makes the MRP work. So it appears to be specifically related to the metal driver introduced in this pr: https://github.com/godotengine/godot/pull/88199
Can you reproduce this on 4.3.stable?
I will go check
I initially tried to test in 4.3 by building from source but was unable to because my Mac OS received an LLVM update. And this version of LLVM can no longer compile code prior to that fix we put in a while back where LLVM rolled out some breaking changes. But I do have good news! I was able to reproduce the issue with dev snapshots and confirm that things work as expected in 4.3-stable. So this is indeed a regression. I'm going to start bisecting, but there is the table of what I have tested so far:
✅ = vulkan mobile works as expected ❌ = vulkan mobile blank screen ? = untested
| Version | Status |
|---|---|
| 4.3.stable | ✅ |
| 4.4-dev1 | ? |
| 4.4-dev2 | ? |
| 4.4-dev3 | ? |
| 4.4-dev4 | ? |
| 4.4-dev5 | ❌ |
Also note that I reproduced this with normal Godot. It occurred in the 4.4-dev5 snapshot without mono support. And I believe those snapshots do not have double precision either right? Which would lead me to believe this issue is not related to mono support or double precision.
| Version | Status |
|---|---|
| 4.3.stable | ✅ |
| 4.4-dev1 | ❌ |
| 4.4-dev2 | ? |
| 4.4-dev3 | ? |
| 4.4-dev4 | ? |
| 4.4-dev5 | ❌ |
So it was first introduced somewhere between 4.3.stable and 4.4-dev1.
@Calinou I found where it was introduced in regards to snapshots :).
Metal 3.1 - Forward Mobile - Using Device #0: Apple - Apple A12 GPU (Apple5)
Default backend for Mobile/Forward+ on macOS and iOS was changed to new Metal renderer. While Vulkan renderer should support A12 (it is the oldest SOC it should run on), I'm not sure what's the minimum requirement for Metal renderer. Try setting rendering/rendering_device/driver.ios in the project settings to vulkan.
@bruvzg I will give this a shot
@Calinou I bisected and found the PR that introduced this issue. Looks like it @stuartcarnie 's pr here: https://github.com/godotengine/godot/pull/88199
Thank you btw @stuartcarnie for the metal support! I love getting as close to the native drivers for target platforms as possible! :). I just believe I may have found an issue with this PR that introduces black screen on ios.
@bruvzg I can confirm that changing the rendering_device/driver.ios back to vulkan fixes and is a workaround while the metal renderer is being debugged :)
For the reference, Metal render seems to be working fine on A14 (10. gen. iPad) and M4 Pro. Unlike A12, these devices have Metal 3.2 printed when starting, not Metal 3.1. So this might be the requirement.
Metal 3.1 - Forward Mobile - Using Device #0: Apple - Apple A12 GPU (Apple5)
Metal 3.2 - Forward Mobile - Using Device #0: Apple - Apple A14 GPU (Apple7)
Metal 3.2 - Forward+ - Using Device #0: Apple - Apple M4 Pro (Apple9)
Officially supported Metal 3 devices are A12X/A13+, so base A12 might be too old and have incomplete Metal implementation. We probably should update documentation with new min. system requirements for Metal renderer.
@bruvzg Should we have it automatically fall back to Vulkan if we detect at startup that it is the old one?
Also something to note, Forward+ works without issue. I was only having issues with the Mobile renderer
Should we have it automatically fall back to Vulkan if we detect at startup that it is the old one?
Yes, but currently fallback only works if a specific renderer is completely missing, in this case renderer init works, but shader compiler fails.
Also something to note, Forward+ works without issue. I was only having issues with the Mobile renderer
In this case, it probably is a Metal renderer bug, not a hardware limitation.
I tried the 2D lights and shadows demo, as I already had that setup, and it is still working with the Forward Mobile renderer, but Forward+ is definitely returning a lot of errors, so I don't believe it is working without issue. I'll try your MRP next.
For some extra info, my phone is:
iOS Version: 17.6.1
Model Name: iPhone XR
Model Number: MT362LL/A
Also something to note, Forward+ works without issue. I was only having issues with the Mobile renderer
In this case, it probably is a Metal renderer bug, not a hardware limitation.
Forward+ is not working correctly, as many of the pipelines are failing to compile, which are in the logs @TCROC included. I was able to replicate that on my iPhone 13. I'll have to take a look and see why it's failing, as I expect it should work.
I'm mostly interested in why the mobile renderer isn't working for you, as there are no logs and no errors / warnings suggesting it is even compiling anything.
Also something to note, Forward+ works without issue. I was only having issues with the Mobile renderer
In this case, it probably is a Metal renderer bug, not a hardware limitation.
Forward+ is not working correctly, as many of the pipelines are failing to compile, which are in the logs @TCROC included. I was able to replicate that on my iPhone 13. I'll have to take a look and see why it's failing, as I expect it should work.
I'm mostly interested in why the mobile renderer isn't working for you, as there are no logs and no errors / warnings suggesting it is even compiling anything.
Did the MRP work on your iPhone 13 with mobile renderer?
Did the MRP work on your iPhone 13 with mobile renderer?
Just trying that now
It is reproducible – the issue is in the Metal renderer and related to how SPIRV-Cross generates the shader interface for iOS vs macOS for certain shaders. Turns out that the mobile renderer is also partially rendering (like Forward+), a full-screen quad is rendering black for mobile.
Perfect! Thank you for reproducing @stuartcarnie! And happy Thanksgiving if you celebrate it! :) I guess we can update the tags now that it has been confirmed :)
Fix coming via #99820
@stuartcarnie I'm not saying you are "the man". But if the "the man" were to hypothetically exist, he would likely look something like you 😎
I'll try out your PR in my fork in the morning! 🔥
@TCROC I think I see that you have an Apple5 GPU device (2018), which is unfortunately too low for the change I had to make. The minimum version is now an Apple6 family GPU, which is from 2019. SPIRV-Cross has some issues with mixing Apple GPU features between Apple5 and Apple6 era GPUs, which directly affect the Metal renderer 😔
~~I'm hoping we can support some sort of automatic fall-back to MoltenVK.~~
I'm going to investigate adding support for 2017+ era devices in a separate PR.
@stuartcarnie Perfect! Let me know what solution you come to and I'll gladly test it out :) Thank you! You are the best! :)
| Version | Status |
|---|---|
| 4.3.stable | ✅ |
| 4.4-dev1 | ❌ |
| 4.4-dev2 | ❌ |
| 4.4-dev3 | ? |
| 4.4-dev4 | ? |
| 4.4-dev5 | ❌ |
| 4.4-dev6 | ❌ |
hi, I trying export on iPhone14 to iOS , and black screen too. Metal.
Provisioning in export not working too in 4.4dev-. Must set it / correct on xcode project, error in log when exporting. Editor export not using dev id. Id is correct. in 4.3 stable is ok, works.
@maxelusgit try changing your rendering driver to vulkan:
@TCROC thx, yes, on vulkan works 😀
@TCROC #99820 will now support your iPhone
@stuartcarnie perfect! I'll try that tomorrow :)
In my tests...
using Metal: now :
-
Node2D is visible (my gui, joysticks on screen ...)
-
Node3D or all 3d is - BLACK
before :
- all BLACK
using Volkan :
- all visible
@maxelusgit do you have a MRP we can look at, as that will help us troubleshoot the problem. It is also likely a separate issue, as an iPhone 14 should be a Tier 2 device and won't use the new code path
@maxelusgit you should also clear out your Godot shader_cache directory.