derat/nup

Figure out cause of weird ThreadPoolServiceThread tasks

Closed this issue · 2 comments

derat commented

I've noticed the app sometimes continuously consuming around 5% CPU after I've been using it for a while. This happens even when the music is paused and the tab is backgrounded. Dev Tools doesn't point at any JS code, but it looks like there are two ThreadPoolServiceThread tasks that are running every 10-12 ms. They complete very quickly, but presumably they're still causing task switches and draining the battery:

Screenshot 2022-04-19 07 14 55

This doesn't happen as soon as I open the app, or even after I play and then pause, but I usually see it after playing and pausing a few times. It appears to happen both on a Chromebook and a desktop Linux system. I added logging to all the timeouts and timeupdate calls, but they don't appear to be firing while this is happening.

https://chromium.googlesource.com/chromium/src/+/refs/heads/main/base/task/thread_pool/service_thread.h is the ThreadPoolServiceThread implementation, but it doesn't really help me figure out what this is. I guess it's used for I/O.

I tried to repro this on a simple page that just has an <audio> element, but I haven't been successful yet.

derat commented

Here's a zoomed-in screenshot:
Screenshot 2022-04-21 11 08 05

derat commented

I haven't noticed this lately (including in a tab that's played 25+ songs), so maybe it got fixed by a Chrome change or by something that I did (e.g. 09f8673).