Closed Bug 965750 Opened 10 years ago Closed 9 years ago

Opening multiple mega.co.nz tabs breaks JS execution on them.

Categories

(Core :: DOM: Workers, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1052398

People

(Reporter: ferongr, Unassigned)

References

()

Details

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 ID:20140129040227 CSet: efe2d0df801e (2014-01-29)


1. Open the URL multiple times (11 in my case) in new tabs.

2. Try to download from any tab

Nothing happens. No errors in the console either. Also, some tabs (the ones opened last) are broken, showing only a ring-shaped loading indicator. Note that all tabs for that domain end up with broken functionality, not only the ones opened last.

Expected: Page works/downloads happen.
This bug also happens on current release (v26) and the first asm.js-enabled release (v22). I'm unsure on whether a regression range with mozregression would help here.
Does that mean it doesn't happen on v21?
v21 doesn't have asm.js enabled by default AFAIR. My memory from Nightly usage is hazy on how complete the implementation was but I'll test it too.
Does Mega use asm.js, or why do you think that there's a connection?
Yes it does according to the developer console that shows asm.js compulation times. I think it uses it to build blobs and decrypt them with the key in the URL from downloaded chunks.
Interesting. CCing luke, then.
Does the bug reproduce with javascript.options.asmjs = false?
Yes :(. I'll try to find a regression range later.
I can confirm the strange behavior and it happens at exactly 11 tabs with me too.  Note:
  if I open 10 tabs, all fine
  if I now try to open the 11th tab, it hangs while loading as explained in comment 0
  if I close one of the first 10 tabs, the hung tab now loads fine!
I can keep repeating this experiment over and over and it's only when I have >10 simultaneous tabs open that I get a hung tab.

This reproduces with not only asmjs, but all the jits and parallel parsing disabled so I strongly suspect this is not a JS engine bug but, rather, a "feature" of Mega.  I tested in Chrome and there doesn't seem to be any limit, but it's still possible Mega is user-agent sniffing.

Perhaps the next step would be to report a bug: bug@mega.co.nz.
Ah hah!  So we were poking around some more (I am at a DOM meetup after all) and I'm pretty sure the bug is that we limit the number of worker threads per domain to 20 (and I guess mega creates 2 workers per tab).  More workers than 20 can be created, but they don't get to run, which explains the observable behavior and why it recovers when you close one tab.  To confirm, bumping dom.workers.maxPerDomain to 40 lets me open more than 10 tabs.  This is a known bug.
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM: Workers
Ever confirmed: true
Is there a bug number on this? And what would break if I set the dom.workers.maxPerDomain value to something high like 100 and end up with a lot more workers per domain above the default limit?
I'm sure there must be other bugs of the same nature.  I'm waiting for Ben to dup :)

If you set the number to 100, you'll get up to 100 threads (real, kernel threads) per origin.
> And what would break if I set the dom.workers.maxPerDomain value to something high like
> 100 and end up with a lot more workers per domain 

Mostly you'd allow sites to use a lot more CPU and memory.  On Windows there's a higher chance you'd run out of virtual address space and crash....
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.