question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error thrown when used in SparkAR, where cannon.js works

See original GitHub issue

Heyhey, 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
marcofugarocommented, Dec 28, 2021

I’ve found the issue, you can’t use npm modules directly from SparkAR, you have to add them as scripts:

Screenshot 2021-12-28 at 16 14 58

For cannon-es specifically, you have to use the dist/cannon.cjs.js file, and import it as

import * as CANNON from './cannon-es'

I’ve made an example starter project with cannon-es already installed:

cannon-es_working.arprojpkg.zip

1reaction
marcofugarocommented, Mar 21, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript Support - Spark AR - Facebook
As well as JavaScript, Meta Spark Studio supports the use of TypeScript. ... Throws a compiler error because we are trying to assign...
Read more >
Hottest 'spark-ar-studio' Answers - Stack Overflow
i just started having the same issue. super simple script, it was working one minute, then started throwing this error, but nothing changed...
Read more >
BlockBuilder AR - Devpost
Create a work of art and then throw a ball at it! ... Spark AR scene objects with physics objects built with the...
Read more >
OwF - River Thames Conditions
Ember js router, Graphics heart, Pmh perth dental, Rb7030 review, ... Islandese lingua, Work related funny video clips, Php model view controller tutorial, ......
Read more >
How to use Cannon.js physics in Spark AR - Medium
Spark seems to have no sense of a global variable/scope. However, in the Cannon module, it assigns a value to a 'performance' variable,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found