Closed MattiaEffendi closed 7 months ago
Do you have any HA logs just before it was killed?
@Tasshack nothing. The logs before it was killed were from around 15/20 seconds before.
That may mean it crashes when installing the prerequisites.
One of the requirements of the integration is py-mini-racer
and that package relies on static libraries compiled for each cpu architecture. If pil
cannot find the native libraries for the py-mini-racer
it tries to compile them from source. That is a case on RPI3 and RPI4 devices but this process should never use more than 2GB memory.
You can try to manually install the requirements from virtual environment of the HA
"requirements": [
"pillow",
"numpy",
"pybase64",
"requests",
"pycryptodome",
"python-miio",
"py-mini-racer",
"tzlocal",
"paho-mqtt"
],
@Tasshack That could definitely be the issue. I remembered now that when watching top
the process which was memory leaking was, in fact, some setuptools
stuff.
Just for clarity: the manual install you suggested is to debug the problem or a definitive fix? Because i think that if i run those commands in the Core container they won't be preserved on container restart, or not?
For debugging;
You can just remove the py-mini-racer
from manifest.json
at the dreame_vacuum
directory. Integration won't start and complain about it's lackness but HA should start if that was the problematic library.
For fix; I have never used HA OS and not sure how it is different from the Core installation but I can manually install the requirements on my HA Core using commands below. Basically HA is doing at the same thing for each required library from the inside so it should be persistent after the reboot.
sudo -u homeassistant -H -s
cd /srv/homeassistant && python3 -m venv . && source bin/activate
pip install py-mini-racer
You probably won't be able to install it manually too since it still will be using to much memory but that is an another issue to solve.
@Tasshack Home Assistant OS is basically a Linux image containing scripts that orchestrate some docker containers (Home Assistant Core, Home Assistant Supervisor, Home Assistant Observer, the addons you install from the addons page and a few more). I don't know if that could help you but i'm running my install on Proxmox on an x86_64
arch.
I've tried removing the py-mini-racer
dependency and i can confirm Home Assistant starts correctly, but the weird thing is that the integration works. Sensors are exposed and the state is correct. I don't know what that library is for but at a first glance the integration is working correctly.
But the weirdest thing is that even when restoring the full backup that was "broken" on another instance (aka, with the integration installed and untouched), and that was throwing the error in the photo above.
The only difference between when i was restoring that a few hours ago trying to debug (and it was giving me the error) and now is that now the robot is cleaning and back then it was at its base. I have no idea if this can have an influence.
Could that be some sort of server-side issue of PyPI or the package repository the dependency used that caused the leak, and it being now fixed the package installs like normal?
I have no idea
That library is responsible for running the JS code that is for optimizing the VSLAM vacuum maps because python is too slow for running some flood fill algorithms and such. Since yours is a LIDAR device, that piece of code won't be used but python will complain about the map.py
and everything inside it because a library has to be imported even when it has not been used.
Maybe that was an older python behaviour but your map feature shouldn't be working right now without from py_mini_racer import MiniRacer
@Tasshack i can confirm that re-installing the integration on my main Home Assistant instance now works.
I have no idea what can have caused that memory leak repeatedly (and i can confirm that the problem wasn't one-shot, i've created multiple VMs and installed the plugin multiple times). Do you think the hypotesis i wrote in the message above can make sense?
Could that be some sort of server-side issue of PyPI or the package repository the dependency used that caused the leak, and it being now fixed the package installs like normal?
I have a Proxmox snapshot of the instance made at the time when the installation was memory leaking. I will try to restore a VM with that snapshot to ensure that the problem is now ok. I still can't explain what happened
Normally py-mini-racer
shipped with the precompiled libraries for x64 systems so it should not try to compile them on your system in the first place so that can verify your suggestion.
Also don't forget that every version of HA requires all of the requirements to be installed again. So this issue may happen any version of the OS and it is not version specific and I am closing this issue because of that.
@Tasshack that makes sense, but even if it needs to compile for x64 do you think that it needs to use more than 6GB of memory? It still seems a lot to me.
I can confirm that after the restore of the affected snapshot everything now works correctly.
As I said before, memory usage is another issue that is not the scope of this project and can be resulted from many different reasons apart from the integration. There is nothing I can fix or guess about this issue because it cannot be reproduced right now.
@MattiaEffendi looks like this is not an issue limited to your setup after all. @Ives25 https://github.com/Tasshack/dreame-vacuum/discussions/353#discussioncomment-8459795
Describe the bug When initializing the integration (both pre-configured or via the configuration wizard, at the end), Home Assistant docker container starts using a lot of RAM, leading to the container being killed by the host system. When that happens, HA Core is dead and the frontend cannot be reached. HA Core restart or host reboot doesn't help, leading to the same problem
The only way to fix is to log-in via SMB (if you have the addon installed) and delete the
custom_components/dreame_vacuum
folder.I have been running the integration
v2.0.0b11
without any problems for the past few months, and this only started happening yesterday after updating Home Assistant Operating System to 11.5. The VM that was running Home Assistant has always had 2GB of RAM, i've increased that to 6GB to try and see if it was the problem but it still persisted.I've been able to fix my main Home Assistant instance as described above, but i have a Home Assistant snapshot affected by this problem that i can restore on another instance to investigate the problem.
To Reproduce
Or, if you have the addon already installed and integration set-up:
Expected behavior Be able to set up the integration, or boot HA core if the integration itself is already installed.
Screenshots
(took via Home Assistant host console)
Additional Information (please complete the following information)