-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SharedWorker is racy #5362
Comments
If I understand what you mean correctly: since Step 11.6 starts a parallel algorithm, we loose the ordering guarantees of the parallel queue on which the algorithm has been running so far. So in theory a "second set of steps" enqueued on the parallel queue could run before the I agree that the spec is not precise on this, and while the Yet in other words, the "shared worker manager" is likely to keep track of "run a worker" algorithms that would have been launched from Step 11.6, so that creating the actual shared worker is not racy.
The problem with that is that when you are on the parallel queue, you're not on the event-loop of the shared worker(which perhaps hasn't even been created yet), so you wouldn't be able to create or manipulate artifacts from that world, see https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-for-spec-authors |
By the way the |
See #4734 (comment) for the latest discussion here. What needs to happen is that we fetch first and then once the response is in (though not necessarily the body) we create the new agent (and possibly an encompassing agent cluster). From @domenic:
|
A top-level navigation response with Cross-Origin-Opener-Policy set to same-origin and Cross-Origin-Embedder-Policy set to require-corp will create a cross-origin isolated browsing context group. And all agent clusters therein will be cross-origin isolated as well (shared and service workers can still not be, as they sit on the side). This change also: * Gates SharedArrayBuffer exposure behind that primitive for web compatibility reasons. * Gates SharedArrayBuffer sharing behind that primitive. * Exposes it through self.crossOriginIsolated. * Makes document.domain return before it mutates the origin. * Makes agent clusters keyed on origin. Tests: * web-platform-tests/wpt#17719 * web-platform-tests/wpt#17760 * web-platform-tests/wpt#17761 * web-platform-tests/wpt#17802 * web-platform-tests/wpt#17909 * web-platform-tests/wpt#18543 * web-platform-tests/wpt#20116 * web-platform-tests/wpt#22358 Closes #4732. Closes #5122. Closes #5444. Follow-up: #5435 (and #5362).
A top-level navigation response with Cross-Origin-Opener-Policy set to same-origin and Cross-Origin-Embedder-Policy set to require-corp will create a cross-origin isolated browsing context group. And all agent clusters therein will be cross-origin isolated as well (shared and service workers can still not be, as they sit on the side). This change also: * Gates SharedArrayBuffer exposure behind that primitive for web compatibility reasons. * Gates SharedArrayBuffer sharing behind that primitive. * Exposes it through self.crossOriginIsolated. * Makes document.domain return before it mutates the origin. * Makes agent clusters keyed on origin. Tests: * web-platform-tests/wpt#17719 * web-platform-tests/wpt#17760 * web-platform-tests/wpt#17761 * web-platform-tests/wpt#17802 * web-platform-tests/wpt#17909 * web-platform-tests/wpt#18543 * web-platform-tests/wpt#20116 * web-platform-tests/wpt#22358 Closes whatwg#4732. Closes whatwg#5122. Closes whatwg#5444. Follow-up: whatwg#5435 (and whatwg#5362).
Shared worker instances with the same url, name and constructor origin must point to the same shared worker. However, since the spec says "in parallel run a worker", the shared worker instances might point to different shared workers.
This happens because SharedWorkerGlobalScope is created after the algorithm is parallelized.
Maybe we should create global scope before parallelizing the algorithm at #dom-sharedworker Step 11.6.
This issue is discussed partially at #5323.
The text was updated successfully, but these errors were encountered: