Skip to content
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

Shared memory and deactivated agents #2581

Open
annevk opened this issue Apr 25, 2017 · 0 comments
Open

Shared memory and deactivated agents #2581

annevk opened this issue Apr 25, 2017 · 0 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: multiple globals topic: serialize and transfer topic: workers

Comments

@annevk
Copy link
Member

annevk commented Apr 25, 2017

This is a follow-up to #2521. JavaScript has the following requirement on agents:

An embedding may terminate an agent without any of the agent's cluster's other agents' prior knowledge or cooperation. If an agent is terminated not by programmatic action of its own or of another agent in the cluster but by forces external to the cluster, then the embedding must choose one of two strategies: Either terminate all the agents in the cluster, or provide reliable APIs that allow the agents in the cluster to coordinate so that at least one remaining member of the cluster will be able to detect the termination, with the termination data containing enough information to identify the agent that was terminated.

Boris came up with a scenario that doesn't quite meet this and I found one derived from that:

  1. Tab A does a window.open to a similar-origin tab B. That similar-origin page starts a dedicated worker. That worker starts a child worker. Navigating B will terminate both workers.
  2. Tab A has a cross-origin child frame B. B does a window.open to a similar-origin (with B) tab C. B starts a dedicated worker. A removes B.

For the first scenario B might be able to use unload to tell A, for the second scenario C is effectively lost with the APIs we provide today (you could do keep-alive pings and that might arguably meet the reliable API definition, but it's not great).


I think there are some solutions here where we could notify the agents within the agent cluster without making GC observable, though applications will have to be careful about cleaning up their objects as they might stay alive longer than desired otherwise. (This "memory leak" versus exposing GC tradeoff is what resulted in this not getting addressed last time around.

  1. A suggestion from @lars-t-hansen is that SharedArrayBuffer is reference-counted and has a callback that is invoked each time an instance is added or removed. That is quite low-level and only works for SharedArrayBuffer.
  2. An event that we dispatch to MessagePort's counterpart in the other still active agent whenever the agent whose global to which MessagePort belongs is deactivated for a deterministic reason (such as discarding the browsing context or navigation).
@annevk annevk added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: multiple globals topic: serialize and transfer topic: workers labels Apr 25, 2017
annevk added a commit that referenced this issue Apr 26, 2017
Define the infrastructure for SharedArrayBuffer. This also clarifies
along which boundaries a browser implementation can use processes and
threads.

Tests: web-platform-tests/wpt#5569.

Follow-up to define similar-origin window agents upon a less shaky
foundation is #2528. Because of that, similar-origin window agents
are the best place to store state that would formerly go on unit of
related similar-origin browsing contexts.

Follow-up for better agent shutdown notifications: #2581.

tc39/ecma262#882 is follow-up to define
agents in more detail; in particular make their implicit realms slot
explicit. w3c/css-houdini-drafts#224 is
follow-up to define worklet ownership better which is needed to
define how they relate to agent (sub)clusters.

Fixes part of #2260. Fixes #851. Fixes
w3c/ServiceWorker#1115. Fixes most of
w3c/css-houdini-drafts#380 (no tests and no
nice grouping of multiple realms in a single agent as that is not
needed).
inikulin pushed a commit to HTMLParseErrorWG/html that referenced this issue May 9, 2017
Define the infrastructure for SharedArrayBuffer. This also clarifies
along which boundaries a browser implementation can use processes and
threads.

Tests: web-platform-tests/wpt#5569.

Follow-up to define similar-origin window agents upon a less shaky
foundation is whatwg#2528. Because of that, similar-origin window agents
are the best place to store state that would formerly go on unit of
related similar-origin browsing contexts.

Follow-up for better agent shutdown notifications: whatwg#2581.

tc39/ecma262#882 is follow-up to define
agents in more detail; in particular make their implicit realms slot
explicit. w3c/css-houdini-drafts#224 is
follow-up to define worklet ownership better which is needed to
define how they relate to agent (sub)clusters.

Fixes part of whatwg#2260. Fixes whatwg#851. Fixes
w3c/ServiceWorker#1115. Fixes most of
w3c/css-houdini-drafts#380 (no tests and no
nice grouping of multiple realms in a single agent as that is not
needed).
inikulin pushed a commit to HTMLParseErrorWG/html that referenced this issue May 9, 2017
Define the infrastructure for SharedArrayBuffer. This also clarifies
along which boundaries a browser implementation can use processes and
threads.

Tests: web-platform-tests/wpt#5569.

Follow-up to define similar-origin window agents upon a less shaky
foundation is whatwg#2528. Because of that, similar-origin window agents
are the best place to store state that would formerly go on unit of
related similar-origin browsing contexts.

Follow-up for better agent shutdown notifications: whatwg#2581.

tc39/ecma262#882 is follow-up to define
agents in more detail; in particular make their implicit realms slot
explicit. w3c/css-houdini-drafts#224 is
follow-up to define worklet ownership better which is needed to
define how they relate to agent (sub)clusters.

Fixes part of whatwg#2260. Fixes whatwg#851. Fixes
w3c/ServiceWorker#1115. Fixes most of
w3c/css-houdini-drafts#380 (no tests and no
nice grouping of multiple realms in a single agent as that is not
needed).
alice pushed a commit to alice/html that referenced this issue Jan 8, 2019
Define the infrastructure for SharedArrayBuffer. This also clarifies
along which boundaries a browser implementation can use processes and
threads.

Tests: web-platform-tests/wpt#5569.

Follow-up to define similar-origin window agents upon a less shaky
foundation is whatwg#2528. Because of that, similar-origin window agents
are the best place to store state that would formerly go on unit of
related similar-origin browsing contexts.

Follow-up for better agent shutdown notifications: whatwg#2581.

tc39/ecma262#882 is follow-up to define
agents in more detail; in particular make their implicit realms slot
explicit. w3c/css-houdini-drafts#224 is
follow-up to define worklet ownership better which is needed to
define how they relate to agent (sub)clusters.

Fixes part of whatwg#2260. Fixes whatwg#851. Fixes
w3c/ServiceWorker#1115. Fixes most of
w3c/css-houdini-drafts#380 (no tests and no
nice grouping of multiple realms in a single agent as that is not
needed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: multiple globals topic: serialize and transfer topic: workers
Development

No branches or pull requests

1 participant