If you tell it to give you a 16-byte Float32Array by passing a length of
16, you get a 16-byte FloatArray. But it is a view on the same ArrayBuffer,
which can be much larger. So the .buffer of that view will potentially be
larger than 16.

On Tue, Jul 21, 2015 at 9:00 PM, Pawel Misiurski <[email protected]>
wrote:

>  Thanks for your quick answer Alon! Data2 has at first normal size: 64
> bytes, but sometimes returned value "return" is being again reused as a
> parameter. So when I use debugger to see sizes of arraybuffers all
> data.buffer.byteLength, data2.buffer.byteLength and
> targetdata.buffer.byteLength return 64 bytes. But when I check
> result.buffer.byteLength it returns exactly 16777216 bytes.
>
> So this line:  var result = new Float32Array(targetHeap.buffer,
> targetHeap.byteOffset, 16);
> produces a result with value as expected:
> [0.000001385850055157789, -1, 7.756424391658356e-10, 0, -1,
> -0.000001385850055157789, 0.0000013868001360606286, 0,
> -0.0000013868001360606286, -7.775643462437642e-10, -1, 0, 0, 0, 0, 1]
>
> but after checking with debugger in the console result.buffer.byteLength
> the length is 16777216 bytes, same as targetHeap.buffer. Now it's
> impossible to feed it back into this function(so it's buffer will be used
> in this line: dataHeap2.set( new Uint8Array(data2.buffer)  ).
>
> Is it an error of Float32Array that it doesn't return a buffer of
> byteLength of 64 or is it because Uint8Array should atomatically truncate
> input? Or is it because the design of my function is wrong?
>
> Following "Uint8Array should atomatically truncate input" I made a change
> to limit amount of data coming to Uint8Array by adding data2.byteOffset and
> nDataBytes parameters:
> dataHeap2.set( new Uint8Array(data2.buffer, data2.byteOffset, nDataBytes)
> );
>
> what's interesting is that the game is now running, but the screen is
> white. At least it's not crashing. Something is still very wrong but it
> looks like tons of calculations are happening now. Only wrong.
>
>
> The returned value after checking it with debugger() on first run
>
> On 22/07/2015 01:10, Alon Zakai wrote:
>
> Where does data2 come from? If you trace that back, you should be able to
> see why it is the wrong array or size.
>
> On Tue, Jul 21, 2015 at 3:41 PM, Pawel Misiurski <
> [email protected]> wrote:
>
>> Hi I'm completely new to Emscripten and I have a problem which I posted
>> on stack overflow, but it's a very niche thing I'm trying to find someone
>> who tried this already.
>>
>> http://stackoverflow.com/questions/31550198/emscripten-uncaught-rangeerror-source-is-too-large-multiple-float32arrays
>>
>>  It looks like once an array has been added to Emscripten's Heap it
>> contains all it's data(only in the buffer).Therefore when trying to send it
>> again to this function I'm getting "Source is too large" error. After 2
>> days maybe I'm missing something or maybe my code is completely wrong? I
>> only want to add that it is not caused by my C++ code because even after
>> commenting out the function call I'm still getting the error.
>>
>>  Thanks for help and in the meantime I'm coming back to pulling my hair
>> out.
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "emscripten-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/emscripten-discuss/JvDRhCWpY2c/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to