Live Video Slows/Crashes Over Time

Required Information

DIETPI VERSION

  • G_DIETPI_VERSION_CORE=9
  • G_DIETPI_VERSION_SUB=10
  • G_DIETPI_VERSION_RC=0
  • G_GITBRANCH=‘master’
  • G_GITOWNER=‘MichaIng’
  • G_LIVE_PATCH_STATUS[0]=‘applied’

DISTRO VERSION

  • bookworm 0

KERNAL VERSION

  • Linux DietPi 6.6.74+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64 GNU/Linux

ARCHITECTURE

  • arm64

SBC MODEL

  • RPi 3 Model B+ (aarch64)

POWER SUPPLY USED

SD CARD USED

  • None.
  • Using a 32GB Sandisk USB3 for boot (I know… 3b doesn’t have USB 3).

GOALS

First, I want to thank everyone for their time and effort on here. I have overcome many obsticles thanks to the questions that have been asked an answered on this forum, as well as the attention to detail by the developers.

My kitchen cabinets are hollow so I decided to cut one open to put a Rasbperry Pi 3b+ in it with a WaveShare 7" touchscreen positioned vertically. The primary reason is to have the live view of my outdoor security cameras always on. My secondary reason is that I like to cook and often look up recipes. It’s a lot easier to have something right there instead of my phone which gets in the way or the screen turns off.

SO FAR…

I’ve been fighting the urge to throw my Pi4 in there. The 3b+ should be good enough and has less issues with overheating (though I will still have to put a small fan in). I had tried a few different distros which failed to do what I needed. Even DietPi didn’t work out until I discovered the chromium kiosk mode. I figured without the desktop overhead, it just might work. I was right.

Sort of.

There are two hiccups left. The video feed of the three cameras I want displayed works fine and flawlessly for over an hour. After some point, however, everything slows down to a crawl and after more time it completely freezes. I figure this has to be some issue with the browser caching the data, but I’m not sure. It’s a weird situation where I can’t find the right keywords that don’t include a whole bunch of stuff not at all relevant to my issue. I see two solutions: a script/chron to automatically exit and restart the kiosk after X amount of time or something similar to reboot the whole thing. I’d rather not do this, especially in case it happens to happen when I’m cooking. Also I’d personally prefer a more elegant solution if one is available.

Thoughts?

Thank you!


Edit - Feb 13, 2025 0927 EST: I’ve taken steps to act on the suggestion from Joulinar. I set everything to the planned final configuration and have started taking screenshots of the htop output over time accessed via SSH. The total memory usage has crept up by 13M over the last 18 minutes. I will continue to monitor it and post when I have more conclusive results.

A little idea. Have you ever tried to monitor the SBC? In other words, log in via SSH and see how the CPU + memory utilisation behaves? This should be possible with htop. Maybe also keep an eye on the temperature. Perhaps this will give you an indication of why it is slowing down.

1 Like

I let it run for approximately 1.5 hours and took a screenshot of the htop readings at the beginning and end. Two intermittent screenshots between those times showed a gradual increase of the three values I believe to be pertinent.

The total memory usage increased from 406M to 502M out of 907M total. I cut the image to get rid of the noise and made sure the lines with the two highest values made it. I marked them with red lines. Those also showed a gradual increase over time starting with 239M/303M and ending with 260M/376M, respectively - an increase of 21M/73M over the 1.5 hours.

I think it’s pretty safe to say this trend will continue until it becomes unusable, eventually grounding to a frozen halt. The question now is: how do I stop this from happening?


Edit: Chrome has always been garbage. I normally use Firefox, but I only saw Chrome --Kiosk in the dietpi list. I’m going to check to see if there is a Firefox Kiosk mode that doesn’t use the desktop at all.

Also, given that this appears to be a Chrome memory management issue, I tried turning the memory saver on (which doesn’t look like it should actually help because it deals with inactive tabs) and I disabled the website preloading in case that’s causing the issue. When I opened a new tab and went back to the camera view, the memory usage jumped back up almost to what it was after the 1.5 hours. I haven’t rebooted, so this still appears to be some caching issue.

Honestly, I have no idea at hand for this as it seems to be related to the app itself. :frowning:

1 Like

I think the evidence shows you are correct. At least it gives me multiple avenues to go from and my search queries are now narrowed to Chrome for a solution, or Firefox for an alternative.


EDIT: I got the Firefox workaround running! I’ve yet to determine if it will be fast enough or if it will persist without the memory issues, but I have hope. I was able to run Firefox without the desktop environment. It’s not kiosk mode, but I really just did that to easily ditch the desktop overhead. This was very easy, only taking three steps:

1. dietpi-config to change autostart to autologin via terminal.
2. Ran the “X” command from the Pi.
3. Ran “DISPLAY=:0 firefox” from SSH terminal.

I’ll make a post after I test more.

**EDIT 2: I ran the X command from the Pi and had to use SSH to start Firefox. I could’ve just piped the DISPLAY=:0 firefox after the X i.e. X|DISPLAY=:0 firefox

Dammit. The video stream is failing to load. The terminal spit out the following:

[Child 1906, MediaDecoderStateMachine #1] WARNING: Decoder=7efa1fbb00 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - Error no decoder found for audio/mp4a-latm: file ./dom/media/MediaDecoderStateMachineBase.cpp:167

I’m trying to find a solution now. Has anyone encountered anything like this?

sudo apt install libavcodec-extra58

That successfully installed the required codec to get the video running and stop the errors. Unfortunately, it was slow as hell. I don’t know if it was a problem with the codec, the browser, something else, or some combination. It appears that running this in chromium is the best option.

So now I have to solve the slow resource eating problem I’m facing. I believe I’ve found a solution in the form of a policy.

BrowsingDataLifetime should give me the ability to set a TTL for specific types of data. Unfortunately, I can’t find it and am beginning to think it’s not part of Chromium. I also just ran a test to clear the browser cache which did nothing to free up the resource problem. I suppose once it’s loaded into RAM, the cache on the disk doesn’t matter. RAM is the issue.

This might be Chromium, but the OS has control over the RAM. Can anyone help me? Is there a way to limit the resources a certain app can use, or some other solution I’m not seeing?

I’m pretty much talking to myself, so for now I’m going to settle with what I have. Thank you again Joulinar for your help. I decided to write a BASH script to automatically reboot if too much RAM gets used. Now that it’s done I’m thinking I should’ve also had it write to the system.d journal. I can see myself forgetting about this, using it for something else and wondering why it keeps rebooting when I tax it. :rofl:

The script is pasted below. I have a cron job running it every 30 minutes. A log file is written so I can go back and see how many times it’s been activated.

mem_total=$(sed -n "1s/[^0-9]//gp" /proc/meminfo)  # First line of /proc/meminfo set as total memory.
mem_used=$(sed -n "2s/[^0-9]//gp" /proc/meminfo)   # Second line of /proc/meminfo set as used memory.
percent=$(( (mem_used * 100) / mem_total ))
echo "Total Memory: $mem_total kB
Memory Used: $mem_used kB
Percent: $percent %"                               # Output the current RAM usage.
if [  "$percent" -gt 80 ]; then                    # Check if more than 80% of the RAM is being used. 
    echo "Memory usage is above threshold. Rebooting..."
	datetime=$(date '+%Y-%m-%d %H:%M:%S')          # Set the current date and time. 
	echo "$datetime - Reboot" >> "reboot.log"      # Save datetime line to file for log.
	sleep 2                                        # Give a little time for user to read the output.
	reboot
fi

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.