This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23416 - Introduce new concept of neutered
Summary: Introduce new concept of neutered
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: File API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Arun
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 23417
  Show dependency treegraph
 
Reported: 2013-10-02 01:19 UTC by Anne
Modified: 2013-11-13 22:09 UTC (History)
5 users (show)

See Also:


Attachments

Description Anne 2013-10-02 01:19:54 UTC
The concept of neutered you import from HTML is used for structured clones. You should introduce your own concept here as neutering a Blob is unrelated to structured clones.
Comment 1 Glenn Maynard 2013-10-02 01:35:50 UTC
No, they're the same thing: a structured clone of a neutered Blob should throw DataCloneError, and the overall effect should be the same (making the object permanently inaccessible).

(It looks like actually making neutered Blobs throw during structured clone was forgotton, though.  I think I assumed this was done for all objects and didn't need special handling.  I'll file a separate bug.)
Comment 2 Anne 2013-10-02 02:59:50 UTC
Hixie disagreed. That was bug 23385.
Comment 3 Anne 2013-10-02 03:05:25 UTC
And I think I agree with Ian. Transfering and neutering are tied.

This matters even more once https://github.com/dslomov-chromium/ecmascript-structured-clone makes its way into JavaScript as you wouldn't want to annotate a non-transferable with [[Transfer]].
Comment 4 Arun 2013-10-02 03:08:34 UTC
Why exactly?

Do you mean:

1. Coin a new method that is the equivalent of Blob.close() (say, hypothetically, Blob.shut())?

Or

2. Do you mean conceptually separate Blob.close() from structured clones in the prose?

The method name is intuitive, and the behavior is *almost* identical; the concept in HTML is analogous enough to borrow directly from.
Comment 5 Anne 2013-10-02 03:09:56 UTC
2 and as I outlined in comment 2 it is not. Ask Hixie if you need more background.
Comment 6 Glenn Maynard 2013-10-02 03:27:03 UTC
"Ask someone else for more info" isn't really a reasonable response, when you're the one that opened the bug.

FYI, I already filed https://www.w3.org/Bugs/Public/show_bug.cgi?id=23417.  Otherwise, I'd reopen 23385, which was closed without explanation to people reading the bug.

If transferring a neutered Blob doesn't throw an exception, and results in a neutered Blob on the other side, then transferring a neutered ArrayBuffer needs to also not throw an exception and result in a neutered ArrayBuffer on the other side.  The effect of Blob.close() making the Blob inaccessible is logically equivalent to transfer making objects inaccessible.  It's strange and inconsistent for them to have different sets of side-effects.  Dead objects should either be clonable or not, whether they're an ArrayBuffer or a Blob.

Pulling out Blob.close() into a separate thing that's just like neutered but separate is the worst solution.
Comment 7 Ian 'Hixie' Hickson 2013-10-04 21:47:39 UTC
You can't transfer a Blob. It's not Transferable. It doesn't need to be (it has no mutable state that can't be shared). The concept of "neutering" for the purposes of Tranferable objects doesn't apply to things that aren't Transferable.

There's no difficulty here. You just define your own prose term like "neutered blob" and use that.
Comment 8 Glenn Maynard 2013-10-04 21:56:07 UTC
There's nothing specific to Transferable about the effects of neutering.  Closed blobs want the exact same behavior--throwing an exception when the object is accessed or structured cloned--so it should use the same concept, not introduce a new concept that does the same thing.
Comment 9 Olli Pettay 2013-10-04 23:23:20 UTC
I agree with Glenn. No inconsistencies in the APIs, please.
Either you can transfer an object (and neuter it on the original side) or you cannot.
Comment 10 Glenn Maynard 2013-10-05 00:59:15 UTC
I do think that Blob should be a Transferable, and close() should be a Transferable method, since the user-visible behavior of transfer and the immediate-release of .close() are the same: the object is no longer accessible.  However, that's a separate issue, and my argument here is narrower: the concept of "this object is dead and inaccessible", aka neutering, should be the same for both transfer and Blob.close() with identical effects (eg. throwing exceptions on access and structured clone), and transfer is simply one user of the neutering concept.

(Just clarifying a bit, so we don't tangent into the "should Blobs be Transferable" discussion, which is related but orthogonal to this.)
Comment 11 Ian 'Hixie' Hickson 2013-10-07 22:33:28 UTC
The concept of "neutered" in the Transferable sense is "this can't be transferred any more". Anything that isn't Transferable is always in that state, so it doesn't make sense to talk about other things being neutered in the Transferable sense.

If File and Blob should be Transferable (meaning they can't be cloned, or that cloning them is an expensive operation), then that's a different matter. My understanding is that that is not the case currently.


I really don't understand the problem here. It's fine to be able to send the object into a different state. Lots of objects do this. WebSocket objects can get closed. Windows can get closed. XMLHttpRequest objects can go into several states. And so on.
Comment 12 Arun 2013-10-31 22:59:07 UTC
(In reply to Ian 'Hixie' Hickson from comment #11)
> The concept of "neutered" in the Transferable sense is "this can't be
> transferred any more". Anything that isn't Transferable is always in that
> state, so it doesn't make sense to talk about other things being neutered in
> the Transferable sense.
> 
> If File and Blob should be Transferable (meaning they can't be cloned, or
> that cloning them is an expensive operation), then that's a different
> matter. My understanding is that that is not the case currently.
> 
> 
> I really don't understand the problem here. It's fine to be able to send the
> object into a different state. Lots of objects do this. WebSocket objects
> can get closed. Windows can get closed. XMLHttpRequest objects can go into
> several states. And so on.

Blobs aren't going to be Transferable -- they don't need to be.

You're right: it isn't a big deal to roll a new one. 
http://dev.w3.org/2006/webapi/FileAPI/#dfn-close

Marking this fixed.
Comment 13 contributor 2013-11-13 22:09:05 UTC
Checked in as WHATWG revision r8279.
Check-in comment: Update terminology to match File API spec
http://html5.org/tools/web-apps-tracker?from=8278&to=8279