elgatito / plugin.video.elementum

Elementum add-on for Kodi. Development of this addon has been stopped!
http://elementum.surge.sh
MIT License
485 stars 159 forks source link

Crash on start, kodi 21.1 flatpak, ubuntu 24.04 #1058

Closed kalaninja closed 1 month ago

kalaninja commented 2 months ago

Kodi crashes while starting if Elementum is enabled. When I disable it, everything works as expected.

Ubuntu 24.04 x86_64 Kodi 21.0 and 21.1 (both have this behaviour) installed with flatpak Elementum 0.1.103

Kodi log: https://pastebin.com/JHd9gcLh

antonsoroko commented 1 month ago

@kalaninja I had no crash with Kodi 21 from flatpak. And i just have checked with kodi 21.1 from flatpak - also no issue. I use Ubuntu 24.04.1 x86_64 with KDE (but this should not matter for flatpak).

If there was crash - there should be crash log in ${XDG_DATA_HOME} (e.g. kodi_crashlog-20240723_222243.log) - you can post it here, maybe it will help to identify the issue.

There is issue that sometimes flatpak kills elementum binary, but this is not elementum issue as i can see. Looks like jail/container restriction. see https://github.com/elgatito/plugin.video.elementum/issues/1051#issuecomment-2236760392 https://github.com/elgatito/plugin.video.elementum/issues/1051#issuecomment-2284692097

but i am not flatpak expert and i do not see anything suspicious in their code for kodi container - https://github.com/flathub/tv.kodi.Kodi/tree/master

simpledork47 commented 1 month ago

i've got similar issues (kodi 21.1 - linux amd64 debian testing )

that happened even with a "plain" kodi 21.1 install ( debian package from https://deb-multimedia.org/ / for testing/trixie)

in kodi logfile it looked like a network problem with JSON-RPC - elementum not being able to reach port 9090 whereas a debugging session didn't confirmed it ( netstat -lntp report 9090 as listening )

Same issue happened when I'm running kodi in flatpak

Btw I'm using Kodi Flatpak right now - with a custom build - for enabling HDR as described here https://github.com/flathub/tv.kodi.Kodi/issues/248 , it works really great (kodi GBM with GLES)

This afternoon I've tweaked a bit elementum and it finally fixed it Elementum > Settings > Advanced > "Force start as library" toggled

now elementum works perfectly, with kodi 21.1 within Flatpak

(didn't tested w/ debian package again)

antonsoroko commented 1 month ago

This feature was created specifically for new androids where new Kodi (complied with new android sdk) was not permitted to run binaries. As I have seen it works a bit less stable than separate process, but stable enough. I guess it should fix issue when flatpak kills Elementum process (since there is no process, Elementum is injected into Kodi process).

kalaninja commented 1 month ago

Thanks for the reply. Really appreciate.

Yes, my issue looks very much like the one mentioned in the link. I'll try to use the "Elementum > Settings > Advanced > "Force start as library" workaround.

kalaninja commented 1 month ago

@simpledork47 @antonsoroko I tried to set "Elementum > Settings > Advanced > "Force start as library" feature toggle. Kodi starts up fine now. But every time I start a video play, kodi crashes.

Kodi log: https://pastebin.com/FAh4UjLT Elementum log: https://pastebin.com/aMABENA2

the crash log is not created.

simpledork47 commented 1 month ago

@kalaninja

On log file there's a folder for Download set:/home/kalan/Videos

Regular flatpak application can't see much outside of ~/.var/app/<application_id>

Could you verify this on your side ?

flatpak info --show-permissions tv.kodi.Kodi

... filesystems=/mnt;xdg-pictures;xdg-videos;/run/udev:ro;/run/lirc;xdg-music;/media;/run/media

=> That's the line to look for

You can check if there's some additional paths granted: flatpak override --show tv.kodi.Kodi

Granting access to your homedir flatpak override tv.kodi.Kodi --filesystem=home

antonsoroko commented 1 month ago

by default it has xdg-videos from https://docs.flatpak.org/en/latest/sandbox-permissions.html xdg-videos | Access the XDG videos directory | $XDG_VIDEOS_DIR or $HOME/Videos

so it it not the issue.

antonsoroko commented 1 month ago

I was able to reproduce the bug (it happens on my system every time), and once i was able to catch golang stack trace for SIGSEGV.

elementum 1058 flatpak crash library mode.txt

but i do not see the root cause. maybe @elgatito can take a look into it.

simpledork47 commented 1 month ago

sorry for the previous noise, I didn't tested long enough. Sometimes it's ok, and most of the time it either crash when a video is about to play or even play ok but once stopped it's a crash.

I've looked carefully, getting back to regular "elementum" process (no library anymore)

First strange thing is lockfile : it gets resolved to addons/plugin.video.elementum/.lockfile insted of userdata/addon_data/plugin.video.elementum/.lockfile (this one exists on disk).

If I remove manually the file prior to run flatpak : all is working

I've made a pull-request with 2 changes ( fixing lockfile path ) and removing this file only if the system is detected as flatpak

antonsoroko commented 1 month ago

@simpledork47

JFYI:

in kodi logfile it looked like a network problem with JSON-RPC - elementum not being able to reach port 9090 whereas a debugging session didn't confirmed it ( netstat -lntp report 9090 as listening )

elementum tries to connect to localhost with ipv4 and ipv6, that's why you saw "error" in log. i guess you saw

warning <general>: [plugin.video.elementum] DEBU  xbmc         ▶ Init             Could not connect to the host ::1: dial tcp [::1]:9090: connect: connection refused

but if later in log you see

warning <general>: [plugin.video.elementum] DEBU  xbmc         ▶ Init             Adding local host 127.0.0.1

then everything is ok.

it just means that kodi does not listen on ipv6 local address.

https://github.com/elgatito/elementum/blob/de4ac744eaa7e26131f4d4bea3da0d4ed01348f0/xbmc/jsonrpc.go#L43

antonsoroko commented 1 month ago

@simpledork47

please try with plugin.video.elementum-v0.1.103-5-g5f482fc.linux_x64.zip it has fix for this issue and for alerts issue.

alternatively you can build it yourself: clone both repos, apply changes from PR, then in elementum directory: $ make linux-x64 linux-x64-shared in plugin.video.elementum directory: ./bundle.sh --target=$HOME/downloads/ --platform=linux_x64 --binaries=$HOME/work/elementum/build/ (i have both dirs in ~/work, change paths accordingly to your case)

see docs if needed: https://github.com/elgatito/plugin.video.elementum/blob/master/README.md#build https://github.com/elgatito/elementum/blob/master/README.md#easy-development-environment-set-up

simpledork47 commented 1 month ago

thanks @antonsoroko

I've installed your build and all is fine

kalaninja commented 1 month ago

It works on my side too. Thanks a lot @antonsoroko and @simpledork47