fix: only allow one activeWindow process to spawn at a time#37
fix: only allow one activeWindow process to spawn at a time#37anormananderson wants to merge 4 commits intoHASEL-UZH:mainfrom
Conversation
|
@anormananderson Thank you very much for your PR - we really hope that it fixes the battery/high-CPU load issue :) I've made three commits to implement your suggested changes (Rename loop, add generation counter and setting a timeout to prevent the tracker being blocked when the getwindow-call takes longer than 5 seconds. @anormananderson @grigor-dochev Could you please briefly review the changes to see whether they make sense? Afterwards, I could create a private release that we could test for a few days (or you could check it out and build locally). Thank you! |
|
Hi! Great to see some progress on the battery issues :) I quickly skimmed through the code, and while there is lots of good stuff overall, I am not 100% convinced it will fully address the issue many are experiencing (I hope I am wrong :D)
|
hey @royru Thanks for your review and thoughts! I was also wondering about that. It does seem to help overcome issues that Norman identified. So I suggest that for a few days, we'll first test this fix and discuss further steps (if necessary) in the coming days. |
|
Like @royru mentioned, I think commit 0706d82 will cause multiple I didn't realize there are multiple issues with I am intrigued because in my testing activeWindow() always returned. It seemed like the screen capture service was eventually timing out on its own ... so maybe further testing is warranted to see how both issues are affected by limiting to one If the screen capture process doesn't always time out on its own, then I think the best solution would be to kill the underlying Hope that makes sense. This issue's behaviour is very strange. |
|
I did some brief testing and it seems that the Promise.race added by commit 0706d82 is causing If waiting for activeWindow to time out by itself doesn't resolve the indefinite |
(Hopefully) addresses HASEL-UZH/PersonalAnalytics#430
The PR replaces a setInterval-based polling loop with a recursive setTimeout pattern. This is the correct architectural fix: setInterval fires regardless of whether the previous async call has finished, which can cause multiple concurrent activeWindow calls. The new pattern chains the next timeout only after the current one completes.
Some considerations:
Explanation for why setInterval() was problematic in its original use case