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

Re: [Public WebGL] Problem with typed arrays in firefox



That seems correct to me, and Chrome might have the bug -- a 29/30/31-byte ArrayBuffer can't be evenly divided into 4-byte Unit32 segments.  The spec states:

> The given byteOffset must be a multiple of the element size of
> the specific type, otherwise an exception is raised.
> 
> If a given byteOffset and length references an area beyond the
> end of the ArrayBuffer an exception is raised.
>
> If length is not explicitly specified, the length of the ArrayBuffer
> minus the byteOffset must be a multiple of the element size of the
> specific type, or an exception is raised.

byteOffset is 0 if it isn't specified, so the third clause here applies in both cases.  The 0,4 case succeeds, because an explicit offset and length is given -- the resulting Uint32Array will have length 4, where 4*4=16 is less than 29/30/31 so that will succeed.

    - Vlad

----- Original Message -----
> I think this may be a bug - if so I'll file a bug report.
> 
> With firefox 4.b6 on win 7 x64 I'm seeing the following behavior:
> 
> function testCase(size) {
> ab = new ArrayBuffer(size);
> try {
> var xyz = new Uint32Array(ab);
> } catch(err) {
> debug("!" + err + " no args");
> }
> try {
> var xyz = new Uint32Array(ab, 0);
> } catch(err) {
> debug("!" + err + " start");
> }
> try {
> var xyz = new Uint32Array(ab,0,4);
> } catch(err) {
> debug("!" + err + " start, offset");
> }
> 
> }
> 
> gives if size is not a multiple of 4. For example:
> !Error: invalid arguments no args
> !Error: invalid arguments start
> 
> testCase(28); // OK
> testCase(29); // FAILS
> testCase(30); //FAILS
> testCase(31); // FAILS
> testCase(32); //OK
> 
> This applies to ff b6 win 7 x64. Chrome works fine. I've tried the
> latest build but it crashes as
> soon as I open it.
> 
> Thanks
> 
> Alan
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -----------------------------------------------------------
> 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:
-----------------------------------------------------------
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: