godot icon indicating copy to clipboard operation
godot copied to clipboard

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

Open marko995 opened this issue 1 year ago • 44 comments

Godot version

4.0, 4.1, 4.1.1

System information

Godot v4.1.1.stable (bd6af8e0e) - 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 avatar Jul 21 '23 18:07 marko995

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.

Sauermann avatar Jul 23 '23 07:07 Sauermann

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

marko995 avatar Jul 23 '23 14:07 marko995

Can you help me with debugging?

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

Sauermann avatar Jul 23 '23 14:07 Sauermann

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

marko995 avatar Jul 23 '23 14:07 marko995

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.

Sauermann avatar Jul 23 '23 14:07 Sauermann

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 avatar Aug 07 '23 12:08 bemyak

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

bemyak avatar Aug 07 '23 12:08 bemyak

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

Zireael07 avatar Aug 07 '23 12:08 Zireael07

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.

Alex2782 avatar Dec 10 '23 23:12 Alex2782

it still crashes

marko995 avatar Dec 11 '23 00:12 marko995

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.

Alex2782 avatar Dec 12 '23 12:12 Alex2782

still crashing..kk

marko995 avatar Dec 12 '23 13:12 marko995

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

marko995 avatar Dec 12 '23 13:12 marko995

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

marko995 avatar Dec 12 '23 14:12 marko995

@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

Calinou avatar Dec 12 '23 14:12 Calinou

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

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

Alex2782 avatar Dec 12 '23 15:12 Alex2782

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

when I don't use it, works fine

marko995 avatar Dec 12 '23 16:12 marko995

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 avatar Dec 12 '23 16:12 Alex2782

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

Alex2782 avatar Dec 12 '23 16:12 Alex2782

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.

marko995 avatar Dec 12 '23 16:12 marko995

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

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

Alex2782 avatar Dec 12 '23 16:12 Alex2782

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

marko995 avatar Dec 12 '23 17:12 marko995

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() {

}

Alex2782 avatar Dec 12 '23 21:12 Alex2782

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 avatar Dec 12 '23 21:12 marko995

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

marko995 avatar Dec 12 '23 21:12 marko995

@Alex2782 is it possible to use source_color without uniform ?

marko995 avatar Dec 12 '23 21:12 marko995

@Alex2782 also this doesn't work

shader_type canvas_item;

uniform vec3 color : source_color;

void fragment() {
	
}

marko995 avatar Dec 12 '23 21:12 marko995

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

shader_type canvas_item;

uniform vec4 color;

void fragment() {
	
}

marko995 avatar Dec 12 '23 21:12 marko995

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.

Alex2782 avatar Dec 12 '23 21:12 Alex2782

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

marko995 avatar Dec 12 '23 21:12 marko995