Re: [whatwg/streams] Add URL.createObjectURL(stream) support (#480)

benwiley4000 left a comment (whatwg/streams#480)

For me, the main requirement for the solution to be interesting is that
users can track download progress (ideally bounded, but even if unbounded)
in their browser UI. The current behavior of no feedback and then a sudden
large download at the end of a variable period of time, is the biggest
problem with the current API from a UX standpoint. Of course, memory usage
is also a valid reason to implement this.

On Tue, Jun 17, 2025, 8:17 a.m. pqnet ***@***.***> wrote:

> *pqnet* left a comment (whatwg/streams#480)
> <https://github.com/whatwg/streams/issues/480#issuecomment-2980150898>
>
> here is another potential solution to all of this: w3c/FileAPI#209
> <https://github.com/w3c/FileAPI/issues/209>
>
> The idea being that you create a virtual blob and still use the good old video.src
> = URL.creataeObjectURL(blob)
>
> const virtualBlob = Blob.from({
> size: 1024,
> async stream(start, end) {
> return customStreamOrAsyncIterable(start, end) // could potential return
> response.body
> }
> })
>
> document.querySelector('video').src = URL.creataeObjectURL(virtualBlob)
>
> This doesn't solve any of the issues that have been presented above:
>
>    - In case where the URL is downloaded multiple times (which may happen
>    for implementation details of the browser) the stream function would
>    be executed multiple times. This is well defined, but will surprise
>    developers when they switch browser.
>    - I seem to understand that adding functionality to createObjectURL is
>    problematic because of explicit reference management. Since there is no way
>    to reliably track whether the URL is in use or not (it is a string) you are
>    forced to manually revokeObjectURL to ensure the resources required by
>    the object are not leaked.
>
> (Note that the <video> case, as well as other HTMLMediaElement elements,
> can already use srcObject to be bound to an object without requiring to
> make an URL for it)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/whatwg/streams/issues/480#issuecomment-2980150898>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADHOD3KLYQFTHCE3O74CHKL3EABOFAVCNFSM6AAAAAB6GWT5WWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOBQGE2TAOBZHA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/480#issuecomment-2980174260
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/480/2980174260@github.com>

Received on Tuesday, 17 June 2025 12:25:49 UTC