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

Add dedicated worker beacon #39

Open
mingyc opened this issue Sep 28, 2022 · 6 comments
Open

Add dedicated worker beacon #39

mingyc opened this issue Sep 28, 2022 · 6 comments

Comments

@mingyc
Copy link
Collaborator

mingyc commented Sep 28, 2022

https://wicg.github.io/unload-beacon/#issue-fdb03e89

ISSUE 2: Add worker beacons as well?

It doesn't make sense to support all types of workers, but only support dedicated worker. It is because a beacon has to be associated with a browsing context and it must not be shared across different context for privacy reason, so service worker & shared worker don't fit the requirement.

@Sora2455
Copy link

In that case, wouldn't the "browsing context" of the dedicated worker be the last browsing context that had the dedicated worker open?

@mingyc
Copy link
Collaborator Author

mingyc commented Sep 28, 2022

Yes. What I mean is to support only dedicated worker. Updated to clarify it.

@mingyc mingyc changed the title Add worker beacon Add dedicated worker beacon Oct 17, 2022
@mingyc
Copy link
Collaborator Author

mingyc commented Oct 28, 2022

Correction to my comment above. There are some concerns around the lifetime of a PendingBeacon P created in a dedicated worker W. Trying to list possible options below:

  1. The same as W's lifetime, meaning that P should be sent out or discarded when W is closed.
    • Easiest to understand and use.
    • But in some cases W can live longer than its parent browsing context (Document, or another DedicatedWorker), which might lead to prviacy issues.
  2. The same as the ancestor Document D (which owns W directly or inderectly via nested dedicated workers)'s lifetime.
    • This means every PendingBeacon P created in W should be attached to D.
    • If W is closed earlier before D is destroyed, it's ok.
    • If W stays active after D is destroyed, anything happens to P must be no-op, and no new PendingBeacon can be created.
      • There might be some undesired contentions happen?
  3. The same as parent browsing context (either a Document or a dedicated worker):
    • If parent is dedicated worker, it does not make sense to attach a PendingBeacon to it.

To me it looks like Option 2 is the one closest to the current PendingBeacon behavior. But in that case, why not just creating PendingBeacon in the Document and waiting for data from worker? Do we really need to allow PendingBeacon in worker?

@fergald
Copy link
Collaborator

fergald commented Oct 28, 2022

If W can still make network requests then it should be able to create a new Beacon and have it send when it is finally destroyed.

@mingyc
Copy link
Collaborator Author

mingyc commented Oct 28, 2022

Ok so basically Option 1. In such case, backgroundTimeout should be disallowed as there is no page visibility event.

@fergald
Copy link
Collaborator

fergald commented Oct 28, 2022

I'm not sure about that disallowing backgroundTimeout. It can still refer to the ancestor frame. We shouldn't make it hard to push code into a worker unless there's a reason why implementing it would be a lot of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants