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

High CPU and memory usage with versions greater than v3.0.2 #36

Open
vzjrz opened this issue Apr 15, 2020 · 11 comments
Open

High CPU and memory usage with versions greater than v3.0.2 #36

vzjrz opened this issue Apr 15, 2020 · 11 comments

Comments

@vzjrz
Copy link

vzjrz commented Apr 15, 2020

I updated to the newer versions and I've noticed that opening youtube tabs is very sluggish compared to before. I narrowed it down to Youtube Watchmarker. Even if I "Refresh" firefox and then install Youtube Watchmarker the problem still persists. The only problem is that this bug may only show up with very large number of tabs. I have a window open with >800 youtube tabs (not fully loaded) but trying to open a new tab with Youtube Watchmarker spikes my cpu and memory.

I've included a screenshot of the addon's console log (v4.0.4).

ytwatchmarker

@sniklaus
Copy link
Owner

What about if you disable the Youtube Watchmarker, is Youtube still sluggish then? I am asking because if you were using the old Youtube theme before then I wouldn't be surprised if navigating Youtube feels sluggish to you now, the new theme is much more CPU intensive.

Is the experience sluggish if you only have a few tabs open? You said something about 800 or more Youtube tabs. If the issue only occurs when having that many tabs open then I am not surprised and I do not think there is much I can do to fix this.

Thank you for the screenshot, this error isn't worrisome. It appears when the extension tries to communicate with a Youtube tab but the communication script in there hasn't been fully loaded yet.

@vzjrz
Copy link
Author

vzjrz commented Apr 15, 2020

What about if you disable the Youtube Watchmarker, is Youtube still sluggish then?

No when I open a new youtube tab my cpu spikes for like 2 minutes. If I disable Youtube Watchmarker then cpu usage goes down instantly.

Is the experience sluggish if you only have a few tabs open?

I have 800 tabs but they are not loaded. I have not been able to reproduce the problem on a clean profile with no tabs. It's just that this wasn't a problem on previous versions. I guess I'll stick with the older releases for now. Thanks.

@sniklaus
Copy link
Owner

Some thoughts on why this might be happening. When navigating to a Youtube video, it is marked as watched. At the same time, another tab might currently contain a list of videos where this video is included as well and it should hence be marked as watched. To support this, the extension notifies all Youtube tabs that there is a newly watched video.

chrome.tabs.query({
'url': '*://*.youtube.com/*'
}, function(objTabs) {
for (var objTab of objTabs) {
funcSendmessage(objTab.id, {
'strMessage': 'youtubeMark',
'strIdent': strIdent
});
}
});

The funcSendmessage function as a built-in retry mechanism that retries sending the message up to 100 times. This retrial is built-in for cases where the Youtube Watchmarker has not fully loaded its code within a Youtube tab, and hence is unable to receive messages yet.

var funcSendmessage = function(intTab, objMessage, intRetry) {
if (intRetry === 0) {
return;
} else if (intRetry === undefined) {
intRetry = 100;
}
chrome.tabs.sendMessage(intTab, objMessage, {}, function(objResponse) {
if ((chrome.runtime.lastError !== undefined) && (chrome.runtime.lastError !== null)) {
setTimeout(funcSendmessage, 100, intTab, objMessage, intRetry - 1);
}
});
};

So in summary, I should find a better way of doing the retry in the funcSendmessage function. It should only retry if we know that the tab that we try to send a message to did not receive it because our script hasn't finished loading in this tab yet.

Thank you for bringing this up, I will try to address it in the next version.

@sniklaus
Copy link
Owner

sniklaus commented May 9, 2021

I just released version 4.1.0 and hope that this new version performs better for you. Could you give it a try an report back? Thanks!

@vzjrz
Copy link
Author

vzjrz commented May 10, 2021

Just upgraded and unfortunately it's still exhibits the same symptoms. I'll stick with version 3.0.2 thanks for your help.

@shoaibshakeel381
Copy link

I am facing the same issue.

@sniklaus
Copy link
Owner

I just released version 4.3.1 based on some great contributions from @lbmaian that may have addressed this now. Could you give the new version a try and report back? Thanks!

@vzjrz
Copy link
Author

vzjrz commented Jan 28, 2023

I'm sad to report that the problem still persists on 4.3.1

@pshlos46
Copy link

pshlos46 commented Mar 5, 2024

still persists on 4.6.1. whenever the addon is open and i have a lot of tabs open, it spikes the CPU usage and playback becomes sluggish/stops for like 30 seconds to 1 minute and eventually things get sorted out. As soon as I disable the extension it works normally. @sniklaus how can I help with data/logs so you can reproduce this and get to the bottom of this?

@sniklaus
Copy link
Owner

sniklaus commented Mar 5, 2024

Let's start with some simple debugging:

  1. If you are using Firefox, try Chrome and vice versa to see whether this is a browser-dependent issue.
  2. If you are having other extensions, try disabling them to see whether this is due to an issue with another extension.
  3. If you have multiple computers, try seeing whether this issue persists across computers.

@piecevcake
Copy link

piecevcake commented Aug 4, 2024

I have the same issue.
If I disable the addon, Youtube immediately becomes responsive. When I re-enable it, youtube stays responsive then I chose a different trigger option (I don't know which one) and within 1 video it started lagging again.
So it's across computers. I have several thousand unloaded tabs (maybe 1000 YT). Usually 1- 6 YT tabs activated.
Even when I then deselected all triggers, it still lagged.
Now that I have run all the triggers and created the list I have only 1 trigger selected, "when opened in the browser". It is lagging with only this trigger selected, which doesn't make sense.
Maybe you could get it to act only in the active tab?
Firefox, not interested in changing browsers. W10 pro.

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

5 participants