Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome tab crashing / hanging after brought on foreground being long time on background

I've got a page that shows real-time statistics. It runs a lot of javascript, makes a lot of HTTP requests, renders SVG charts every few seconds using D3.js, has a lot of CSS animations, and rearranges the DOM frequently.

As long as the page is focused, it runs smoothly. If I switch to another tab and come back later, there's often a short pause where the page seems to be frozen before the view suddenly seems to rerender and the page becomes usable again. The longer the tab has been backgrounded, the longer this pause is. If the tab has been in the background for a very long time (hours) and I switch back to it, it will be frozen for a long time then crash.

All these behaviors are observed in Chrome. I haven't tested much in other browsers.

What isn't Chrome doing while the tab is in the background, and what is it doing during that pause when I first switch back to the tab?

UPDATE:

I'm also doing some jQuery animating. This answer and this one may be relevant.

According to that first answer:

"Inactive browser tabs buffer some of the setInterval or setTimeout functions."

stop(true,true) will stop all buffered events and execute immediatly only the last animation.

I've added a call to .stop(true, true) in my code, and at least for short trips away from the tab, I'm not detecting a hiccup. I need to leave it in the background for a long time and test it before I can tell if it made significant difference.

like image 304
Trevor Dixon Avatar asked Nov 16 '12 00:11

Trevor Dixon


People also ask

Why does my Chrome keep freezing and crashing?

Causes of Chrome FreezingChrome has too many open tabs, and the browser is using too many system resources. Third-party apps and extensions can interfere with Chrome's operation, utilizing too much memory and causing the browser to crash. Virus and malware infections can wreak havoc on Chrome.

Why does my Google Chrome keep hanging?

Your computer may have run out of memory, and can't load the site while also running your apps, extensions, and programs. To free up memory: Close every tab except for the one that's showing the error message. Quit other apps or programs that are running.

Why is my Google tab crashing?

This issue usually means there's a graphics rendering issue. Sometimes, opening a new tab and browsing to another page can help the affected tab to load. If this doesn't help, try restarting Chrome or your device. For more information, see Further troubleshooting.


1 Answers

We had a similar issue with SVG graphs and managed to solve it using Page Visibility API introduced with HTML5. If anyone stumbles upon such an issue please refer to the following article Using the Page Visibility API

What we managed to do was to suspend all SVG rendering activities when the browser window is not visible. This managed to stop the tab from crashing.

like image 152
Lasitha Petthawadu Avatar answered Sep 23 '22 15:09

Lasitha Petthawadu