Code Monkey home page Code Monkey logo

Comments (6)

alexcrichton avatar alexcrichton commented on May 22, 2024 2

Aha thanks for the hint @s3bk! Also thanks for the source @Marwes!

I've confirmed that the imports in @Marwes's wasm module are:

  (import "env" "Math_acos" (func (;0;) (type 9)))
  (import "env" "Math_atan" (func (;1;) (type 9)))
  (import "env" "Math_atan2" (func (;2;) (type 11)))
  (import "env" "Math_cbrt" (func (;3;) (type 9)))
  (import "env" "Math_cosh" (func (;4;) (type 9)))
  (import "env" "Math_expm1" (func (;5;) (type 9)))
  (import "env" "Math_hypot" (func (;6;) (type 11)))
  (import "env" "Math_log1p" (func (;7;) (type 9)))
  (import "env" "Math_sinh" (func (;8;) (type 9)))
  (import "env" "Math_tan" (func (;9;) (type 9)))
  (import "env" "Math_tanh" (func (;10;) (type 9)))
  (import "env" "__wbindgen_throw" (func (;11;) (type 3)))
  (import "env" "cos" (func (;12;) (type 9)))
  (import "env" "exp" (func (;13;) (type 9)))
  (import "env" "exp2" (func (;14;) (type 9)))
  (import "env" "fma" (func (;15;) (type 14)))
  (import "env" "log" (func (;16;) (type 9)))
  (import "env" "log10" (func (;17;) (type 9)))
  (import "env" "log2" (func (;18;) (type 9)))
  (import "env" "pow" (func (;19;) (type 11)))
  (import "env" "round" (func (;20;) (type 9)))
  (import "env" "sin" (func (;21;) (type 9)))

which is certainly something wasm-bindgen could handle! Ideally it wouldn't need to but I see no harm in fixing this for now.

from wasm-bindgen.

alexcrichton avatar alexcrichton commented on May 22, 2024

Thanks for the report! Is this perhaps due to a wasm-bindgen unknown import? Currently the wasm2es6js tool assumes that the wasm input module is supposed to be interpreted as an ES6 module, but most wasm files produced by rustc right now aren't as there's not module named env.

Would this perhaps be shareable?

from wasm-bindgen.

Marwes avatar Marwes commented on May 22, 2024

The error itself should be reproducible from this branch https://github.com/Marwes/try_gluon/tree/wasm, just run wasm.sh (and make sure that https://github.com/ssuman/parcel-plugin-elm is installed.)

from wasm-bindgen.

 avatar commented on May 22, 2024

I have seen it with mathematical functions. It can be solved by adding env to the import:

const importObject = {
    "./bullet_wasm": {
        __wbindgen_throw: function(ptr, len) {
            throw new Error(getStringFromWasm(ptr, len));
        }
    },
    "env": {
        cos: Math.cos,
        sin: Math.sin,
        exp: Math.exp,
        log: Math.log
    }
}

from wasm-bindgen.

Marwes avatar Marwes commented on May 22, 2024

Installed alexcrichton@d66bc25 and I now get the WASM running! Running it results in an index out of bounds exception however so I am trying to get source maps working to find out why that is.

EDIT: Source maps working, seems to be a index out of bounds when freeing memory :/.

from wasm-bindgen.

DanielRamosAcosta avatar DanielRamosAcosta commented on May 22, 2024

Hey @Marwes how did you get the source maps working?

from wasm-bindgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.