Why the heck don't my cameras consistently load up when I load my lovelace dashboard?

On the back of my recent post about testing almost every single camera platform on Home Assistant:

I have only found one camera platform (the synology one) which will consistently load a stream on my lovelace dashboard and keep the stream running. Other platforms often fail to load one or more streams on the dashboard or will stop running during the stream.

These are against the same streams that my synology surveillance station and frigate/tensorflow/ffmpeg object detection run against without even noticeable dropped frames or artifacts, so I’m pretty sure the streams are fine…

Is there not a way to make our camera feeds load reliably and continue to stream in lovelace? As you can see I’m pretty deep into this already, so if there’s something you’d like me to test, I’d be happy to.

I use a few with generic and ffmpeg platforms and both methods are still terrible.

I think this has to do with the auth signature on initial load. I noticed a refresh of the browser after a restart generally works and I don’t have any issues after that until the next restart.

2 Likes

It varies greatly by camera platform… for HLS streams with the stream component enabled, reloading was my go to, it would fix it for a while but it didn’t seem like until the next restart… I think often it was only until I reopened my browser window.

For MJPEG cameras, however, it’s a complete crap shoot. Reloading may have same/other/more broken camera cards or they might all come up correctly.

The big thing I don’t get is if one of my picture entity cards fails to load the camera (especially MJPEG cameras) for whatever reason (I suspect it maybe has too short a timeout), why doesn’t it at least try again in a couple seconds?

Any time that I click on the blank camera card, the more info popup comes up with a perfectly working stream. Can’t it just keep retrying until it gets it?

I mean, if it doesn’t load right the first time, it will just sit there for hours with a blank card… Why?

2 Likes

+1 to this. I have set my tablet to automatically refresh the page every hour just to try and minimize the time I see the darn gray broken square

2 Likes

Thanks for raising this issue. I too have been struggling with the same challenge. I have several D-Link 2670L cameras around my house, connected via LAN and unfortunately HA lovelace just doesn’t consistenly work. Randomly every now and then (very rarely) some of the cameras show a live feed but 99% of the time show nothing, just a grey box in the picture entity card. And even clicking on the picture entity doesn’t stream, keeps trying to connect. Interestingly I have one camera from Hanwha (Samsung branded) , model QNO-7010R and this works 100% without a glitch. I tried a whole
new HA installation on a core i5 machine, thinking a more powerful platform would help, but to no avail. Exact same issue. Tried all sorts of protocols, frame rates, etc and none have helped. I’d be forever grateful if HA devs can fix this once and for all. Thanks.

1 Like

I have had the same problem. It has driven me crazy.
Made a lot of experiments, different cameras, different clients (in term of computers, tablets, phones, browsers, etc.).
I have 20+ cameras in different configurations, that is, wired ethernet, wifi or powerline.
The experiments have shown the following:

When opening the HA in the browser, most of the time, some picture glance entities do not show the live stream, some of the pictures are missing (blank) and/or frozen. Selecting detail, does show the life stream on each and everyone. The picture entities that do not show life stream are not the same every time. Changing the resolution of the camera to low does not seem to matter. If refreshing the browser, other picture may have the issue. One workaround I have found is changing to another tab in the browser then getting back to HA tab. It works most of the times.

I also noted that the issue is prone to manifest more frequently on cameras with wifi or powerline (weak connection) than wired ethernet. It is not a hard rule but more like an observation.

An interesting thing is looking to the task manager, performance, GPU, on the client machine. The CPU, memory, disk and ethernet usage are very low. In contast, the GPU utilization is very high, more camera you have, more it goes high. One of my machines is a Dell XPS 15 7590 with 2 GPU (Intel UHD Graphics 630 - GPU0 and Nvidia Geforce GTX 1650-GPU1). When starting HA in Firefox and select camera page, if the pictures are not frozen, the GPU0 goes almost 100%. By default the GPU used is GPU0. I have selected Firefox to go work with GPU1. From that moment on, the issue disappeared.
One strange thing is, even if the Firefox is instructed to work with GPU1 only, it still have the load divided to both GPU.
I have checked with another machine, a Dell T5500, XENON 12 cores, 24 logical and NVIDIA Quadro 5000. The GPU goes around 27% and there is no issue observed.
Using a tablet with an I7 6th gen and obviously the processor’s GPU the problem is permanent.

This might explain why issue appears mostly on machines that have weak GPU.

Thanks,
us

1 Like

It’s probably worth mentioning some of the reasons I think I have isolated for cameras not displaying correctly… Althought if you look at my “I tried all the cameras” post, you will note that the reliability score I put there are the cases where I don’t think it was these things that were causing the cameras to not display.

1) Overloaded CPU (/GPU?) on your server: Any time you are taking an h.264 stream and displaying it as MJPEG, there is one ffmpeg instance being created for each camera being displayed on each frontend device. 4 cameras being displayed on 3 devices? 12 instances. Each of these instances uses something like 8-10% of my CPU so displaying more than 8 of these cameras is impossible on my old core duo mac mini. I’ve never tried to see what was possible with GPU, my understanding from an FR is that the NUC hass.io image has the ability to use the intel integrated GPU, so people running intel NUC’s with hass.io may be utilizing GPU resources for this, so it would be good to check those too.

Solutions:

  1. Activate streaming component so that your cameras display as HLS instead of MJPEG (though you will pay for this with lag, which in my case is about 10 seconds.
  2. Use proxy camera component to re-serve the stream. This magically seems to not use much of any CPU, though it does also make the camera stream less reliable so that sometimes it still won’t come up.
  3. Buy a better server :wink:

2) Limited number of streams available from your camera

Some cameras will only allow one stream of a certain type or one stream at a time from a type of device. Keep in mind that generally homeassistant is not re-casting your streams. When you open a stream to display on the frontend, it opens that stream from the camera or DVR that you’ve configured. It means you are likely to have many streams going to the camera and/or DVR at once if you have multiple displays (like I do with my tablets).

A couple examples of this that I’ve encountered are that

  • My Hikvision cameras are only able to serve one MJPEG stream at a time, so the second device to try opening will get a blank card. They seem happy to stream many h.264 camera streams, though.

  • My reolink camera will only allow streaming via the app or via the stream that the reolink beta component uses at a time. So, as soon as I open the reolink app, all the homeassistant streams vanish.

Solutions:

  1. Try using h.264 instead of MJPEG
  2. Account for everything that’s using the camera and try to close clients to see if it allows more clients to connect.

3) Overloaded CPU on your cameras

This is one I realized too late to really assess it properly, as I didn’t have a sensor for it until I got the ONVIF cameras going. But basically cameras have very limited CPU resources, and if you are running some of the features like motion detection, line crossing, tampering, camera rotation in addition to certain types of apparently demanding streams like MJPEG or to a lesser extent the proxy camera component, you can overload the CPU. That being said, mine still seem to work pretty well when almost maxed out but I’m sure it caused some of my problems.

Solution:

  1. Avoid MJPEG cameras. For whatever reason they have high CPU load
  2. Avoid rotating your cameras. This causes me some additional load
  3. Avoid proxy camera. Adds some small load
  4. Don’t use camera motion detection features (you can do this on the synology or DVR for example)

4) Overloaded browser on the frontend

I see this sometime on my kindle fire tablets if I am trying to display 4x 1080p stream cameras with live view enabled. But instead of not displaying the camera, fully kiosk browser just crashes, so a bit different. But your frontend devices do have limits.

Solutions:

  1. Use a less demanding camera type (non live stream, mjpeg appears easier to stream on the frontend than ALS using stream).
  2. Get a stronger frontend device. A modern iOS device seems to be able to keep up with just about anything I’ve tried, compared to a low powered Kindle Fire device. YMMV.

All that being said, there are many, many cases that I can’t explain. The cases I can’t explain are shown as a lower reliability score in my “I tried all the cameras” post.

1 Like

Related issue: https://github.com/home-assistant/frontend/issues/4302

When the HA server is restarted, the picture entity cards are no longer thumbnails from the camera feed, they are grey ‘image broken’ boxes. Refreshing lovelace fixes the entity cards until the next HA server restart.

I am. confident that it’s not a performance issue as the cameras do not show high load average (yes, i can SSH in and run top on them :slight_smile: ). The host where my HA container is running is a recent i5 with 8 gig ram. The host is working, but load average numbers do not indicate that the host is near critical levels.

The only time that i can make the picture entity card stop working / be replaced with the ‘grey box’ is when I restart HA w/o refreshing Lovelace or when I intentionally break connectivity between the HA host and the camera in question.

Hi, pretty new to this and just playing around with an IP camera on an old phone. I was wondering if you had tried out the motionEye add on?

Nope. I use frigate.

Frigate is awesome!!!

1 Like