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

iOS Mobile Renderer Black Screen #99682

Closed
TCROC opened this issue Nov 25, 2024 · 34 comments · Fixed by #99820
Closed

iOS Mobile Renderer Black Screen #99682

TCROC opened this issue Nov 25, 2024 · 34 comments · Fixed by #99820

Comments

@TCROC
Copy link
Contributor

TCROC commented Nov 25, 2024

Tested versions

  • Reproduceable In: 4.4.dev.mono.custom_build.f0e971730

System information

Godot v4.4.dev.mono (f0e9717) - 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:

Image

When exporting to iOS set to use the Forward+ renderer, it renders just fine:

Image

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

forward_plus_log.txt

Steps to reproduce

  1. 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.
  2. Open the MRP
  3. Export to iOS
  4. Install to an iPhone
  5. See that a black screen renders
  6. Change project settings mobile rendering method to Forward+
  7. Export to IOS
  8. Install to an iPhone
  9. See that cube renders

Minimal reproduction project (MRP)

mrp.zip

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: #88199

@Calinou
Copy link
Member

Calinou commented Nov 25, 2024

Can you reproduce this on 4.3.stable?

@TCROC
Copy link
Contributor Author

TCROC commented Nov 25, 2024

I will go check

@TCROC
Copy link
Contributor Author

TCROC commented Nov 25, 2024

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

@TCROC
Copy link
Contributor Author

TCROC commented Nov 25, 2024

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.

@TCROC
Copy link
Contributor Author

TCROC commented Nov 25, 2024

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 :).

@bruvzg
Copy link
Member

bruvzg commented Nov 26, 2024

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.

@TCROC
Copy link
Contributor Author

TCROC commented Nov 26, 2024

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

@TCROC
Copy link
Contributor Author

TCROC commented Nov 26, 2024

@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 :)

@bruvzg
Copy link
Member

bruvzg commented Nov 27, 2024

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.

@TCROC
Copy link
Contributor Author

TCROC commented Nov 27, 2024

@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

@bruvzg
Copy link
Member

bruvzg commented Nov 27, 2024

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.

@stuartcarnie
Copy link
Contributor

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.

@TCROC
Copy link
Contributor Author

TCROC commented Nov 27, 2024

For some extra info, my phone is:

iOS Version: 17.6.1
Model Name: iPhone XR
Model Number: MT362LL/A

@stuartcarnie
Copy link
Contributor

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.

@TCROC
Copy link
Contributor Author

TCROC commented Nov 27, 2024

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?

@stuartcarnie
Copy link
Contributor

Did the MRP work on your iPhone 13 with mobile renderer?

Just trying that now

@stuartcarnie
Copy link
Contributor

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.

@TCROC
Copy link
Contributor Author

TCROC commented Nov 28, 2024

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 :)

@stuartcarnie
Copy link
Contributor

Fix coming via #99820

@TCROC
Copy link
Contributor Author

TCROC commented Nov 29, 2024

@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! 🔥

@stuartcarnie
Copy link
Contributor

stuartcarnie commented Nov 29, 2024

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

@TCROC
Copy link
Contributor Author

TCROC commented Nov 29, 2024

@stuartcarnie Perfect! Let me know what solution you come to and I'll gladly test it out :) Thank you! You are the best! :)

@maxelusgit
Copy link

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.

@TCROC
Copy link
Contributor Author

TCROC commented Dec 12, 2024

@maxelusgit try changing your rendering driver to vulkan:

Image

@maxelusgit
Copy link

maxelusgit commented Dec 12, 2024

@TCROC thx, yes, on vulkan works 😀

@stuartcarnie
Copy link
Contributor

@TCROC #99820 will now support your iPhone

@TCROC
Copy link
Contributor Author

TCROC commented Dec 15, 2024

@stuartcarnie perfect! I'll try that tomorrow :)

@maxelusgit
Copy link

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

stuartcarnie added a commit to stuartcarnie/godot that referenced this issue Dec 16, 2024
This commit introduces support for checking the argument buffer tier,
and falling back to disabling argument buffers when tier 1 is available.

Closes godotengine#99682
@stuartcarnie
Copy link
Contributor

stuartcarnie commented Dec 16, 2024

@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

@stuartcarnie
Copy link
Contributor

@maxelusgit you should also clear out your Godot shader_cache directory.

@stuartcarnie
Copy link
Contributor

stuartcarnie commented Dec 18, 2024

@TCROC were you able to try #99820 on your A12 device (Apple5 GPU)?

@TCROC
Copy link
Contributor Author

TCROC commented Dec 18, 2024

@stuartcarnie not yet. I had some things come up that I had to deal with. I try to get around to testing before end of week

@Repiteo Repiteo added this to the 4.4 milestone Dec 20, 2024
@iusn
Copy link

iusn commented Dec 22, 2024

Godot Engine mono v4.4.dev7.official.46c8f8c5c - https://godotengine.org
Metal 3.2 - Forward Mobile - Using Device #0: Apple - Apple A18 Pro GPU (Apple9)

exporting to iOS set to use the mobile renderer, it renders with a black screen. like this issue.

@stuartcarnie
Copy link
Contributor

Important

@iusn, et al, the fix, #99820 did not make the dev-7 release

tGautot pushed a commit to tGautot/godot that referenced this issue Feb 5, 2025
tGautot pushed a commit to tGautot/godot that referenced this issue Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants