home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
3.96k stars 2.69k forks source link

High client memory usage, slow UI response and crashes on devices with limited resources (Android phones, tablets) #20184

Open ujvarigergo1 opened 5 months ago

ujvarigergo1 commented 5 months ago

Checklist

Describe the issue you are experiencing

Experiencing slow ui performance. It's not a fresh problem, but now I figured out why this is happening. When I open Home assistant and switch between tabs on dashboard, it takes sometimes 5-10 seconds. When I open entities or automations settings, it takes 20-30 seconds to load, and 5-10 seconds after I clicked any other button. On my desktop PC (32 gb of ram and ryzen 7 5800x processor) it's quite faster, but on android (doesn't matter if in Home assistant app or browser) sometimes it takes minutes to load and if I open settings and modifying things, the app sometimes crashes. The possible cause of this problem is the memory usage. I tested it in chrome, but edge does the same thing. When the app is just opened, it uses 400-500 mb ram based on chrome's task manager. When I open entities list in settings it jumps over 1.4 gb: image (This picture made in safe mode, so my custom integrations should not be the problem) After some browsing between setting, entities and automations it can jump over 5 gb: image

I'm experiencing this problem at least half a year. Tried disabling almost all of my integrations but nothing helped. I love Home assistant but this problem makes it unusable, because I can't use it from my phone and configuring some more complex automation is takes about five times longer than it should be because of the slow response time and slow loading of the app.

Describe the behavior you expected

I expect that the app uses maximum 200-300 mb of ram and responses within a second when I click a button.

Steps to reproduce the issue

  1. Open the app
  2. Open settings
  3. Open entities list, go back and open it again, enable hidden entities
  4. Open automations, edit one of them, go back to entities
  5. This is the point when I have at least 1.5-3 gb of ram userge just for this tab

What version of Home Assistant Core has the issue?

core-2024.3.3

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Google Chrome 123.0.6312.58

Which operating system are you using to run this browser?

Windows 11 Pro 23H2 | Build: 22631.3296

State of relevant entities

Can't figure out which entity or integration causes the problem

Problem-relevant frontend configuration

#### I don't think that is matter, but my server's config:
- Lenovo mini pc (i5-4570T, 12gb ddr3 ram, 1 Tb sata ssd) with proxmox
- Tried virtualized HA OS and also VM with docker supervisor installation
- Fresh installation seems working smooth but when I restore my backup it goes wrong again

#### Installed integrations:
Default weather forecast, Bluetooth, DLNA Digital Media Renderer,DLNA Digital Media Server, Google calendar, Jellyfin, MQTT (10 device), Sony Bravia TV, Spotify, System monitor,Certificate expirity, Tasmota (1 device), Tuya (2 device), Xbox, Yeelight (4 device), Mobile app (2 device), Octoprint (disabled), MJPEG Camera (1 camera, disabled)
#### Installed custom integrations:
Passive BLE Monitor (5 device, 33 entity), Dreame Vacuum (1 device), Frigate (1 camera), Hacs, Midea Ac Lan (1 air conditioner), MiWifi (105 entity), Scheduler, Tapo Control (1 camera)
#### Enabled addons:
Appdaemon, Wireguard, File Editor, Zigbee2MQTT, MariaDB, Mosquito broker
#### Used cards (dashboard has 7 tabs):
custom:html-card, custom:vertical-stack-in-card, custom:stack-in-card, custom:auto-entities, weather-forecast, custom:mini-graph-card, custom:mini-media-player, thermostat, light,custom:xiaomi-vacuum-map-card, custom:mod-card, custom:threedy-card

Javascript errors shown in your browser console/inspector

No errors shown

Additional information

No response

PatrickBziuk commented 5 months ago

Hi @ujvarigergo1!

I'm currently experiencing the same/similar issue in my Dashboard and I'm also currently running HA 2024.3.3. Just like in your case the tab slowly eats up RAM and is not longer responsive and needs to be restarted. I discovered this issue lately and also couldn't find any specific integration causing the issue.

After searching for similar issues, I only found yours that matches mostly mine. Do you also have this problem with the normal Dashboard or only with the entity list?

After eating up my RAM for a while, the Tab in edge gets the error "Out of Memory" after consuming over 5 GB RAM idling. Screenshot 2024-03-28 161000

mainTAP commented 5 months ago

I am also having a similar issue with the Dashboard's memory consumption, I'm trying to display a dashboard on a small SBC like Raspberry Pi without desktop environment only running Chromium showing HomeAssistant, but the memory gets constantly filled up and results in a crash. I've tried this on several devices with various amounts of RAM (515MB,1GB,4GB) but they all keep steadily increasing the used RAM and result in a crash after showing the dashboard for a while. Currently, I am using the device with 1GB of RAM and I need to re-load the browser window or restart the browser every hour or so to prevent a crash. Screenshot 2024-04-02 171941

bramkragten commented 5 months ago

Is this also happening in safe mode?

ujvarigergo1 commented 5 months ago

@PatrickBziuk Yes, it happened on dashboard too but entites page was the worst. @bramkragten Yes, it happened in safe mode too.

Solution

Finally found a solution and the possible cause of the problem. I had 200000 (I don't know how but yes, this is the correct number) device tracker entities without unique id, history data or any other info. I think the BLE tracker integration created them, but I'm not sure. They couldn't be deleted from ui so I deleted them with automatized api calls (simple js script with axios). I send the code if anyone needs it. When deleted them all, restarted HA and they created again, so I re-enabled BLE tracker, deleted entire known-devices.yaml, disabled BLE tracker, deleted all related entities with api calls again and finally restarted ha and it feels super fast now.

I know that's a special case but it means that Home assistant's frontend keeps all entities in client's memory. That could be useful for tracking changes, but on entities without any history data or any function is unnecessary.

Another intersting thing I noticed is about security. Now it was a good thing but I started more than 200000 api calls in aprox. 5 minutes. I learned at school that is recommended to limit the maximum api calls per minute to protect web applications against automatized bots. Is there any options to turn on something like this on my system?

milandzuris commented 5 months ago

same problem but on new version 2024.4.0

blackgold9 commented 3 months ago

+1

github-actions[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

kpagnat commented 2 weeks ago

Hi, I was in same situation for a long time. My HA instance is on a dedicated VM on a NUC and in a separate room, I have a RPi with a screen always on, that only connect to HA web ui. It has a limited user connection with only 1 tab and about 30 entities on that tab. For a long time, I had crashes from chromium and it was hard to figure out what was going on. It ends up to be one of lovelace cards that takes too mich memory and seems to not release it. At that time, I managed to change that card (didn't remember which one) to other types and my UI is working well since then.

Last week, I was playing with some new lovelace cards (for me), which are mini-graph card and tailwind-css card. It ends up to make chromium freezes after only some hours. I just give up changing my lovelace interface but if some one can figure out how to make any kind of cards works nicely with my RPi chromium, it could be so much better.

Thanks.