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

Define the lifetime of a blob URL created inside a service worker #688

Closed
ehsan opened this issue Apr 28, 2015 · 14 comments
Closed

Define the lifetime of a blob URL created inside a service worker #688

ehsan opened this issue Apr 28, 2015 · 14 comments
Labels
Milestone

Comments

@ehsan
Copy link

ehsan commented Apr 28, 2015

Right now in Gecko at least we tie the lifetime of such URLs to the Worker or SharedWorker that created them, but doing the same (as in, invalidating the blob URL when the service worker goes away) seems wrong, since that can happen at any time at UA's discretion.

How should we handle this?

One option that comes to my mind right now is keeping those URLs valid until the service worker that registered them is unregistered.

@jakearchibald
Copy link
Contributor

I think Gecko's current behaviour is correct. Yes, it may get GC'd when the SW closes, but same with variables. If you want a long term way to store a response, the caches api is the way to go right?

Tieing it to registration feels wrong as it would need to survive browser shut down.

What is the current behaviour breaking? I'm wondering if a way to access items in the cache api by url may be a better solution.

@annevk
Copy link
Member

annevk commented Apr 30, 2015

We should maybe restrict this API inside service workers since it's a giant memory leak. And only allow the one-time-minting variant.

@jakearchibald
Copy link
Contributor

Is it a giant memory leak if the data is GC'd when the SW terminates?

@annevk
Copy link
Member

annevk commented Jun 9, 2015

Depends on whether service workers will forever terminate quickly. It seems better to simply not offer APIs that are known to be problematic.

@slightlyoff slightlyoff added this to the Version 1 milestone Oct 28, 2015
@jakearchibald
Copy link
Contributor

@annevk I really don't think this is a problem any more than it is on pages. Service workers are generally not alive longer than pages.

@annevk
Copy link
Member

annevk commented Nov 1, 2015

Right, that argument was made, and the argument against was that it might not remain that way. I guess the other question is why we need blob URLs in service workers since we can just use Request/Response objects.

@jungkees
Copy link
Collaborator

Need a resolution. Would like to discuss at the f2f.

@mfalken
Copy link
Member

mfalken commented Jan 22, 2016

Implementor feedback from Chrome: if we continue to allow blob URLs in service workers, tieing the lifetime to the service worker (i.e., the execution context that created it, not the registration) sounds good. That's what Chrome does already.

@jakearchibald
Copy link
Contributor

F2F resolution: remove createObjectURL

@jungkees
Copy link
Collaborator

@annevk Is it better to make URL.createObjectURL(blob), URL.createFor(blob) and URL.revokeObjectURL(url) explicitly throw in File API spec?

@annevk
Copy link
Member

annevk commented Jan 29, 2016

@jungkees no, I would get the File API specification to use [Exposed=] similar to how XMLHttpRequest does that for e.g., responseXML, to hide these from service workers.

@wanderview
Copy link
Member

@jungkees
Copy link
Collaborator

Closing with w3c/FileAPI#31 merged.

@inexorabletash
Copy link
Member

Blink tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=604951

I filed w3c/media-source#67 since MediaSource has createObjectURL as well.

MediaStream had it as well at some point but it's been removed from the spec.

moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Aug 7, 2018
The appropriate lifetime for URLs created with URL.createObjectURL turned
out to be tricky to define, so it was decided to hide it from service
workers altogether. (w3c/ServiceWorker#688)

This commit implements this change and adds a web platform test to verify it.
It also exposes the MediaSource variant of URL.createObjectURL in DedicatedWorker
and SharedWorker contexts in order to comply with the WebIDL spec (see
w3c/media-source#168 (comment)).

Differential Revision: https://phabricator.services.mozilla.com/D2728

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1264182
gecko-commit: 40d4999db3191bca0aeb75a50b37537ad78102ed
gecko-integration-branch: autoland
gecko-reviewers: mrbkap, asuth
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Aug 7, 2018
The appropriate lifetime for URLs created with URL.createObjectURL turned
out to be tricky to define, so it was decided to hide it from service
workers altogether. (w3c/ServiceWorker#688)

This commit implements this change and adds a web platform test to verify it.
It also exposes the MediaSource variant of URL.createObjectURL in DedicatedWorker
and SharedWorker contexts in order to comply with the WebIDL spec (see
w3c/media-source#168 (comment)).

Differential Revision: https://phabricator.services.mozilla.com/D2728

--HG--
extra : moz-landing-system : lando
jankeromnes pushed a commit to jankeromnes/gecko that referenced this issue Aug 8, 2018
The appropriate lifetime for URLs created with URL.createObjectURL turned
out to be tricky to define, so it was decided to hide it from service
workers altogether. (w3c/ServiceWorker#688)

This commit implements this change and adds a web platform test to verify it.
It also exposes the MediaSource variant of URL.createObjectURL in DedicatedWorker
and SharedWorker contexts in order to comply with the WebIDL spec (see
w3c/media-source#168 (comment)).

Differential Revision: https://phabricator.services.mozilla.com/D2728
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Aug 8, 2018
The appropriate lifetime for URLs created with URL.createObjectURL turned
out to be tricky to define, so it was decided to hide it from service
workers altogether. (w3c/ServiceWorker#688)

This commit implements this change and adds a web platform test to verify it.
It also exposes the MediaSource variant of URL.createObjectURL in DedicatedWorker
and SharedWorker contexts in order to comply with the WebIDL spec (see
w3c/media-source#168 (comment)).

Differential Revision: https://phabricator.services.mozilla.com/D2728

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1264182
gecko-commit: 40d4999db3191bca0aeb75a50b37537ad78102ed
gecko-integration-branch: autoland
gecko-reviewers: mrbkap, asuth
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 3, 2019
The appropriate lifetime for URLs created with URL.createObjectURL turned
out to be tricky to define, so it was decided to hide it from service
workers altogether. (w3c/ServiceWorker#688)

This commit implements this change and adds a web platform test to verify it.
It also exposes the MediaSource variant of URL.createObjectURL in DedicatedWorker
and SharedWorker contexts in order to comply with the WebIDL spec (see
w3c/media-source#168 (comment)).

Differential Revision: https://phabricator.services.mozilla.com/D2728

UltraBlame original commit: 40d4999db3191bca0aeb75a50b37537ad78102ed
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 3, 2019
The appropriate lifetime for URLs created with URL.createObjectURL turned
out to be tricky to define, so it was decided to hide it from service
workers altogether. (w3c/ServiceWorker#688)

This commit implements this change and adds a web platform test to verify it.
It also exposes the MediaSource variant of URL.createObjectURL in DedicatedWorker
and SharedWorker contexts in order to comply with the WebIDL spec (see
w3c/media-source#168 (comment)).

Differential Revision: https://phabricator.services.mozilla.com/D2728

UltraBlame original commit: 40d4999db3191bca0aeb75a50b37537ad78102ed
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 3, 2019
The appropriate lifetime for URLs created with URL.createObjectURL turned
out to be tricky to define, so it was decided to hide it from service
workers altogether. (w3c/ServiceWorker#688)

This commit implements this change and adds a web platform test to verify it.
It also exposes the MediaSource variant of URL.createObjectURL in DedicatedWorker
and SharedWorker contexts in order to comply with the WebIDL spec (see
w3c/media-source#168 (comment)).

Differential Revision: https://phabricator.services.mozilla.com/D2728

UltraBlame original commit: 40d4999db3191bca0aeb75a50b37537ad78102ed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants