Closed Bug 1419727 Opened 2 years ago Closed 2 years ago

SharedWorkers are not shared across content processes

Categories

(Core :: DOM: Workers, enhancement)

57 Branch
enhancement
Not set

Tracking

()

RESOLVED DUPLICATE of bug 1224904

People

(Reporter: schrammel, Unassigned)

Details

(Whiteboard: [specification][type:bug])

What did you do?
================
1. 
2. 
3. 

What happened?
==============
In Firefox Quantum the sharedWorker not send message for others tabs.

What should have happened?
==========================
Should send the messages.

Is there anything else we should know?
======================================
see the issue: https://stackoverflow.com/questions/47414543/firefox-quantum-sharedworker-not-work
This bug does not need to have restricted access.
Group: websites-security
Component: Design → General
OS: Other → All
Priority: -- → P1
Product: Mozilla Developer Network → Firefox
Version: unspecified → 57 Branch
The bug can be easily reproduced on Firefox 57 in this way.

Create a simple Web page containing the following code:
    var sw = new SharedWorker("workers.js");	  
    sw.port.onmessage = function(e) {
       console.log('onmessage', e.data);
    };

Create a file workers.js:
    var count = 0;
    onconnect = function(e) {
        var port = e.ports[0];
        port.postMessage("Count " + count++);
    }

Open the Web page in two tabs.

I expect to see the message “Count 0” on the first tab and “Count 1” on the second tab, but the actual result is “Count 0” on both tabs.

The result is correct if “dom.ipc.multiOptOut” is disabled.
Component: General → DOM: Service Workers
Priority: P1 → --
Product: Firefox → Core
Its a known issue that SharedWorker does not work across content processes.

We're in the middle of fixing service workers for multi-e10s and are unlikely to tackle this until after that.  We will probably reuse some of the infrastructure.  Setting the dependency.

This bug is not really a service worker issue, though, so moving to DOM:Workers.

Andrea, I thought we had a bug for this already, but I can't find it.  Do you know if there is one?

Depending on what you are trying to do with the SharedWorker, you may find that BroadcastChannel is a short term work-around.  It may also not be adequate.
Component: DOM: Service Workers → DOM: Workers
Summary: SharedWorker not work. → SharedWorkers are not shared across content processes
I found the existing bug.  See bug 1224904.
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
No longer depends on: ServiceWorkers-e10s
Resolution: --- → DUPLICATE
Duplicate of bug: SharedWorkers-e10s
Thanks Bean!, i used BroadcastChannel to resolve my problem!
You need to log in before you can comment on or make changes to this bug.