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

Dart2JS ByteBuffers inconsistence #12365

Closed
DartBot opened this issue Aug 10, 2013 · 3 comments
Closed

Dart2JS ByteBuffers inconsistence #12365

DartBot opened this issue Aug 10, 2013 · 3 comments
Labels
closed-duplicate Closed in favor of an existing report

Comments

@DartBot
Copy link

DartBot commented Aug 10, 2013

This issue was originally filed by [email protected]


I'm using dart to create some binary file reader in browser. So, i wrote code, that works with dart:typed_data.ByteData, it uses Uint8List as data keeper and ByteData as raw data converter.
The code i wrote perfectly works on Dartium, but when i've tried to execute dart2js compiled code in Chrome 28.0.1500.95 m (Win7 x64), i've meet up some troubles.

What steps will reproduce the problem?
0. Open in

  1. We have a fullfilled Uint8List Reader._base;
  2. Client code triyng to execute Reader.readInt()
     int readInt(){
        assert(!this.eof);
        ByteBuffer bb = this._base.buffer;
        ByteData bd = new ByteData.view(bb, this._pos, 4);
        assert(bd != null);
        this._seekPos(this._pos+4);
        return bd.getInt32(0, this._endian);
      }
  3. In console i get

Uncaught Error: NoSuchMethodError : method not found: 'Object #<ByteBuffer> has no method 'get$buffer''
Receiver: ""
Arguments: []
Stack Trace:
TypeError: Object #<ByteBuffer> has no method 'get$buffer'
    at $.get$buffer$x (http://127.0.0.1:3030/D:/dev/tmp/repos/odc/odc/web/odc.dart.js:73305:39)
    at Reader.readInt$0 (http://127.0.0.1:3030/D:/dev/tmp/repos/odc/odc/web/odc.dart.js:65194:41)
    at Documents_importDocument (http://127.0.0.1:3030/D:/dev/tmp/repos/odc/odc/web/odc.dart.js:63395:12)

@rakudrama
Copy link
Member

The VM and dart2js implementations are slightly inconsistent.
See Issue #10136.

I suspect that your program has a small bug but works in the VM because a single object (your buffer/list) implements both interfaces: Uint8List and ByteBuffer.

On dart2js these are always separate types - no browser object implements both interfaces.

My guess is that Reader._base is actually initialized to a ByteBuffer. On the VM this does not matter because it is also a Uint8List.
If you compile dart2js in checked mode you should get an exception at the initialization of '_base'.
Or you could try to print the type: print(this._base.buffer.runtimeType);

Because the VM Uint8List is also a ByteBuffer, running on the VM did not help you find this bug.

If my guess is correct I would like to close this bug as a duplicate of Issue #10136.


Added Triaged label.

@DartBot
Copy link
Author

DartBot commented Aug 10, 2013

This comment was originally written by [email protected]


ОК, I see now.

Really, it was my mistake, the HttpRequest.responce's type was unexpected and it was not typechecked in preconditions of Reader's constructor.

Thanks for quick answer!

@anders-sandholm
Copy link
Contributor

Added Duplicate label.
Marked as being merged into #10136.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

4 participants