WofWca / jumpcutter

⏩ Fast-forwards long pauses between sentences — watch lectures ~1.5x faster (browser extension)
https://chrome.google.com/webstore/detail/jump-cutter/lmppdpldfpfdlipofacekcfleacbbncp
GNU Affero General Public License v3.0
356 stars 13 forks source link

fix: video gets stuck at silenceSpeed for a while when performing processing-heavy actions on the page #104

Open WofWca opened 2 years ago

WofWca commented 2 years ago

For example, open a video on YouTube and then open dev tools (F12), or try resizing the window.

Could be the reason for https://github.com/WofWca/jumpcutter/issues/24#issuecomment-943971048.

What I think happens is that the main thread gets overloaded and can't process messages from SilenceDetectorNode in a timely manner:

https://github.com/WofWca/jumpcutter/blob/d81da1596a2dfa89a35bbc7b0cb0d28880f6f2e2/src/entry-points/content/StretchingController/StretchingController.ts#L384-L390

Not sure what we can do about this. Putting this listener on a separate thread (#88) would be perfect, but AFAIK it's not possible to access DOM from within Workers.

Maybe we could measure how loaded the main thread currently is and if it is quite busy, don't switch to silenceSpeed. Maybe requestIdleCallback could help, idk.