KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

Bug on android related to shaders

Open Neizvestnyj opened this issue 2 years ago • 1 comments

Full log

09-18 01:41:14.903 21996 22024 I python  : AND: Ran string
09-18 01:41:14.903 21996 22024 I python  : Run user program, change dir and execute entrypoint
09-18 01:41:15.019 21996 22024 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/<APP>/files/app/.kivy/logs/kivy_22-09-18_1.txt
09-18 01:41:15.019 21996 22024 I python  : [INFO   ] [Kivy        ] v2.1.0
09-18 01:41:15.019 21996 22024 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/<APP>/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
09-18 01:41:15.019 21996 22024 I python  : [INFO   ] [Python      ] v3.9.9 (main, Sep 18 2022, 01:31:35) 
09-18 01:41:15.019 21996 22024 I python  : [Clang 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb
09-18 01:41:15.020 21996 22024 I python  : [INFO   ] [Python      ] Interpreter at ""
09-18 01:41:15.020 21996 22024 I python  : [INFO   ] [Logger      ] Purge log fired. Processing...
09-18 01:41:15.021 21996 22024 I python  : [INFO   ] [Logger      ] Purge finished!
09-18 01:41:15.714 21996 22024 I python  : [INFO   ] [Factory     ] 189 symbols loaded
09-18 01:41:15.959 21996 22024 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
09-18 01:41:15.989 21996 22024 I python  : [INFO   ] [Window      ] Provider: sdl2
09-18 01:41:16.008 21996 22024 I python  : [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
09-18 01:41:16.009 21996 22024 I python  : [INFO   ] [GL          ] Backend used <sdl2>
09-18 01:41:16.009 21996 22024 I python  : [INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.2 [email protected] (GIT@033a5b0, I0e419467bc, 1583931100) (Date:03/11/20)'>
09-18 01:41:16.010 21996 22024 I python  : [INFO   ] [GL          ] OpenGL vendor <b'Qualcomm'>
09-18 01:41:16.010 21996 22024 I python  : [INFO   ] [GL          ] OpenGL renderer <b'Adreno (TM) 630'>
09-18 01:41:16.010 21996 22024 I python  : [INFO   ] [GL          ] OpenGL parsed version: 3, 2
09-18 01:41:16.010 21996 22024 I python  : [INFO   ] [GL          ] Texture max size <16384>
09-18 01:41:16.011 21996 22024 I python  : [INFO   ] [GL          ] Texture max units <16>
09-18 01:41:16.031 21996 22024 I python  : [INFO   ] [Window      ] auto add sdl2 input provider
09-18 01:41:16.032 21996 22024 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
09-18 01:41:16.034 21996 22024 I python  : [INFO   ] [KivyMD      ] 1.1.0.dev0, git-Unknown, 2022-09-17 (installed at "/data/user/0/<APP>/files/app/_python_bundle/site-packages/kivymd/__init__.pyc")
09-18 01:41:16.040 21996 22024 I python  : [INFO   ] [Text        ] Provider: sdl2
09-18 01:41:16.311 21996 22024 I python  : [INFO   ] [GL          ] NPOT texture support is available
09-18 01:41:16.332 21996 22024 I python  : [WARNING] [Base        ] Unknown <android> provider
09-18 01:41:16.333 21996 22024 I python  : [INFO   ] [Base        ] Start application main loop
09-18 01:41:16.601 22032 22032 F DEBUG   :       #06 pc 00006803  /data/data/<APP>/files/app/_python_bundle/site-packages/kivy/graphics/vbo.so

After android app start I get error:

09-18 00:04:30.928 30527 30527 F DEBUG   :       #04 pc 0000000000009e40  /data/data/<APP>/files/app/_python_bundle/site-packages/kivy/graphics/vbo.so
09-18 00:04:30.928 30527 30527 F DEBUG   :       #05 pc 00000000000073c8  /data/data/<APP>/files/app/_python_bundle/site-packages/kivy/graphics/compiler.so
requirements = kivy==master, pyjnius, https://github.com/kivymd/KivyMD/archive/master.zip
android.api = 33
android.ndk = 25

If I use kivymd==1.0.2 - all fine

Neizvestnyj avatar Sep 17 '22 22:09 Neizvestnyj

https://discord.com/channels/566880874789076992/566880874789076994/1015860048381083678

This is because of opengl

https://github.com/kivymd/KivyMD/issues/1327

T-Dynamos avatar Sep 18 '22 11:09 T-Dynamos

Also seeing this on a Samsung Galaxy Tab S7 running Android 12. Reverting to a version before the elevation/shadow shader was implemented "solves" it. For example, dae1aede5b460b89b34c6900e2a714c2245697a5 seems to work (for my purposes at least).

@T-Dynamos, did you find any workaround or solution to this?

markqvist avatar Oct 02 '22 22:10 markqvist

@HeaTTheatR I see no defination of smoothstep function in elevation.frag https://github.com/kivymd/KivyMD/blob/master/kivymd/data/glsl/elevation/elevation.frag

Which is used in line

https://github.com/kivymd/KivyMD/blob/c59012117c8801c0cc9b75f05630884cef0c10a8/kivymd/data/glsl/elevation/elevation.frag#L24-L42

After adding

float smoothstep(float a, float b, float x) {
    float t = clamp((x - a) / (b - a), 0.0, 1.0);

    return t * t * (3.0 - (2.0 * t));
}

It works but, Running this code

from kivy.lang import Builder
from kivymd.app import MDApp

KV = """
MDRelativeLayout:
	md_bg_color:0,0,0,1
	MDCard:
		pos_hint:{"center_x":0.5,"center_y":0.5}
		md_bg_color:1,0,0,1
		size_hint:0.5,0.5
		elevation:2
"""

class App(MDApp):
	
	def build(self):
		return Builder.load_string(KV)
		
App().run()

Shadow is broken Screenshot_2022-10-03-08-30-32-210_ru iiec pydroid3

T-Dynamos avatar Oct 03 '22 03:10 T-Dynamos

I found this app to test shaders https://play.google.com/store/apps/details?id=de.markusfisch.android.shadereditor https://www.shadertoy.com/view/fsdyzB Screenshot_2022-10-03-10-27-07-858_de markusfisch android shadereditor

T-Dynamos avatar Oct 03 '22 04:10 T-Dynamos

I think so problem still persists @Neizvestnyj can you test?

T-Dynamos avatar Oct 07 '22 12:10 T-Dynamos

Yes, problem exists. @HeaTTheatR Reopen issue please.

10-14 22:01:31.194 23929 23957 I python  : [INFO   ] [Kivy        ] v2.1.0
10-14 22:01:31.194 23929 23957 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/org.test.myapp/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
10-14 22:01:31.194 23929 23957 I python  : [INFO   ] [Python      ] v3.9.9 (main, Oct 14 2022, 21:51:47) 
10-14 22:01:31.194 23929 23957 I python  : [Clang 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb
10-14 22:01:31.194 23929 23957 I python  : [INFO   ] [Python      ] Interpreter at ""
10-14 22:01:31.195 23929 23957 I python  : [INFO   ] [Logger      ] Purge log fired. Processing...
10-14 22:01:31.195 23929 23957 I python  : [INFO   ] [Logger      ] Purge finished!
10-14 22:01:31.198 23929 23957 I python  : [INFO   ] [Factory     ] 189 symbols loaded
10-14 22:01:32.072 23929 23957 I python  : [INFO   ] [KivyMD      ] 1.2.0.dev0, git-Unknown, 2022-10-14 (installed at "/data/user/0/org.test.myapp/files/app/_python_bundle/site-packages/kivymd/__init__.pyc")
10-14 22:01:32.106 23929 23957 I python  : [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2 (img_pil, img_ffpyplayer ignored)
10-14 22:01:32.130 23929 23957 I python  : [INFO   ] [Text        ] Provider: sdl2
10-14 22:01:32.159 23929 23957 I python  : [INFO   ] [Window      ] Provider: sdl2
10-14 22:01:32.178 23929 23957 I python  : [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
10-14 22:01:32.182 23929 23957 I python  : [INFO   ] [GL          ] Backend used <sdl2>
10-14 22:01:32.182 23929 23957 I python  : [INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.2 [email protected] (GIT@033a5b0, I0e419467bc, 1583931100) (Date:03/11/20)'>
10-14 22:01:32.182 23929 23957 I python  : [INFO   ] [GL          ] OpenGL vendor <b'Qualcomm'>
10-14 22:01:32.183 23929 23957 I python  : [INFO   ] [GL          ] OpenGL renderer <b'Adreno (TM) 630'>
10-14 22:01:32.183 23929 23957 I python  : [INFO   ] [GL          ] OpenGL parsed version: 3, 2
10-14 22:01:32.183 23929 23957 I python  : [INFO   ] [GL          ] Texture max size <16384>
10-14 22:01:32.183 23929 23957 I python  : [INFO   ] [GL          ] Texture max units <16>
10-14 22:01:32.213 23929 23957 I python  : [INFO   ] [Window      ] auto add sdl2 input provider
10-14 22:01:32.214 23929 23957 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
10-14 22:01:32.272 23929 23957 I python  : 1.2.0.dev0
10-14 22:01:32.395 23929 23957 I python  : [WARNING] [Base        ] Unknown <android> provider
10-14 22:01:32.395 23929 23957 I python  : [INFO   ] [Base        ] Start application main loop
10-14 22:01:32.399 23929 23957 I python  : [INFO   ] [GL          ] NPOT texture support is available
10-14 22:01:32.724 23966 23966 F DEBUG   :       #04 pc 0000000000009e38  /data/data/org.test.myapp/files/app/_python_bundle/site-packages/kivy/graphics/vbo.so

Neizvestnyj avatar Oct 14 '22 19:10 Neizvestnyj

Can also confirm the problem persists. On all of the devices I have available to test with, it only happens on one with an Adreno GPU, which matches above cases too.

markqvist avatar Oct 14 '22 22:10 markqvist

Now I think so Adding

	<uses-feature
		android:glEsVersion="0x00020000"
		>

in manifest is the solution

See : https://stackoverflow.com/questions/52801644/android-opengl-app-crashes-when-creating-the-shader

I also confirm that line in this app https://play.google.com/store/apps/details?id=de.markusfisch.android.shadereditor

Because this app able to run same shader Screenshot_2022-10-15-08-16-15-543_com gmail heagoo apkeditor pro image

T-Dynamos avatar Oct 15 '22 02:10 T-Dynamos

Can I get an apk for testing?

T-Dynamos avatar Oct 15 '22 03:10 T-Dynamos

I already have the GLES version set in AndroidManifest, and the crash still occurs, unfortunately: https://github.com/markqvist/Sideband/blob/main/sbapp/patches/AndroidManifest.tmpl.xml#L25

I am currently disabling the elevation shader completely in my shipped APKs to avoid the issue, so the APKs on my repo does not crash on Adreno GPU. But if you need it for testing, I can build one with shaders enabled for testing.

markqvist avatar Oct 15 '22 09:10 markqvist

@HeaTTheatR Set Bug label (High priority)

Neizvestnyj avatar Oct 22 '22 09:10 Neizvestnyj

@Neizvestnyj Done!

HeaTTheatR avatar Oct 22 '22 09:10 HeaTTheatR

If someone can test if this bug persist with the new kivy master version (2.2.0), it will be appreciated. I did a PR (https://github.com/kivy/kivy/pull/8043) to update the SDL version to 2.24.1 and this version include some bug fix on Open GL 2 ES compilation.

mp-007 avatar Oct 28 '22 17:10 mp-007

Update: p4a need to be also updated. I have asked an update in this pull request https://github.com/kivy/python-for-android/pull/2692 to include all bug fix with the open gl 2, but we need to wait the next SDL release. ~~An other thing that I realized is that the SDL version 2.24.1 doesn't changed anything in Open GL 2 ES compilation, but everything should be add in version 2.25.0 (not release yet)~~

To be continued....

mp-007 avatar Nov 04 '22 14:11 mp-007

We can check these PR - https://github.com/kivy/kivy/pull/8056 - that have not yet been merged into the Kivy master branch. If this is merged and it works well, then we can use this solution in the KivyMD library. However, I was unable to test this PR myself, as I failed to compile Kivy with this PR.

Снимок экрана 2022-11-20 в 11 46 49

HeaTTheatR avatar Nov 20 '22 08:11 HeaTTheatR

for long term solution I think that https://github.com/kivy/kivy/pull/8056 will be a better solution, but it can be good to test the new commit https://github.com/kivy/python-for-android/commit/e14bdfc92f8fd369b21b4f3a8dfd601ea1a3f90d merged into develop branch. It's included several bug fix in opengl es 2.0 from SDL 2.24.1 and 2.26.0 that maybe help to solve our issue.

mp-007 avatar Nov 29 '22 14:11 mp-007

@mp-007 I'll try to watch it on the weekend.

HeaTTheatR avatar Nov 29 '22 14:11 HeaTTheatR

Can someone please clarify how i get past this issue or are we still waiting on something to be merged / reviewed / fixed ? I'm still un able to compile my app on kivyMD 1.1.1 due to this issue and i''m not clear on what i have to do to make it work. Cheers

LazzaAU avatar Dec 10 '22 05:12 LazzaAU

Can

Can someone please clarify how i get past this issue or are we still waiting on something to be merged / reviewed / fixed ? I'm still un able to compile my app on kivyMD 1.1.1 due to this issue and i''m not clear on what i have to do to make it work. Cheers

I am facing the same problem. The AndroidManifest has <uses-feature android:glEsVersion="0x00020000" /> So as @LazzaAU mentioned above, where we are now?

Thanks in advance.

andmart avatar Dec 11 '22 19:12 andmart

Since the question has been open for almost 3 months, I found only one solution for myself, to completely disable shadows by editing "uix/behavior/elevation.py" class CommonElevationBehavior. if it helps someone, I attached a file where I commented the lines that were related to the creation of shadows, and tested it by replacing the elevation.py file in master.zip and in buildozer.spec I wrote the path to the zip instead of kivymd, everything works on the commit 7b1e72. This permanently disables shadow creation. This is a workaround, not a fix, so we're waiting for a fix. elevation.zip

YaROKer avatar Dec 14 '22 11:12 YaROKer

I tested the PR - and it works. Now I'm refactoring ElevationBehavior class according to the changes in this PR. And while this PR has not yet been merged, you can use the Kivy installation as follows - pip install git+https://github.com/DexerBR/kivy.git@boxshadow_instruction and use KivyMD library from master branch.

HeaTTheatR avatar Dec 14 '22 14:12 HeaTTheatR

@HeaTTheatR, may be a stupid question, but how to write it (pip install git+https://github.com/DexerBR/kivy.git@boxshadow_instruction) in buildozer.spec?

PythonLaboratory avatar Dec 14 '22 19:12 PythonLaboratory

@PythonLaboratory requirements = git+https://github.com/DexerBR/kivy.git@boxshadow_instruction, https://github.com/kivymd/KivyMD/archive/master.zip

HeaTTheatR avatar Dec 14 '22 20:12 HeaTTheatR

@HeaTTheatR, thanks, i will try

PythonLaboratory avatar Dec 14 '22 20:12 PythonLaboratory

@

@HeaTTheatR, thanks, i will try

I haven't made any changes to the KivyMD master branch yet. It will be done in two or three hours.

HeaTTheatR avatar Dec 14 '22 20:12 HeaTTheatR

@HeaTTheatR

@PythonLaboratory requirements = git+https://github.com/DexerBR/kivy.git@boxshadow_instruction, https://github.com/kivymd/KivyMD/archive/master.zip

when i write like this requirements = git+https://github.com/DexerBR/kivy.git@boxshadow_instruction, https://github.com/kivymd/KivyMD/archive/master.zip buildozer throws an error

Updated build/lib.linux-x86_64-cpython-39/kivy/include/config.h

  Updated kivy/include/config.h
  Updated build/lib.linux-x86_64-cpython-39/kivy/include/config.pxi
  Updated kivy/include/config.pxi
  Updated build/lib.linux-x86_64-cpython-39/kivy/setupconfig.py
  Updated kivy/setupconfig.py
  Detected compiler is unix
   error: command '/home/suser/.buildozer/android/platform/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit code 1
  error: subprocess-exited-with-error
 
  × Building wheel for Kivy (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/suser/Projects/TextInputTest/.buildozer/android/platform/build-arm64-v8a/build/venv/bin/python /home/suser/Projects/TextInputTest/.buildozer/android/platform/build-arm64-v8a/build/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpklha_0ah
  cwd: /tmp/pip-req-build-cfyra79e
  Building wheel for Kivy (pyproject.toml) ... error
  ERROR: Failed building wheel for Kivy
  Running command Building wheel for kivymd (pyproject.toml)
  Ignoring "sys._home = value" override
  fatal: not a git repository (or any of the parent directories): .git
  /tmp/pip-build-env-sgjdyvi5/overlay/lib/python3.9/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
    warnings.warn(msg, warning_class)

but when I write pip install git+https://github.com/DexerBR/kivy.git@boxshadow_instruction all OK

PythonLaboratory avatar Dec 15 '22 18:12 PythonLaboratory

@PythonLaboratory Yes, I also got this error.

HeaTTheatR avatar Dec 15 '22 19:12 HeaTTheatR

@HeaTTheatR, how fix it?

PythonLaboratory avatar Dec 15 '22 19:12 PythonLaboratory

@PythonLaboratory I have no idea.

HeaTTheatR avatar Dec 15 '22 19:12 HeaTTheatR

@HeaTTheat, sadness...

PythonLaboratory avatar Dec 15 '22 19:12 PythonLaboratory