[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Differing TypedArray#set behavior

On Thu, Apr 12, 2012 at 1:57 AM, Stéphan Kochen <stephan@angrybytes.com> wrote:
> While implementing TypedArrays, I came across a specific situation
> that seems to be missed by the conformance tests. Here's a test:
>  https://github.com/stephank/node-arrays/blob/master/test/typed-array-copy.js
> This does a copy using `TypedArray#set` between two TypedArrays of
> different types, but with the same backing store and overlapping
> regions.

The original intent of the Typed Array spec was that set() only
accepted TypedArrays of the same type as the view on which set() is
called. This is the reason /TypedArray/ is italicized in the IDL in
http://www.khronos.org/registry/typedarray/specs/latest/#7 . The
precise IDL is intended to be
. (It might be out of date since it isn't autogenerated. Boris Zbarsky
recently made a great contribution to the WebGL spec to automatically
extract its Web IDL.)

Therefore, the original intent for your test case was that TypeError
would be thrown upon the call to set(). set(), when passed a typed
array, was supposed to be able to just call memmove().

Unfortunately, it was recently discovered that these semantics were
illegal according to Web IDL -- see
. The Web IDL spec was updated, so now if you pass in a typed array
view of a different type, it will actually match the overload taking a
JS array.

Note: in the case where a typed array is passed to set() and the type
matches the receiver's, memmove() can still be called.

> The test passes on Firefox, but fails on Chrome, Safari, Opera and Node.js.
> Is the Firefox behavior the correct one here?

Firefox's behavior is (now) correct.

On Fri, Apr 13, 2012 at 7:01 AM, Glenn Maynard <glenn@zewt.org> wrote:
> As an aside, it doesn't seem like the conversion is actually defined, eg. if
> you set() an Int16Array onto an Int8Array and some values overflow.  I'm not
> sure where the conversion is defined even for eg. array8[0] = 2000
> (somewhere in WebIDL, I assume), but set() should use the same rules.

The conversions are defined by Web IDL. Is a little more text needed
in the spec of set() to make this clear?

On Sat, Apr 14, 2012 at 7:17 AM, Stéphan Kochen <stephan@angrybytes.com> wrote:
> On Saturday 14 April 2012 at 15:54, Glenn Maynard wrote:
>> Don't forget to add this to the test suite, if it's not there.
> I would love to, but how?

Sorry this wasn't clearer, but information on submitting new tests has
been added to http://www.khronos.org/webgl/wiki/Testing/Conformance .


You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl