Error thrown when used in SparkAR, where cannon.js works
See original GitHub issueHeyhey, first of all, thank you for maintaining this!
I’m using “vanilla” cannon.js in my SparkAR-projects (instagrams AR facefilter technology) and am writing a little wrapper for it. I install it using yarn into the project’s script-directory, and from there I can work with it using TypeScript in WebStorm. As I understand it, SparkAR hot reloads the script files referenced in the project, after using webpack to bundle them to some temporary folder in the user directory - this is a bit of a black box.
To reduce bundle size in the face filter projects (and to work with a maintained library) I tried to switch from cannon to cannon-es. I also installed with yarn and can use the library completely normally with code-completion and type recognition. However, when importing cannon-es (or parts of it) into a new or ongoing project TypeScript-file and hot reloading, SparkAR throws this:
JavaScript error: Compiling JS failed: 14984:28:invalid expression Buffer size 1186988 starts with: 2866756e6374696f6e205f5f61726678
This is something happening internally of SparkAR to the bundled version of the script obviously, as it happens on line 14984, and I realize that it’s not a problem of cannon-es per se. However, I have no idea how to debug this and haven’t seen it with other libraries or modules. So I just wanted to ask if any of the contributers here have an idea what could be causing the invalid expression Buffer size
. For the moment I still had to switch back to cannon.js, which is working fine.
If needed information is missing from my post, please let me know, and sorry if it isn’t apropriate to ask this here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I’ve found the issue, you can’t use npm modules directly from SparkAR, you have to add them as scripts:
For cannon-es specifically, you have to use the dist/cannon.cjs.js file, and import it as
I’ve made an example starter project with
cannon-es
already installed:cannon-es_working.arprojpkg.zip
Thanks for the issue! Haven’t tried SparkAR myself, could you maybe share a minimal reproducible project with cannon-es? It will help with debugging. That error is kinda weird, will check if it’s something we added in cannon-es.