Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome HTML5 Videos stop working if too many tabs are open - Memory issue?

Tags:

html

memory

video

I'm using jQuery to dynamically write <video> objects, and running videojs to init them. After I play a video, SOMETIMES when I try to play it again, it just won't play, and from that point on, even after refreshing the page, no videos will play. Each time, the <video> object renders, but the video just doesn't play. Nothing is written to the console. There don't appear to be any errors. Restarting Chrome resolves the issue, but only momentarily. After playing a few videos, the issue comes back again.

I found that closing other tabs in Chrome does indeed fix the problem, so it appears to be some kind of memory issue.

I'm running Chrome 19.0.1084.46

like image 415
Johnny5k Avatar asked May 18 '12 19:05

Johnny5k


2 Answers

Exactly how many video tags to you have? What do they look like? Do they include preload='none' attribute? Are the source videos all on the server?

I ask because if you have more than six video tags on a single page pointing to the same source server then you could be experiencing "connection starvation":

  • Chrome allows only six open connections to a single server (based on DNS name in the URL)
  • the html5 video tag's preload attribute default value is 'auto'
  • Chrome's auto behavior is to preload some data and leave the connection open ready to pull more data for the video

So, with more than six video tags on a single page pointing to a single server, the videos will not play. To resolve this particular problem, set the preload attribute to 'none'

like image 194
Stu Thompson Avatar answered Oct 05 '22 01:10

Stu Thompson


Stu is correct. But sometimes, in my experience, Chrome ignores the preload="none" attribute and goes ahead and opens a connection anyway. I've had much problem with this when developing a site which had many smaller videos on it. The connections blocked the rest of the content (images, custom fonts (and when custom fonts are delayed, the text does not even render)) My solution was to build an own preloader which loads the images. This made sure I could control at least when the images (which was the most crucial aspect from a design point of view) was loaded.

That solved the problem with images not showing but the problem still remained. So the best solution is to set up subdomains pointing to the same server, like: v1.server.com, v2.server.com, and so on. This means you won't have to move your files and you get the benefit from enabling browsers to have more open connections. Watch out for increased dns lookup time though.

like image 28
PerMafrost Avatar answered Oct 05 '22 02:10

PerMafrost