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

Strange bug with 3 sprites, where one of them uses gdshader - Android 10 #79760

Open
marko995 opened this issue Jul 21, 2023 · 46 comments
Open

Comments

@marko995
Copy link

marko995 commented Jul 21, 2023

Godot version

4.0, 4.1, 4.1.1

System information

Godot v4.1.1.stable (bd6af8e) - Fedora Linux 37 (Workstation Edition) - Vulkan (Mobile) - integrated Intel(R) Graphics (ADL GT2) () - 12th Gen Intel(R) Core(TM) i5-12500H (16 Threads)

Issue description

Hi guys,
I am porting circle android jump game from kids can code tutorial using vulkan renderer.
I am using an old phone Xiaomi mi a2 (Android 10, it support vulkan 1.0 and gles3.2)
I found a strange bug, where I am rendering 3 sprites, two sprites use png, third use png with gdshader.
Tested situations:

  1. When I hide one of them (nvm which one) everything is working. So, in this case, if there is one sprite with png, and a second with gdshader, everything is working.

  2. When I remove gdshader from the sprite, everything is working.

  3. When I remove gdshader, but add more sprites, everything is working.

I will send github repo to see details.

I did tests on other phones, like moto g5(android 12) and samsung a52(android 12), and on pc as well, and everything is working.
It's working in compatibility renderer!

logcat:
https://pastebin.com/Z8H5tDUQ

Currently, I am trying to build editor and export a template with debugging symbols to find the line where it's crashing, but I found nothing.

I am open to any suggestions to fix this error because it has very unpredictable behavior.

Steps to reproduce

  1. Create circle scene, add sprite, and add png.
  2. Create jumper scene, add sprite, add png and add gdshader on that sprite:
shader_type canvas_item;

uniform vec4 color : source_color;

void fragment() {
	COLOR .rgb = color.rgb;
}
  1. Create main scene, where you add one jumper scene, and two circle scenes.

Minimal reproduction project

I removed all unnecessary files.
https://github.com/marko995/CircleJumpGodot4

@marko995 marko995 changed the title Strange bug with 3 sprites, where one of them using gdshader - Android 10 Strange bug with 3 sprites, where one of them uses gdshader - Android 10 Jul 21, 2023
@Sauermann
Copy link
Contributor

Since only a single device-type shows this problem, it might be hardware-related. That would make it difficult to fix this on the Godot-side.

@marko995
Copy link
Author

Since only a single device-type shows this problem, it might be hardware-related. That would make it difficult to fix this on the Godot-side.

Can you help me with debugging?
Because same game created in godot 3.5, works in both gles3 and gles2

@Sauermann
Copy link
Contributor

Can you help me with debugging?

@marko995 i don't believe so, because without the specific device I can't replicate the problem.

@marko995
Copy link
Author

yeah, I know, but can you give me guidelines on how to debug the issue? I already tried to build godot editor from source with debugging symbols, but I got same error message :/

@Sauermann
Copy link
Contributor

Sauermann commented Jul 23, 2023

For questions regarding godot-compilation I suggest to join the contributors chat at https://chat.godotengine.org/
It is difficult to discuss these things here on Github.

@bemyak
Copy link
Contributor

bemyak commented Aug 7, 2023

I experience a similar issue on Sony Xperia XZ1 Compact running Android 11. I narrowed down the problem to the uniform feature. If I hardcode the value, the game no longer crashes.

@bemyak
Copy link
Contributor

bemyak commented Aug 7, 2023

The issue is present on 4.1.1.stable and on v4.2.dev2.official [da81ca62a]; 3.5.2 works as expected.

@Zireael07
Copy link
Contributor

3.x is not a Vulkan app, so it could be related to your device's Vulkan drivers, too

@Alex2782
Copy link
Contributor

Minimal reproduction project: https://github.com/marko995/CircleJumpGodot4
is no longer found

Some bugs have been fixed in the last few weeks, you might be able to test again soon with version 4.2.x or 4.3.

@marko995
Copy link
Author

it still crashes

@Alex2782
Copy link
Contributor

Alex2782 commented Dec 12, 2023

and v4.2.1?

Akien - 13:22
We just released Godot 4.2.1, as the first maintenance update to the 4.2 feature branch.

This version contains the bug fixes that I meant.
If not, please upload your project again.

@marko995
Copy link
Author

still crashing..kk

@marko995
Copy link
Author

@marko995
Copy link
Author

marko995 commented Dec 12, 2023

@Alex2782
is there any tutorial on how to get better error logs from vulkan driver?

@Calinou
Copy link
Member

Calinou commented Dec 12, 2023

@Alex2782 is there any tutorial on how to get better error logs from vulkan driver?

https://docs.godotengine.org/en/latest/contributing/development/debugging/vulkan/vulkan_validation_layers.html

It doesn't mention specific instructions for enabling Vulkan validation layers on Android. I can find this from a quick search: https://developer.android.com/ndk/guides/graphics/validation-layer

@Alex2782
Copy link
Contributor

@Alex2782 same link https://github.com/marko995/CircleJumpGodot4

ok thanks, 2 days ago Github showed 404 error (not found), today it works again

@marko995
Copy link
Author

@Alex2782 crash happens because of this line:
uniform vec4 color : source_color;

when I don't use it, works fine

@Alex2782
Copy link
Contributor

logcat: https://pastebin.com/Z8H5tDUQ
AudioTrack org.godotengine.game V processAudioBuffer(351): obtainBuffer(882) returned 1772 = 882 + 890 err 0

but in the project I can't find any audio files that are played


You could also try starting an empty 2D project (maybe with only 1 text label, no gdshader) via remote debugging and log everything without filters
image

adb logcat > logs.txt
(press Ctrl + C after crash, redirected all logs from the last 2 hours to one file)

@Alex2782
Copy link
Contributor

@Alex2782 crash happens because of this line: uniform vec4 color : source_color;

when I don't use it, works fine

ok on my Samsung Tab S7 no problems (newer Vulkan version)

@marko995
Copy link
Author

problem happens when I use
3 sprites, and one of them use uniform vec4 color : source_color;

if I use 2 sprites, everything works.

Probably the problem is in vulkan driver, because when I use the newer phone, motorola g5, works fine.

@Alex2782
Copy link
Contributor

strange, and if only COLOR is not initialized, it also crashes?

void fragment() {
	COLOR.rgb = color.rgb;
}

@marko995
Copy link
Author

@Alex2782
you didn't understand me :D if I don't use color, and use hardcoded color, it is working

@Alex2782
Copy link
Contributor

I just wanted to narrow down the error. I understood the rest.😄

problem happens when I use 3 sprites, and one of them use uniform vec4 color : source_color;

without COLOR.rgb = color.rgb;, crash or not?

shader_type canvas_item;
uniform vec4 color : source_color;

void fragment() {

}

@marko995
Copy link
Author

marko995 commented Dec 12, 2023

doesn't work:

shader_type canvas_item;

uniform vec4 color : source_color;

void fragment() {
	COLOR .rgb = color.rgb;
}

it works:

shader_type canvas_item;


void fragment() {
	COLOR.rgb = vec3(1.0, 0.0, 0.0);
}

@marko995
Copy link
Author

the idea is to manipulate colors through material parameter, which is not working.

@marko995
Copy link
Author

@Alex2782 is it possible to use source_color without uniform ?

@marko995
Copy link
Author

@Alex2782
also this doesn't work

shader_type canvas_item;

uniform vec3 color : source_color;

void fragment() {
	
}

@marko995
Copy link
Author

yup, problem is in word uniform :/
this doesn't work as well:

shader_type canvas_item;

uniform vec4 color;

void fragment() {
	
}

@Alex2782
Copy link
Contributor

Alex2782 commented Dec 12, 2023

Github: uniform + android 14 issues open.

I still have an old Samsung tablet with Android 8, if I find time I'll try to test it with Godot.

@marko995
Copy link
Author

@Alex2782 Ok, but I think this won't be fixed soon :/

@Alex2782
Copy link
Contributor

@Alex2782 is it possible to use source_color without uniform ?

Unfortunately, I don't know much about shaders at all, after a short research I couldn't find any examples without "uniform".


There are also compute shaders, where different uniform types can be specified via GdScript. Maybe it would also be interesting to catch the errors.

https://docs.godotengine.org/en/stable/tutorials/shaders/compute_shaders.html

# Create a uniform to assign the buffer to the rendering device
var uniform := RDUniform.new()
uniform.uniform_type = RenderingDevice.UNIFORM_TYPE_STORAGE_BUFFER

https://docs.godotengine.org/en/stable/classes/class_renderingdevice.html#enum-renderingdevice-uniformtype

@Alex2782
Copy link
Contributor

Samsung Galaxy Tab A (2016) SM-T580, Android 8, armeabi-v7a: no problems with Vulkan and uniform 😃


Vulkan API 1.0.61 - Forward Mobile - Using Vulkan Device #0: ARM - Mali-T830

https://vulkan.gpuinfo.org/
The tablet is so old that there is no information about it, I can't install the gpuinfo app either (arm-v8)


This comparison could perhaps be useful:
Samsung Galaxy Tab A (2016, Android 10, arm-v8) vs. Xiaomi Mi A2 Lite
https://vulkan.gpuinfo.org/compare.php?reports=10941,9320#extensions

  • VK_KHR_16bit_storage
  • VK_KHR_image_format_list

For example, Samsung has these 2 'extensions'. They are also queried by Godot (optional). If I find more time again, I'll try to experiment with the sources.

@marko995
Copy link
Author

@Alex2782
If you need device to test it, ping me

@Alex2782
Copy link
Contributor

ShaderTest.zip

@marko995: if you find the time at some point, please try it out. Are the crashes reproducible? I need a project where I can debug the functions at the push of a button.

  • button "Compute" is this example: compute_shaders
  • button "Add ShaderMaterial" adds dynamically via GdScript the file global_color_canvas_item.gdshader -> global uniform vec4 global_color;

Bildschirmfoto 2023-12-29 um 19 42 44

On my Samsung Galaxy Tab A (2016) SM-T580, there are no problems with the color shaders, but with the compute shader (output = input).

Bildschirmfoto 2023-12-29 um 19 40 16

@marko995
Copy link
Author

@Alex2782
when i press compute once it works but if i press 25 times the app crashes.
logcat: https://pastebin.com/fYeKr2c9

But when I pressed Add ShaderMaterial first (or after compute), app crashed instantly.
logcat: https://pastebin.com/SFZmHzKT

@marko995
Copy link
Author

marko995 commented Jan 4, 2024

@Alex2782 any luck?

@Alex2782
Copy link
Contributor

Alex2782 commented Jan 4, 2024

I will release a debug APK for it soon, last I checked OpenGL ES3. I found some debug settings in the Godot sources, I still have to try if this is also possible with Vulkan.

@Alex2782
Copy link
Contributor

Alex2782 commented Jan 7, 2024

Firebase - Test Lab has also Mi A2 Lite: full logs (search for 22258 pid)

I have tried with Validation Layer, but I can't see any new useful information yet.

01-06 19:23:09.259: I/godot(22258): _on_timer_timeout
......
01-06 19:23:09.532: I/godot(22258): Shader loaded in 273 ms
......
01-06 19:23:09.587: F/libc(22258): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 22746 (VkThread), pid 22258 (com.godot.game)
......
01-06 19:23:09.833: F/DEBUG(23682): ABI: 'arm64'
01-06 19:23:09.835: F/DEBUG(23682): Timestamp: 2024-01-06 19:23:09-0800
01-06 19:23:09.835: F/DEBUG(23682): pid: 22258, tid: 22746, name: VkThread  >>> com.godot.game <<<
01-06 19:23:09.835: F/DEBUG(23682): uid: 10160
01-06 19:23:09.835: F/DEBUG(23682): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
01-06 19:23:09.835: F/DEBUG(23682): Cause: null pointer dereference
01-06 19:23:09.835: F/DEBUG(23682):     x0  0000000000000000  x1  0000000000000003  x2  0000007810966e80  x3  000000780f7b3058
01-06 19:23:09.836: F/DEBUG(23682):     x4  000000783cdb2000  x5  0000000000000000  x6  0000000000000000  x7  0000000000000001
01-06 19:23:09.836: F/DEBUG(23682):     x8  0000000000000002  x9  0000000000000001  x10 0000000000000001  x11 0000000000000004
01-06 19:23:09.836: F/DEBUG(23682):     x12 00000078156bbef0  x13 0000000000000000  x14 0000000000000000  x15 0000000000000002
01-06 19:23:09.836: F/DEBUG(23682):     x16 000000783d62eef8  x17 00000078156db800  x18 00000078204d2000  x19 00000078156db800
01-06 19:23:09.836: F/DEBUG(23682):     x20 0000007810966e80  x21 000000789b174d10  x22 0000000000000000  x23 000000789b174a10
01-06 19:23:09.836: F/DEBUG(23682):     x24 0000000000000001  x25 000000780f03e100  x26 0000000000000028  x27 0000007843eb8580
01-06 19:23:09.836: F/DEBUG(23682):     x28 0000000000000000  x29 000000789b177b70
01-06 19:23:09.836: F/DEBUG(23682):     sp  000000789b1740f0  lr  000000789b174a10  pc  00000078195d0004
01-06 19:23:09.829: W/Studio:PollNet(21316): type=1400 audit(0.0:4593): avc: denied { read } for name="stats" dev="proc" ino=4026532884 scontext=u:r:shell:s0 tcontext=u:object_r:proc_qtaguid_stat:s0 tclass=file permissive=0
01-06 19:23:09.844: F/DEBUG(23682): backtrace:
01-06 19:23:09.844: F/DEBUG(23682):       #00 pc 00000000000f5004  /vendor/lib64/hw/vulkan.msm8953.so (BuildId: 4059f276877a7a61cc16b085624608be)
01-06 19:23:09.844: F/DEBUG(23682):       #01 pc 00000000000a0468  /vendor/lib64/hw/vulkan.msm8953.so (qglinternal::vkCmdDrawIndexed(VkCommandBuffer_T*, unsigned int, unsigned int, unsigned int, int, unsigned int)+232) (BuildId: 4059f276877a7a61cc16b085624608be)
01-06 19:23:09.844: F/DEBUG(23682):       #02 pc 00000000019fd5e0  /data/app/com.godot.game-KJNnqiAlqU7OqrGjjechwQ==/lib/arm64/libVkLayer_khronos_validation.so (DispatchCmdDrawIndexed(VkCommandBuffer_T*, unsigned int, unsigned int, unsigned int, int, unsigned int)+156) (BuildId: 74b81aeab8816fc078cb99b8199b6b561a30c09b)
01-06 19:23:09.844: F/DEBUG(23682):       #03 pc 00000000017e8e94  /data/app/com.godot.game-KJNnqiAlqU7OqrGjjechwQ==/lib/arm64/libVkLayer_khronos_validation.so (vulkan_layer_chassis::CmdDrawIndexed(VkCommandBuffer_T*, unsigned int, unsigned int, unsigned int, int, unsigned int)+452) (BuildId: 74b81aeab8816fc078cb99b8199b6b561a30c09b)

@Alex2782
Copy link
Contributor

Alex2782 commented Jan 7, 2024

Next week I'll try to add debug_callback. I can test 5 x per day for free at Firebase on real devices, there are also a lot of virtual ones, which are probably unsuitable because of software renderer.

@hsandt
Copy link
Contributor

hsandt commented Mar 26, 2024

I'm looking for a shader-related crash and I'm not sure if this issue is about it, because nor the title nor the description explicitly mention a crash.

The title says "strange bug". Then again in the description line:

I found a strange bug, where I am rendering 3 sprites, two sprites use png, third use png with gdshader.

The first and only mention of crash is when trying to fix it:

Currently, I am trying to build editor and export a template with debugging symbols to find the line where it's crashing, but I found nothing.

and in the label: crash

I think it would be clearer to add the words crash in both the title and bug description instead of "strange bug" because it's not clear what the issue is without running the MRP (esp. if it only happens on a certain device).

Anyway, I'll be following the other shader-related crash issues, so this is just to help other users find things more easily.

@Alex2782
Copy link
Contributor

@hsandt: uniform crash on some android devices (Xiaomi Redmi 7A, Google Pixel 2 XL)

#85097
#82602
#86037


I've had this on my TODO list for a while, but haven't found enough time to check it out again. I would have to try it on Firebase Test Lab because I don't have the hardware to reproduce it.

@Alex2782
Copy link
Contributor

Alex2782 commented Mar 28, 2024

maybe only Adreno 5xx affected by the uniform crash

  • Google Pixel 2 XL: Adreno (TM) 540
  • Xiaomi Redmi 7A: Adreno (TM) 505
  • Mi A2 Lite: Vulkan 1.1.87 - Forward Mobile - Using Device #0: Qualcomm - Adreno (TM) 506
Test on Firebase (Mi A2 Lite)

After a few seconds, a shader is dynamically attached to CanvasItem, after which the app crashes.

web-build_20240328_nyxe_daisy_sprout-29-en_US-landscape_video.mp4

@Ayush-Agarwal123
Copy link

Ayush-Agarwal123 commented Apr 22, 2024

Is there any update on this crash? I am facing it on Godot version 4.2.1 also which is the latest stable version
Device: OnePlus 3

@Alex2782
Copy link
Contributor

  • OnePlus 3: Adreno (TM) 530

I gave up 3 weeks ago, it takes too much time to test on Firebase (cloud service). I only have Adreno 6xx and 4xx. On Adreno 4xx Godot Vulkan apps do not start at all, the official demo app from Google does, so I will prefer the Adreno 4xx problems first, as long as I don't have Adreno 5xx yet.

@Alex2782

This comment was marked as outdated.

@Alex2782
Copy link
Contributor

no crash if all nodes have a uniform shader.

Video: Firebase Test Lab
web-build_20240522_ds2a_daisy_sprout-29-en_US-landscape_video.mp4

It looks to me as if the commands have to be executed in the correct order (on Adreno 5xx):
RenderingDeviceGraph::_run_draw_list_command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants