Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutation callback performance issues with livestream chat #126

Open
gsuberland opened this issue Nov 17, 2024 · 2 comments
Open

Mutation callback performance issues with livestream chat #126

gsuberland opened this issue Nov 17, 2024 · 2 comments

Comments

@gsuberland
Copy link

Typing in the chat message box on a livestream is very laggy with PocketTube enabled. It often takes several seconds for typed messages to catch up, and the tab frequently locks up while typing.

I did a quick performance analysis in Firefox, and found that a large amount of CPU time is spent in the DOM mutation callbacks for PocketTube. Popping chat out into its own window shifts the CPU time accounting from the livestream window to the chat window, indicating that it is indeed chat which is the root cause.

This makes sense - presumably every new chat message and every character pressed in the text box is triggering a series of DOM mutations (probably quite a few due to updating all the chat icons, at-replies, etc.), which then triggers a pathological performance case in PocketTube's code, probably re-traversing the DOM looking for elements it integrates with. I don't currently have time to dig any deeper into the call heatmap, but it should be replicable just by going to any livestream with an active chat.

Running PocketTube 16.3.17 on FF 132.0 x64 Win10, with uBO + SponsorBlock also running. Tested on three machines; sluggishness is worst on machines with lower single-thread performance.

@NabokD
Copy link
Owner

NabokD commented Nov 17, 2024

It's weird, I can't reproduce the behavior under my account and there is no similar requests. I'm not sure we can optimize mutations, it's required for proper extension working.

@gsuberland
Copy link
Author

I'll take another look, see if I can grab you a trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants