KivyMD: Bug on android related to shaders

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 V@415.0 (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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 38 (14 by maintainers)

Most upvoted comments

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

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.

When we add requirement=https:/..kivy...GitHub..link Bulldozer does not use its default kivy build recipe. To fix it, add custom p4a repo then change kivy download url then specify your fork in buildozer.spec file by using p4a.source_dir See : https://buildozer.readthedocs.io/en/latest/contribute.html?highlight=Fork#write-your-own-recipe

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.

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.

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

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.

@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

@HeaTTheatR Set Bug label (High priority)

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