YePpHa / YouTubeCenter

YouTube Center is a userscript designed to expand the functionality of YouTube. It includes the ability to download the video you're watching, auto selecting your preferred video quality and much more.
MIT License
2.89k stars 520 forks source link

Unbearable performance issues #538

Open mzso opened 10 years ago

mzso commented 10 years ago

Using YTC on youtube has become unbearably slow. Even if I set quality preview and flags to delayed load and load on scroll the cpu and the memory usage is just horrible. Everything becomes jittery slow and unresponsive. Even after all the pages are loaded the cpu usage stays high, close to max. It's just a pain. I disabled YTC and started using magic actions for partial replacement, and I could watch youtube videos for hours without much issues.

YePpHa commented 10 years ago

Could you please specify which browser you were using?

If you're using Chrome could you please try to take a profile, save it and send it to me?

To run the profiler you press CTRL + SHIFT + J and click on Profiles. Thereafter you make sure that Collect JavaScript CPU Profile is checked and you click on Start. From there you then just have to reload the page and the profiler will collect information about what part of YouTube Center that uses the most CPU. After you've played a video in about 10 seconds you can then click on the Stop button to stop the profiler. In the left side of the profiler window the profile will appear. Right click on it and click on save to save it. After that you can send it to me.

mzso commented 10 years ago

I'm a firefox user. I only occasionally start Chrome. Chrome probably wouldn't hang that easily because of it's multi-process nature.

YePpHa commented 10 years ago

I will try to do some testing in Firefox then.

You can also do a profile in Firefox. You just have to press CTRL + SHIFT + K and then select the tab Profiler and press on the gauge meter icon at the very top left corner of the profiler. Do the same as I instructed on Chrome and press the icon again to stop the profiler. You can then click on save and send the file to me.

YePpHa commented 10 years ago

I did some testing with Firefox and I didn't find any huge CPU usage with YouTube Center (I used the Firefox addon).

mzso commented 10 years ago

Hmmm. I have firefox 24. (Well, technically Pale Moon) and there isn't a save feature yet it looks like.

mzso commented 10 years ago

Oops accidentally closed it, it seems.

YePpHa commented 10 years ago

ahh okay, I will try to test it in Pale Moon then.

YePpHa commented 10 years ago

Okay found the issue... It seems like YouTube Center couldn't detect the flash player so it went into an infinite loop (that I need to fix). The CPU usage would not really be noticeable with only one tab open, but with a lot of pages in that loop you would be able to see it drag the browser down with it.

The reason your browser didn't crash because of it is because there is a delay from every time it loops. If I remember correctly it will be delayed 100 ms.

mzso commented 10 years ago

Cool. Not sure it's relevant, but I use the 64 bit version.

Anyway I exported the YTC configuration. Maybe it's of some value: https://drive.google.com/file/d/0ByfdfPvnoDuzVjNIZFNIZnZEeEU/edit?usp=sharing

mzso commented 10 years ago

@YePpHa Cool. Is it Pale Moon (or FF24) specific?

YePpHa commented 10 years ago

I have once seen that specific issue, but it went away so it could be a FF24 specific. I have released a new version of YouTube Center, which should have fixed the issue I found. Also I found another issue with the Firefox addon that I also fixed.

YePpHa commented 10 years ago

I would recommend you to uncheck the option Player glow as it doesn't work on Firefox and it might just take up unnecessary CPU usage.

ChromeCanary commented 10 years ago

Here's an example of one YouTube video (HTML5, Chrome Canary 37 x64, YTCD 319)

untitled

It's not so bad, and you can easily browse other websites while YouTube tab is on the background.

598mb without ABP.

mzso commented 10 years ago

Dev build 319? Unfortunately I see little to no improvement. Opening one youtube video and then 5 from the related video thumbnails. And it takes minutes to load them. After the page first loads something else is loaded like 3-4 times. (as indicated by tab mix plus ) And after everything loaded and should be idle I get constant high cpu usage. And the browser becomes jittery and slow to react.

PS: I didn't start playback.

ChromeCanary commented 10 years ago

Give me a link for a Youtube video you try to watch and thumbnails you're trying to load. So I can test.

YePpHa commented 10 years ago

@mzso could you try to do a Profiler but just take a screenshot of the result and send it to me? Remember to open the (Total) tree.

Also I choose to completely disable the communication between tabs to see if this is the issue as that was what used the most CPU on Palemoon on my pc.

EDIT: the developer version with the disabled feature to communicate between tabs is out now.

mzso commented 10 years ago

Something like this? ytc-prof Waited for a while to things to load. Didn't start playback. I'll check the new version. (I scrolled down once and some thumbnail stuff probably got loaded.)

mzso commented 10 years ago

Seems to be better with build 320. Loading is still pretty heavy but there doesn't seem to be any lingering cpu usage increase after.

YePpHa commented 10 years ago

Okay, good to know. But I've been doing some digging and I found a few issues where something will run multiple times. Also the RAM usage will increase over time and I will try to take a look at that too.

mzso commented 10 years ago

I also noticed some RAM increase. +450 when I opened the five videos. But it only dropped back by ~half after I closed them and minimized memory. But I also have other YT stuff so I didn't mention it.

YePpHa commented 10 years ago

There is a memory leak I am also trying to fix. There are a few issues about this.

YePpHa commented 10 years ago

I will be trying to address the performance issue while I'm rewriting YouTube Center (https://github.com/YePpHa/YouTubeCenter/tree/requirejs). I did some more tests with the memory leak and it seems like I get ~40 MB of memory leak for every YouTube window I close with YouTube Center installed. I am still working on getting the memory leak fixed.

mzso commented 10 years ago

I just realized that YTC greatly messes up other pages loading, if there are embedded videos on them. I set YTC to use the HTML5 player on embedded videos, which I guess may make it worse. Loading this one results in an unusable (unresponsive) browser for like half a minute here: http://eng.tekkenpedia.com/wiki/Kazuya_Mishima (14 embedded YT videos, last two loads with flash for some reason)

mzso commented 10 years ago

I found this addon called "Suspend background tabs" that helps mitigate the performance issues a lot. https://hg.adblockplus.org/suspendbackgroundtabs/ https://hg.adblockplus.org/downloads/file/

Unfortunately it disables the disable autoplay feature too, by - I'm assuming - disabling YTC. It doesn't disable all addons though. So I added "Magic Actions" just to disable autoplay. Unfortunately it adds a bar. (Another addon "Youtube Control Center" unfortunately only manages to disable autoplay when YTC is disabled also. Weird. Didn't find anything else)

mzso commented 10 years ago

Is it me or did performance did get worse in the past couple weeks? Loading a youtube page feels a lot more sluggish/hangy.

gix commented 10 years ago

I can confirm. Opening a YouTube page makes Firefox nearly unresponsive for a few seconds. But what I noticed is that this doesn't happen (or is at least much less severe) for a while after disabling and re-activating the addon.

hhyyrylainen commented 9 years ago

I updated from version 2.10 to version 2.17 and started experiencing this issue. Firefox lags for many seconds everytime I open a new youtube tab or scroll down any youtube page. I ran the profiler while scrolling down http://www.mediafire.com/view/e69aooeqq3etcac/profile.json but I was unable to load the results for some reason. The performance is so bad that it is almost impossible to use youtube center.