Skip to content
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

ByteBuffer.asFloat32List() error on dart2js and dartdevk #43204

Closed
sgrekhov opened this issue Aug 27, 2020 · 1 comment
Closed

ByteBuffer.asFloat32List() error on dart2js and dartdevk #43204

sgrekhov opened this issue Aug 27, 2020 · 1 comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-typed-data type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-platform

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Aug 27, 2020

The following programm works in Dart VM but on dart2js and dartdevk produces an error

Runtime error:
RangeError: byte length of Float32Array should be a multiple of 4
import "dart:typed_data";

main() {
  var list1 = new List.filled(5, 0);
  ByteBuffer buffer = new Int8List.fromList(list1).buffer;
  int bufSizeInBytes = buffer.lengthInBytes;
  print(bufSizeInBytes); // 5
  Float32List res = buffer.asFloat32List(0); 
}

Similarly in case of Float64List res = buffer.asFloat64List(0); there will be an error on dart2js and dartdevk RangeError: byte length of Float64Array should be a multiple of 8 and no error in VM

Dart SDK version: 2.10.0-56.0.dev (dev) (Mon Aug 24 09:17:19 2020 -0700) on "windows_x64"

@lrhn lrhn added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-typed-data web-platform labels Aug 27, 2020
@lrhn lrhn added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Oct 2, 2020
@lrhn
Copy link
Member

lrhn commented Jan 27, 2021

It seems the underlying Float32Array(buffer, 0) bails out if the third argument, length, is not provided and buffer.lengthInBytes is not a multiple of 4. Same issue for all other arrays with elements of more than one byte.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-typed-data type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-platform
Projects
None yet
Development

No branches or pull requests

2 participants