Stop refresh when tab not active

Want something added? Ask for it here.
Post Reply
ALbino
Full Member
Full Member
Posts: 214
Joined: October 23rd, 2014, 12:28 am

Stop refresh when tab not active

Post by ALbino »

I like keeping a tab with SABnzbd loaded so I can check on it every now and then. And when I do check on it, I like it to be set to a 1 second refresh so I can truly see what's going on for monitoring/testing purposes. What I don't like is that when I'm browsing other pages it keeps doing a constant 1 second refresh in the unused tab which causes my scrolling to stutter in whatever tab I'm actively looking at.

Right now I can mitigate this either by dropping the refresh rate when it starts to annoy me, or by using an extension like UnloadTab to essentially turn it off when I don't want it.

My feature request then is: something in the code that detects when the tab isn't active and stops the refresh. I can't think of any real reason why people would want it to keep refreshing when they can't see what it's showing, so I'd say just turn it off until they activate the tab again.

Doing a quick Google search I found various examples of how to accomplish this. For example, here's one from Stack Overflow:

https://stackoverflow.com/questions/106 ... tly-active

I'm not sure if this would go in the SABnzbd code, or would be theme dependent, but either way it would be great to see it implemented. Thanks!

(Windows 7 Professional/Firefox 38.0.5/SABnzbd 0.7.20)
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Stop refresh when tab not active

Post by shypike »

It's a skin thing.
I'll check with the designer of the new Glitter skin.
ALbino
Full Member
Full Member
Posts: 214
Joined: October 23rd, 2014, 12:28 am

Re: Stop refresh when tab not active

Post by ALbino »

Glitter looks really promising, it would great if he could incorporate something like this as well.
User avatar
inpheaux
Administrator
Administrator
Posts: 563
Joined: January 16th, 2008, 9:14 pm

Re: Stop refresh when tab not active

Post by inpheaux »

This would be great for main page content, but what about the title bar? Plush updates the <title> text along with the body, so you can see progress in a tab's title. If we only refresh when the page is active, this functionality would be lost.
ALbino
Full Member
Full Member
Posts: 214
Joined: October 23rd, 2014, 12:28 am

Re: Stop refresh when tab not active

Post by ALbino »

inpheaux wrote:This would be great for main page content, but what about the title bar? Plush updates the <title> text along with the body, so you can see progress in a tab's title. If we only refresh when the page is active, this functionality would be lost.
Good question, and I agree that I like that to see when something starts downloading, which often is what prompts me to go look at it in the first place. Maybe instead of turning off refresh entirely it could just drop to a really low rate like 10 seconds, then if something starts downloading you could still see it happen and go look at it to get the full 1 second refreshes. I think you could probably make this a settings option so people could leave it off or configure how they see fit.

A better solution, but more complicated, would probably be some sort of ajax implementation where only the title bar was continuously updating rather than having to refresh the entire page every single second.
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: Stop refresh when tab not active

Post by sander »

ALbino wrote:What I don't like is that when I'm browsing other pages it keeps doing a constant 1 second refresh in the unused tab which causes my scrolling to stutter in whatever tab I'm actively looking at.
I don't recognize and don't understand that your webbrowser stutters; in my experience the sab web interface is lightweight for a webbrowser on modern hardware. ???
ALbino
Full Member
Full Member
Posts: 214
Joined: October 23rd, 2014, 12:28 am

Re: Stop refresh when tab not active

Post by ALbino »

It doesn't when I first open Firefox, but after being open for a day or so, as the RAM usage gets high, it starts to slightly stutter when scrolling long pages. If I scroll up and down it happens every 1 second, and if I change the refresh rate to 2/4/8 it stutters on those same intervals. If I close the tab or unload it then it goes away completely. This is the behavior on both my PC and laptop.

PC: Windows 7 Professional, Intel i7, 16gb RAM, SSD drive
Laptop: Windows 7 Home Premium, Intel i7, 8gb RAM, SSD drive

Firefox 38.0.5 on both of them, and SABnzbd 0.7.20 (Plush Gold) on the PC, which I connect to from the laptop.
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: Stop refresh when tab not active

Post by sander »

Ah, Firefox ... !

Have you tried Chrome / Chromium?

I have left Firefox behind me a long time ago ... because of unexplainable stuttering and stalling. Very annoying.
ALbino
Full Member
Full Member
Posts: 214
Joined: October 23rd, 2014, 12:28 am

Re: Stop refresh when tab not active

Post by ALbino »

Yeah, there might be something said for making that switch. I have Chrome installed, and use it every now and then, but my day-to-day stuff is all done in Firefox. The idea of trying to set up Chrome with all my settings and addons just how I want it seems daunting though :)
User avatar
an3k
Newbie
Newbie
Posts: 31
Joined: June 16th, 2015, 10:49 am

Re: Stop refresh when tab not active

Post by an3k »

ALbino wrote:PC: Windows 7 Professional, Intel i7, 16gb RAM, SSD drive
Laptop: Windows 7 Home Premium, Intel i7, 8gb RAM, SSD drive

Firefox 38.0.5 on both of them, and SABnzbd 0.7.20 (Plush Gold) on the PC, which I connect to from the laptop.
I use Chrome and I never experienced any stuttering. Windows 7 Professional 64-Bit, Core2Quad, 8 GB RAM, SSD and SABnzbd 0.7.20 with Plush Gold and 1 sec refresh rate.
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Stop refresh when tab not active

Post by safihre »

For Glitter I was indeed experimenting already to only update the title when the tab is hidden.
By using queue.tmpl to output a custom JSON "API" output with just the amount of MB and current speed when the tab is hidden, the bandiwth and CPU/RAM usage should be super low!
I'll keep you updated!
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
ALbino
Full Member
Full Member
Posts: 214
Joined: October 23rd, 2014, 12:28 am

Re: Stop refresh when tab not active

Post by ALbino »

Sounds awesome, thanks!
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Stop refresh when tab not active

Post by safihre »

I tried it for Glitter, and in Chrome it already uses less than max 0.9% of my CPU when the tab is not active.
With the title-only update it's uses less than max 0.4%. But I did notice that with the regular update the memory slowly increases when the tab is not active, while it stays constant with the title-only update.
So it still could be beneficial!
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: Stop refresh when tab not active

Post by safihre »

I tried something else in which I don't do any nice JSON stuff to use Knockout, but use queue.tmpl to output only the title text so I only have to update that and nothing else (which does mean that the speed-graph is not updated when the tab is hidden).
With this the CPU usage really drops to almost 0% in Chrome and from 3% to 1% in Firefox. It also seems to be lighter on memory in both cases, although I still have to test having SABnzbd open for more than 24h.

Will keep this for Glitter!
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
ALbino
Full Member
Full Member
Posts: 214
Joined: October 23rd, 2014, 12:28 am

Re: Stop refresh when tab not active

Post by ALbino »

I appreciate all the effort you're putting into your template. Keep up the good work :)
Post Reply