home-assistant / iOS

:iphone: Home Assistant for Apple platforms
https://companion.home-assistant.io
Other
1.52k stars 290 forks source link

High CPU load on macOS #2389

Open wolph opened 1 year ago

wolph commented 1 year ago

Device model, version and app version

Model Name: Macbook pro 16" 2019 macOS Version: 12.6.4 (21G526) monterey App Version: 2023.2.1 (2023.452) Safari Version: Version 16.4 (17615.1.26.101.9, 17615)

Home Assistant Core Version Home Assistant 2023.8.0

Describe the bug The OS X app uses a significant amount of CPU when it's simply idling in the background (window closed). I've already tried to disable as many sensors as I can but it doesn't appear to make much difference.

I should note that it's likely not the safari component because when opening home assistant in safari the CPU load is significantly less.

While I'm not too experienced in OS X development I can certainly help debug the issue (i.e. profile using xcode or instruments)

Restarting the app might reduce the cpu load a little but it's varying too much to be certain of that. In any case, when my computer is idling it's by far the most resource intensive app running, even though I've got 3 pycharm windows open, 3 vscode windows, 5 chrome windows with about 30 tabs in total. It is definitely using an excessive amount of CPU power.

To Reproduce

Run the Home Assistant app.

Expected behavior

No significant amount of CPU load while idling.

Additional information

I've included two samples, one after running for a while and one after a restart of the app.

Sample of Home Assistant After restart.txt Sample of Home Assistant.txt

imkebe commented 1 year ago

I had similar issues both on my Intel Mac and Apple Silicon. I noticed the problem is when there is a connection issue. For example after sleep etc. Also once i had HUGE memory leak app took about 96GB of virtual memory.

ShadowJonathan commented 8 months ago

I'm having the same problem, and its causing me to see Home Assistant Macos as somewhat of a parasite to my mac's performance, as almost always when i get stuttering and battery issues, its this app unnecessarily using a lot of resources in the background

wolph commented 8 months ago

So far I've not really been able to debug it myself... I've tried analysing the app using Instruments but because there are no debug symbols that's largely useless.

I've also tried compiling the app myself but for some reason xcode is not happy and giving me 514 errors. Not entirely sure what's wrong but for some reason it doesn't seem to recognise the L10n namespace and several others. I can investigate further if anyone has a hint as to what could be the cause:

▸ ❌  Sources/Extensions/NotificationContent/MapViewController.swift:150:25: cannot find 'L10n' in scope
▸             if title == L10n.Extensions.Map.Location.original {
▸                             ^~~~
▸ ❌  Sources/Extensions/NotificationContent/MapViewController.swift:152:32: cannot find 'L10n' in scope
▸             } else if title == L10n.Extensions.Map.Location.new {
▸                         ^~~~
▸ Compiling CameraStreamHandler.swift
▸ ❌  Sources/Extensions/NotificationContent/CameraStreamHandler.swift:11:15: cannot find type 'HomeAssistantAPI' in scope
▸     init(api: HomeAssistantAPI, response: StreamCameraResponse) throws
▸                                ^~~~
▸ ❌  Sources/Extensions/NotificationContent/CameraStreamHandler.swift:11:43: cannot find type 'StreamCameraResponse' in scope
▸     init(api: HomeAssistantAPI, response: StreamCameraResponse) throws
▸               ^~~~~~~~~~~~~~~~
johntdyer commented 7 months ago

Same issue on osx 14.2.1

bgoncal commented 4 months ago

For the memory leak we have a duplicate issue being worked on here: https://github.com/home-assistant/iOS/issues/2101

For CPU usage, do you still see the issue on version 2024.4? Let me know so I can hopefully close this issue

ShadowJonathan commented 4 months ago

I remember closing home assistant multiple times lately due to my Mac being slow, it may be placebo, but I want to observe for a few more moments before I'd say yes or no

imkebe commented 3 months ago

I can confirm that latest 2024.4 (2024.624) still has an issue. It happens for me when the Companion App was connected to the HA service, disconnect my MacBook from the network (by physically moving away), bring it back and connect to the network again. So the service is not available and then available again. Then i saw that my RAM is jumping 1-4 MB every second.

bgoncal commented 3 months ago

Please try 2024.4.1 which is in TestFlight beta

wolph commented 3 months ago

I've been trying for a little while but OS X refuses to run the app. Starting it the normal way I get this:

image

Trying it from the commandline I get:

zsh: killed     ./Home\ Assistant

I'm sure that's not related to this issue though... could be an older OS X issue or perhaps I downloaded the wrong build file.

benediktkr commented 2 months ago

Removing the Thread integration (which I wasn’t using) seems to have resolved these issues for me.

JonLaliberte commented 2 months ago

I started noticing this problem as well recently (high CPU usage). It seems to come and go, but I've noticed it a few times now.

frederick-launoy commented 1 month ago

Same here, high CPU load causing fans to go wild. MacBook Pro running Sonoma. I conform that removing the Thread integration solves the problem....

ShadowJonathan commented 1 month ago

I actually use Thread for some devices, so removing it is a no-go for me.

frederick-launoy commented 1 month ago

I actually use Thread for some devices, so removing it is a no-go for me.

Understand, just wanted to post this info as this can help whoever is analysing this problem to understand what causes it. Hope it gets resolved soon for you as well... ;-)

Coder84619 commented 1 month ago

I too am on Sonoma, M1 Pro Mac, and see high CPU utilization with Thread. I also see high CPU usage in Safari when I have a tab open to HA for an extended period (days?). Closing the HA tab in Safari immediately drops CPU utilization for the Safari process.