-
-
Notifications
You must be signed in to change notification settings - Fork 652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[js] blit may throw "source too large" exception if length is changed #5474
Comments
I tried reading several times but still couldn't get it: could you post some actual code? Also, your issue title is way too long :-) |
I'll try creating some test code. |
I tried creating test code from OpenFL ByteArray impl. This throws "Source too large" error only on js, but not on other targets such as cpp because import haxe.io.Bytes;
import haxe.io.BytesData;
class ExtBytes extends Bytes {
private var __length:Int;
public function new(length:Int)
{
var bytes:Bytes = Bytes.alloc (length);
#if js
super(bytes.b.buffer);
#else
super(length, bytes.b);
#end
__length = length;
}
public function clear ():Void {
length = 0;
}
public function __resize (size:Int) {
if (size > __length) {
var bytes = Bytes.alloc ((((size + 1) * 3) >> 1));
var cacheLength = length;
length = __length;
bytes.blit (0, this, 0, __length);
length = cacheLength;
__setData (bytes);
}
if (length < size) {
length = size;
}
}
private inline function __setData (bytes:Bytes):Void {
b = bytes.b;
__length = bytes.length;
#if js
data = bytes.data;
#end
}
}
class Test {
static function main() {
var src:ExtBytes = new ExtBytes(50);
src.clear();
src.__resize(25);
var dst:ExtBytes = new ExtBytes(20);
dst.clear();
dst.__resize(25);
dst.blit(0, src, 0, 25);
}
} |
I fixed this by checking underlying Uint8Array's byteLength instead of |
We're having the same issue. |
@tbilou yes a PR would work, thanks |
@vroad can you create the pull request? |
Closed by 8c03ac1 |
On js, specifying length in constructor is not allowed, but subclasses of
haxe.io.Bytes
could set this to a different value. OpenFL ByteArray sometimes stops working with this exception on js. Probablyblit()
should usesrc.b.byteLength
(orsrc.b.length
?) to get consistent behavior in this case.The text was updated successfully, but these errors were encountered: