Playling Playlist dies after about 7 minutes - possible memory leak?

(Note: there is a copy of this thread on the Kodi forums: link)
Hi everyone, and thanks in advance for your help,

I am running OSMC 2021.12-1 (kernel: Linux 5.10.78-2-osmc) on a Raspberry Pi CM4 (2GB RAM, 32GB eMMC storage) and on the carrier board ‘TOFU’ (oratek).

I am using the skin Estuary and no special add-on to my knowledge.

Issue:
I have some custom-made m3u playlists that point to files stored in the SSD drive. When I read them, everything works perfectly for about 7 minutes, then I get a blue screen with a frowny face and Kodi restarts. The log file seems to point to an ffmpeg error with memory allocation on the heap.

The error always arises when switching from one video to another in the playlist, but happens regardless of the video (the playlist is randomized). The error is always identical. Here is the log.

The error is at the end of that log and is the following:

2022-01-21 14:34:33.951 T:1510     INFO <general>: ffmpeg[(nil)X]: Failed to alloc 12533760 from dma-heap(fd=176): 12 (Cannot allocate memory)
2022-01-21 14:34:33.951 T:1510    ERROR <general>: ffmpeg[(nil)X]: [hevc] v4l2_request_hevc_start_frame: Failed to get dst buffer

I found only one thread online with a similar issue here (I also have 4k video). But the “cma-512” solution was already in my /boot/config.txt as shipped by OSMC.

I tried creating a swap file to no effect (still same error after same amount of time).

I am out of ideas here as to what I could test, would anyone be able to help?

Many thanks,
Nara

Hmm. have about the same issue. Didn’t time it to 7minutes though.
My logs showed nothing (I admit, I’m not running in debug mode). Running the same skin estuary.
Kernel:$ uname -a
Linux vero4k2 4.9.113-60-osmc #1 SMP PREEMPT Sun Dec 19 23:56:28 UTC 2021 aarch64 GNU/Linux
And running on a vero4k2+.

The files are mounted through NFS partition/fstab - hence it seems local to kodi.
Playlist is the format: more than 3 stars, so it is dynamically extracted songs.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="songs">
    <name>3 Star</name>
    <match>all</match>
    <rule field="userrating" operator="greaterthan">
        <value>2</value>
    </rule>
    <order direction="ascending">random</order>
</smartplaylist>

It rather seems to be a kodi issue though. Files are regular ripped mp3’s (variable bit).
Movies work all fine.

We did some digging in the Kodi forum thread, and we found that the issue doesn’t happen in LibreELEC.

They seem to suggest the main difference in ffmpeg between LibreELEC and OSMC (at identical Kodi versions) is that LibreELEC has a patch that optimizes memory.

I’d like to try applying that patch to ffmpeg in OSMC to see if that fixes the issue, but I don’t know how to do it. Could anyone here give me some pointers?

Thanks!

We can synchronise with the GBM Matrix branch after Kodi v19.4 is released and hit that. Thanks for bringing it to my attention.

I am seeing a similar issue on a Pi 3B+ with playing a continuous slideshow of pictures and videos, I have an autoexec.py file which adds them from a folder. Things were fine with the 2021.11-2 version and after I upgraded it, Kodi would freeze after a few hours. I started afresh with the 2021.12-1 version, and that does the same. The processor load values seem to creep up slowly over time. Will logs be collected in such cases if I enable that?

Mon Jan 31 07:40:05 CST 2022
Kodi Version: 19.3
OSMC VERSION_ID=“2021.12-1”
temp=63.4’C
07:40:05 up 14:18, 1 user, load average: 2.22, 2.20, 2.18

Showing photos shouldn’t be affected unless videos also exist in this playlist.

The folder that I am copying the files from does contain both photos and videos. Digital picture frames do not seem to allow display of both together, it is one or the other, so OSMC/Kodi is a great alternative. For a while, with Kodi 18, that feature was lost, but fortunately it was restored later. With Kodi 17, I could even have background music which would stop during videos and restart for the pictures, but that feature was apparently something unintended and could not be brought back!

I tested with the latest OSMC release, and the display seems to freeze with the very first video. With the earlier releases, it would take more time. The 2021.08-1 version seems to be the only version which works properly. Now that Kodi 19.4 is incorporated, can this be looked into? Thanks.

After Debian Bullseye is released, I can merge further upstream changes, but this is lower on the list of priorities at this time

Sam

The latest release might have solved the issue of crashing the slideshow when playing playlists with photos and videos together, I don’t see the processor load values gradually increasing over time. Perhaps the other people who had this issue could also test and confirm? Thanks.

Thanks for the heads up, @nls!

I have tested with the new version, and unfortunately, the memory leak is still there in my originally described use case.

Looks like my setup also goes into a no video output state after a few days of the slideshow with mixed photos and videos. I did enable logging, but without a video output, I don’t quite know how to upload the logs. I can connect via ssh and see the logs in the .kodi/temp folder, I could transfer them to my laptop using WinSCP. I am not sure whether the logs are indeed correct, as I don’t see anything with earlier timestamps. Will it help if I put them on my Google drive and provide a link? Thanks.

grab-logs -A will upload them and you just need to share the URL.

Thanks. Looks like there were some errors with the upload, but it seems to have been successful, please see the following.

osmc@osmc:~/.kodi/temp$ grab-logs -A
Grabbing log UNAME …
Grabbing log cmdline …
Grabbing log Debian version …
Grabbing log OSMC Build Information …
Grabbing log Pi config …
Grabbing log Pi config-user …
Grabbing log GUI Settings (abridged) …
Grabbing log guisettings.xml …
Masking private information …
Grabbing log advancedsettings.xml …
An error occurred while grabbing advancedsettings.xml:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/osmc/.kodi/userd ata/advancedsettings.xml’
Grabbing log sources.xml …
Masking private information …
Grabbing log fstab …
Masking private information …
Grabbing log mounts …
Grabbing log OSMC Packages …
Grabbing log All Other Packages …
Grabbing log APT term.log …
Grabbing log APT history.log …
Grabbing log APT sources.list …
Grabbing log APT apt.conf.d …
Grabbing log APT preferences.d …
Grabbing log APT sources.list.d …
Grabbing log System Journal …
Grabbing log lircd.conf …
Grabbing log init.d …
Grabbing log systemd …
Grabbing log Kernel Message Log …
Grabbing log Memory …
Grabbing log Diskspace …
Grabbing log /boot Contents …
Grabbing log edid-decode …
/sys/class/drm/card0-HDMI-A-1/edid: No such file or directory
An error occurred while grabbing edid-decode:
subprocess.CalledProcessError: Command ‘[’/usr/bin/edid-decode’, ‘/sys/class/dr m/card0-HDMI-A-1/edid’]’ returned non-zero exit status 255.
Grabbing log ifconfig …
Grabbing log Kodi Log …
Masking private information …
Grabbing log Kodi Old Log …
Masking private information …
Writing logs to temp file …
Dispatching logs …
Logs successfully uploaded.
Logs available at https://paste.osmc.tv/kehanazika
osmc@osmc:~/.kodi/temp$

Just checking back to see if the logs were of any use. This is a standard installation, no customization except for the autoexec.py starting the slideshow with mixed photos and videos. It seems to run well for a few days, but then the processor load values seem to go up and the display is gone. Stopping and restarting Kodi seems to work sometimes, reboot is the only other option. Thanks.

Can you try removing photos temporarily and see if that helps the situation?

I have another slideshow running at a different location with just photos, no problem there. So it looks like videos are causing the problem.

After more testing, I think that this issue might be related to the TV used for the display. When I use an old Dynex 19" TV with a 1366 x 768 pixel resolution, I have the video freeze problem. But with a more recent 39" Samsung TV that has a 1920 x 1080 resolution, the problem does not seem to be there. Even if I use an old Dell 19" monitor which has a 1280 x 1024 resolution, with a HDMI to DVI adapter, the photo/video display continues on without any issues. The processor load values also seem to be more erratic when I use the Dynex as compared to the Samsung or Dell. Is there anything in the video drivers that gets impacted by the resolution? Is there any Kodi/OSMC setting that needs to be changed?