godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.04k stars 20.19k forks source link

Android export not working just a black screen on Android versions older than 9.0 #63943

Closed madmiraal closed 1 year ago

madmiraal commented 2 years ago

Godot version

4.0.alpha13

System information

Android 8

Issue description

Exports to Android no longer work with 4.0.alpha13. It worked fine with 4.0.alpha12. All I get now is a black screen.

Logcat: ``` 2022-08-05 09:26:33.614 4721-4721/org.godotengine.androidtest W/linker: "/data/app/org.godotengine.androidtest-ubSVahhQcJP6DEU3VC_OFA==/lib/arm64/libc++_shared.so" unused DT entry: type 0x70000001 arg 0x0 2022-08-05 09:26:33.981 4721-4762/org.godotengine.androidtest E/vulkan: invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceVersion") call 2022-08-05 09:26:33.982 4721-4762/org.godotengine.androidtest E/vulkan: invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceVersion") call 2022-08-05 09:26:34.056 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "err" is true. Returning: ERR_CANT_CREATE 2022-08-05 09:26:34.056 4721-4762/org.godotengine.androidtest E/godot: at: _update_swap_chain (drivers/vulkan/vulkan_context.cpp:1856) - Condition "err" is true. Returning: ERR_CANT_CREATE 2022-08-05 09:26:34.056 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "err != OK" is true. Returning: ERR_CANT_CREATE 2022-08-05 09:26:34.056 4721-4762/org.godotengine.androidtest E/godot: at: _window_create (drivers/vulkan/vulkan_context.cpp:1461) - Condition "err != OK" is true. Returning: ERR_CANT_CREATE 2022-08-05 09:26:35.239 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR failed with error -7. 2022-08-05 09:26:35.239 4721-4762/org.godotengine.androidtest E/godot: at: _render_pass_create (drivers/vulkan/rendering_device_vulkan.cpp:3955) - Condition "res" is true. Returning: nullptr 2022-08-05 09:26:35.239 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR failed with error -7. 2022-08-05 09:26:35.239 4721-4762/org.godotengine.androidtest E/godot: at: _render_pass_create (drivers/vulkan/rendering_device_vulkan.cpp:3955) - Condition "res" is true. Returning: nullptr 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR failed with error -7. 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: at: _render_pass_create (drivers/vulkan/rendering_device_vulkan.cpp:3955) - Condition "res" is true. Returning: nullptr 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: at: render_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6381) - Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR failed with error -7. 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: at: _render_pass_create (drivers/vulkan/rendering_device_vulkan.cpp:3955) - Condition "res" is true. Returning: nullptr 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: at: render_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6381) - Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.240 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR failed with error -7. 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: at: _render_pass_create (drivers/vulkan/rendering_device_vulkan.cpp:3955) - Condition "res" is true. Returning: nullptr 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: at: render_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6381) - Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR failed with error -7. 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: at: _render_pass_create (drivers/vulkan/rendering_device_vulkan.cpp:3955) - Condition "res" is true. Returning: nullptr 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: at: render_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6381) - Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR failed with error -7. 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: at: _render_pass_create (drivers/vulkan/rendering_device_vulkan.cpp:3955) - Condition "res" is true. Returning: nullptr 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.241 4721-4762/org.godotengine.androidtest E/godot: at: render_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6381) - Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR for empty fb failed with error -7. 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: at: framebuffer_format_create_empty (drivers/vulkan/rendering_device_vulkan.cpp:4047) - Condition "res" is true. Returning: 0 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: at: render_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6381) - Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: vkCreateRenderPass2KHR for empty fb failed with error -7. 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: at: framebuffer_format_create_empty (drivers/vulkan/rendering_device_vulkan.cpp:4047) - Condition "res" is true. Returning: 0 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: USER ERROR: Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() 2022-08-05 09:26:35.287 4721-4762/org.godotengine.androidtest E/godot: at: render_pipeline_create (drivers/vulkan/rendering_device_vulkan.cpp:6381) - Condition "!framebuffer_formats.has(p_framebuffer_format)" is true. Returning: RID() ```

The above is just the beginning of the error log, but these errors continue as long as the game's black screen is open.

Steps to reproduce

Export a project to Android (using one-click deploy). See nothing but a black screen.

Minimal reproduction project

Any project will do, but here's one: Test.zip

akien-mga commented 2 years ago

No idea what caused the regression yes but I'll mention a few who have been involved in changing Vulkan setup the past few weeks: @RandomShaper @BastiaanOlij

BastiaanOlij commented 2 years ago

It's trying to recreate the framebuffer each frame which is why it's error spamming. The question is why it's erroring out to begin with.

The first one that stands out is: invalid vkGetInstanceProcAddr(VK_NULL_HANDLE, "vkEnumerateInstanceVersion") call, this is likely not our issue. vkEnumerateInstanceVersion is a Vulkan 1.1 function, we are getting it's pointer to see if it is supported and on failure assume we're still on Vulkan 1.0. Well atleast at the point we're calling it.

It could be the VRS issue on devices that don't support VRS that clayjohn just fixed that was happening on integrated GPUs.

We should run this with validation layers turned on, on a device that is giving issues. That will give us more detailed info. I'll test it on my android device as soon as I have some free time.

dave2 commented 1 year ago

May be related? https://github.com/godotengine/godot/issues/65217

Snowy-Fox commented 1 year ago

I may be having the same issue on both of my two Android devices. One is a Huawei P10 Lite running Android 8, the other is a Retroid Pocket 2+ running Android 9.

I'm afraid I don't know how to access the log files in Android, but am willing to try with guidance if it would help narrow down the fault.

I've been exporting an APK and installing it manually on both devices, rather than using one-click deploy.

I can provide a reproduction project, though like madmiraal, it doesn't matter which project I use: https://drive.google.com/uc?id=1Refr6GJsew6gnNNfGoSdrNWZtm2KrP4h&export=download

I've been discussing the issue with other users in this thread on the Godot Forums: https://godotforums.org/d/31827-40b3-40b4-black-screen-on-android

Calinou commented 1 year ago

While Vulkan is in theory supported on Android 7.0 and later, Vulkan support on versions below Android 9.0 is considered pretty broken in general (not just among Godot developers).

The OpenGL renderer will have to be made working to get actual support for Android versions older than 9.0. This renderer is already present as of 4.0.beta4, but is currently experimental and doesn't have a working Android context yet.

clayjohn commented 1 year ago

It would be good to test this on a more recent beta as https://github.com/godotengine/godot/pull/67227 may have fixed this issue

Snowy-Fox commented 1 year ago

It would be good to test this on a more recent beta as #67227 may have fixed this issue

I've just tested an export from 4.0b5 on both the Retroid Pocket 2+ and the Huawei P10 Lite. In both cases, the result was the same as before when using the Mobile renderer. When using the OpenGL renderer, both devices showed this error message.

Snowy-Fox commented 1 year ago

Just tested exporting from 4.0b7. The issue is back to being a black screen after the Godot splash, with no error message shown. The game no longer crashes on the Pocket 2+, but the black screen still persists on both devices.

clayjohn commented 1 year ago

@Snowy-Fox Does that include the OpenGL renderer? We just added Android export for the OpenGL renderer in Beta 7

Snowy-Fox commented 1 year ago

@clayjohn It does - I tested it with both the mobile renderer and the OpenGL renderer. Reported observed behaviour is from the OpenGL export.

clayjohn commented 1 year ago

The issue running on the gl_compatibility renderer may be fixed by https://github.com/godotengine/godot/pull/69521. https://github.com/godotengine/godot/pull/69521 does not help the Vulkan backends though

Snowy-Fox commented 1 year ago

If the feedback is any help, I can keep testing and reporting my findings on these devices with new beta releases.

Snowy-Fox commented 1 year ago

Update: as of Godot 4 beta 8, while using OpenGL, I now have a nearly-functioning picture on my Retroid Pocket 2+ and Huawei P10 Lite!

photo_2022-12-13_15-45-20_detail

A semi-related screen tearing issue previously observed in Android exports from Godot 3.x has re-emerged. This was previously resolved by using GLES2, so I guess now I should just wait and hope for support for that to be re-added.

clayjohn commented 1 year ago

Wonderful! Closing this as resolved. Feel free to open another bug report for issues you encounter in using the OpenGL backend

tung-nt-niteco commented 1 year ago

Hi guys,

So what is the solution after all?

I also got a black screen on some devices. Godot 4.0.3 Here is my logcat: --------- beginning of kernel 2023-07-13 21:57:17.996 7278-7303 OpenGLRenderer org.tung.myapp E Unable to match the desired swap behavior. 2023-07-13 21:57:18.191 7278-7316 platform org.tung.myapp E Failed to open rendernode: No such file or directory 2023-07-13 21:57:33.456 7278-7316 godot org.tung.myapp E USER ERROR: Unable to open file: res://.godot/imported/thumbnail_placeholder.png-f21ef9f8f845b484ce2039339d4882e2.ctex. 2023-07-13 21:57:33.457 7278-7316 godot org.tung.myapp E at: _load_data (scene/resources/texture.cpp:847) 2023-07-13 21:57:33.469 7278-7316 godot org.tung.myapp E USER ERROR: Unable to open file: res://.godot/imported/menu_arrow.png-6aa82b98585c62f1ccdd06489088e188.ctex. 2023-07-13 21:57:33.470 7278-7316 godot org.tung.myapp E at: _load_data (scene/resources/texture.cpp:847) 2023-07-13 21:57:39.430 7278-7316 goldfish_vulkan org.tung.myapp E exportSyncFdForQSRILocked: Failed to dup() QSRI sync fd : sterror: Bad file descriptor errno: 9 2023-07-13 21:57:39.475 7278-7316 goldfish_vulkan org.tung.myapp E exportSyncFdForQSRILocked: Failed to dup() QSRI sync fd : sterror: Bad file descriptor errno: 9 2023-07-13 21:57:45.248 7278-7328 androidemu org.tung.myapp E Logging hang event. Number of tasks already hung: 0 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E Metadata: 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E file: device/generic/goldfish-opengl/system/vulkan_enc/VkEncoder.cpp 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E function: vkWaitForFences 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E line: 4747 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E msg: vkWaitForFences in VkEncoder 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E thread: 7316 (0x00001c94) 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E process name: org.tung.myapp 2023-07-13 21:57:45.249 7278-7328 androidemu org.tung.myapp E Additional information: 2023-07-13 21:57:45.250 7278-7328 androidemu org.tung.myapp E seqno: 11049 2023-07-13 21:57:45.250 7278-7328 androidemu org.tung.myapp E packetSize: 44 2023-07-13 21:57:45.251 7278-7328 androidemu org.tung.myapp E packetContents: 47 4E 00 00 2C 00 00 00 29 2B 00 00 20 17 00 00 02 00 03 00 01 00 00 00 22 17 00 00 02 00 16 00 01 00 00 00 FF FF FF FF FF FF FF FF 2023-07-13 21:57:45.251 7278-7328 androidemu org.tung.myapp E HealthMonitor: Number of unresponsive tasks increased: 0 -> 1