kivy: Segmentation fault in Raspberry 3B+
Versions
- Python: 3.5.3
- OS: Raspbian GNU/Linux 9.4 (stretch)
- Kivy: v1.11.0.dev0, git-916b77b, 20181022
- Kivy installation method: sudo pip3 install git+https://github.com/kivy/kivy.git@master
Description
I am trying to execute the demo app_with_kv.py
but it shows a segmentation fault
error always. I am using the TFT screen from here.
Code and Logs
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_18-10-22_12.txt
[INFO ] [Kivy ] v1.11.0.dev0, git-916b77b, 20181022
[INFO ] [Python ] v3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516]
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: egl_rpi
[INFO ] [GL ] Using the "OpenGL ES 2" graphics system
[INFO ] [GL ] Backend used <sdl2>
Segmentation fault
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 44 (11 by maintainers)
Had similar issue with it. For some reason,
sdl2
is called instead of thegl
for Backend. I do not know if there is a permanent fix for this, but after some time trying to find a fix, the only solution I could come up with is this to add 2 lines on top of your app, before you import Kivy. Should look like this:Hope it will help. Good luck!
P.s. If you want to run your app on Windows you might want to comment
os.environ['KIVY_GL_BACKEND'] = 'gl'
otherwise it will not run.OK, look like SDL_GL_GetProcAddress can’t find anything 😦 I understand now. Our method to detect and load opengl is tied to the Window provider used. But in this case,
egl_rpi
is used, not SDL2, therefore the SDL2 function will not work.It requires a fix, thanks for reporting!
I also confirm that @goadik 's solution works! And I also point out that as it is an environment variable problem, you can simply export the variable as follows:
And then execute the script.
I’m planning to fix it in the post release.
On Wed, Jun 12, 2019, 1:11 PM RafalSkolasinski notifications@github.com wrote:
I had simliar problems with the actual raspbian lite os (2020-05-27) --> after first loading I got segmentation fault. Than I tried the switching to ‘gl’. After that I gt a whichte screen and a black cursor without any contesnts from my GUI. If I swiched back to a previusly raspbian lite it works with Kivy 1.11.1. Actually I do not know what exactly is the difference. Seems that there are some updates which cause this issue (libs, firmware…?). I luckily backed up the old sd card and restore it for my actually used GUI. I decided to use Kivy because of the reason that I do not need to install X11. My GUI is running in the console…
To confirm a build using the latest stable (1.11.0) in a fully up to date stretch-lite installation on any RPI causes this segmentation fault. Must build stable-1.10.1 to run on an RPI. I am not sure why you would release a stable that has had this problem on a major platform for over 6 months.
Still no solution to this?
os.environ[‘KIVY_GL_BACKEND’] = 'gl’doesn’t help at all with v1.11.0.dev0, git-9ebad2d, 20190516
Getting: [CRITICAL] [App ] Unable to get a Window, abort
And with older version like 1.10.1 I don’t get any transparent PNG support…all transparent PNGs are drawn with a black background…same code works fine on Debian 9 though …
So will RPi Stretch-Lite never be supported again?
Not sure if it is relevant to add here but I think it got something to do with the new version of Raspbian. I tried the older one (I have an image) and it worked like a charm.
The problem with segmentation fault on app start can be fixed with an environment variable, but also, it crashes with the same segmentation fault every time I load the graph with lots of data on it to show.
The problem with GDB is that if I try to use it like that
gdb --args python main.py
and replicate the crash, RPI just freezes and the only thing left to do at this point is just to restart it. When I check the logs they are empty.Wanted to add it here.