colinbendell / homebridge-blink-for-home

Blink For Home Camera Homebridge plugin
MIT License
88 stars 27 forks source link

Huge jump in cpu/memory usage. #25

Closed tombenton55 closed 3 years ago

tombenton55 commented 3 years ago

Updated to the latest version and my cpu went from 2% to 67% memory has increased too. Had to uninstall as I don’t have a cooling solution yet. Thought I’d flag it just incase.

Edit seems to be related to live view, I’ve reinstalled and disabled it for now and cpu everything is back to normal.

I’m using the new outdoor cam, I don’t need live view I was just testing it as the plug-in updated. Perhaps this is normal.

Sorry for my lack of technical ability

xelypse commented 3 years ago

Same here. I had to turn off the power to the pi. all versions before were without problems.

colinbendell commented 3 years ago

Interesting. What configuration are you running? What version of homebridge? node? npm? To confirm, you updated and restarted homebridge and saw the increase in memory? Is it stable or does it drop?

colinbendell commented 3 years ago

Using homebridge 1.2.3 and node 14, the active memory decreased ~10MB (read: within error bars) between 3.5.18 and 3.6.1. The big difference in this release is that I'm now using the HTTP/2 TLS socket APIs instead of H1. But that's a function of Node primarily.

tombenton55 commented 3 years ago

I'm using homebridge 1.2.3 on a pi4 2gb with node 14.15.0 As soon as I enabled the live view memory/cpu usage went crazy and stayed at 67-73%. Turning it off didn't help return it to normal. Plugin had to be uninstalled and reinstalled to fix.

Plugin without liveview has been absolutely flawless, I just got curious.

xelypse commented 3 years ago

Node.js Version v14.15.0 Npm Version v6.14.8 Homebridge 1.1.6

Raspberry Pi 3B+

colinbendell commented 3 years ago

the re-install fixed the memory usage? After you did the update, did you restart homebridge?

xelypse commented 3 years ago

yes, the Homebridge has been restarted. The Pi also had to be restarted. Then reinstall the plugin. The same problem after a while. Didn't reinstall the plugin.

colinbendell commented 3 years ago

oh you mean the cpu + ram didn't spike immediately, but grew after a period of time?

xelypse commented 3 years ago

Yes exactly. It ran for a few minutes and suddenly the homebridge was unreachable, not even via ssh

colinbendell commented 3 years ago

Oh. I think I misunderstood. You are using live view and found the cpu and memory go up. Is this correct? But under normal operation it doesn't?

Live view uses ffmpeg to transcode the stream and so requires a high amount of cpu and memory to transcode and encrypt to meet HomeKit camera requirements.

Can you confirm the use case you are finding this?

If you are finding the high cpu/memory when not in live view, can you tell me if you are using a higher thumbnail refresh rate? Or the standard 10min when armed?

tombenton55 commented 3 years ago

Exactly. This was a live view specific situation. If it’s normal behaviour then fine. But should it ramp up even when the stream is exited?

On Mon, 16 Nov 2020 at 23:01, Colin Bendell notifications@github.com wrote:

Oh. I think I misunderstood. You are using live view and found the cpu and memory go up. Is this correct? But under normal operation it doesn't?

Live view uses ffmpeg to transcode the stream and so requires a high amount of cpu and memory to transcode and encrypt to meet HomeKit camera requirements.

Can you confirm the use case you are finding this?

If you are finding the high cpu/memory when not in live view, can you tell me if you are using a higher thumbnail refresh rate? Or the standard 10min when armed?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/colinbendell/homebridge-blink-for-home/issues/25#issuecomment-728381842, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANWINUR75IP2IUNNESOMFZDSQGVNZANCNFSM4TW36OLA .

colinbendell commented 3 years ago

It might take a bit. But not long. Check the logs id it persists.

xelypse commented 3 years ago

So for me the Pi is frozen twice in the default settings. Before, all versions ran without problems. I have now removed the plugin.

mtressl commented 3 years ago

So for me the Pi is frozen twice in the default settings. Before, all versions ran without problems. I have now removed the plugin.

Same situation here. Since the last update to 3.6.1 with no config changes this happens.

nin9s commented 3 years ago

same here: image

dcgraves commented 3 years ago

I'm having the same issue and was able to get the CPU back down to normal levels by manually killing the ffmpeg process. From the behavior I noticed, it looks like ffmpeg starts when you click on a camera in the Home app for live view (even if you've disabled it) but the plugin doesn't kill the ffmpeg process automatically once live view is exited.

colinbendell commented 3 years ago

Thanks. I probably need to add a watcher to make sure the SIGINT/SIGKILL is properly sent. (PRs are always welcome ;)

MasterofKungfu9999 commented 3 years ago

Is there something new? I have this problem too.

newelement commented 3 years ago

Tried this plugin today and seeing the same. CPU usage was around 4%, now it's around 50%. Could it be it's trying to stream the camera feeds in the background?

colinbendell commented 3 years ago

The root cause is that the single frame image is being looped in ffmpeg and this process isn't getting killed gracefully. I haven't had time yet to add a timeout mechanism to clean up these events. (Usually happens when you go into the camera and then to settings). I'm planning to come back to this in the next week or so.

newelement commented 3 years ago

The root cause is that the single frame image is being looped in ffmpeg and this process isn't getting killed gracefully. I haven't had time yet to add a timeout mechanism to clean up these events. (Usually happens when you go into the camera and then to settings). I'm planning to come back to this in the next week or so.

@colinbendell No worries. This is awesome. If I had time I could help as well.

jeremybdk commented 3 years ago

Same issue here, installed the plugin, when configured saw an increase to 100% of CPU Usage and 1.2 Gb or ram used by ffmpeg, I use a RPI 4 2Gb with node v12.20.0 and latest version of Homebridge.

I had to remove the plugin to get CPU and RAM to normal level, removing only the plugin configuration did not work.

hunterpaul commented 3 years ago

Exactly the same issue for me too. CPU maxed out and the batteries in the camera got drained. Looks like a bug is keeping the live feed open

saadatorama commented 3 years ago

Any update on this?

robbie2003ie commented 3 years ago

Yeah, Any update? Unable to use as CPU shoots to 97% and will not go down until FFMPEG zombie process are killed.

colinbendell commented 3 years ago

should be resolved in v3.7