MTG / essentia.js

JavaScript library for music/audio analysis and processing powered by Essentia WebAssembly
https://essentia.upf.edu/essentiajs
GNU Affero General Public License v3.0
645 stars 42 forks source link

TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context #93

Closed OlivierEstevez closed 2 years ago

OlivierEstevez commented 2 years ago

What is the issue about?

What part(s) of Essentia.js is involved?

Description

First of all, excuse me for the newbie question. I'm a designer with some Front-End skills, not a professional programmer. I am making an audio analysis app with React, but I am unable to import Essentia. Since I'm using React I can not use let esPkg = require('essentia.js'), so I ended up importing the packages with the CDN Method. It does work well on Safari, but Chrome gives the following error: Uncaught RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 4KB. Use WebAssembly.compile, or compile on a worker thread.

I did some research and tried using Web Workers, but I think the easiest way for me is just importing the packages. Now all the browsers give the following error: TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context Looks like this functions are deprecated.

Steps to reproduce / Code snippets / Screenshots

import Essentia from "essentia.js/dist/essentia.js-core.es"
import EssentiaWASM from 'essentia.js/dist/essentia-wasm.web.wasm'
import EssentiaWASMWeb from "essentia.js/dist/essentia-wasm.web"
EssentiaWASMWeb(EssentiaWASM)

const instance = new Essentia(EssentiaWASM)

System info

MacBook Pro M1 Pro, MacOS, Google Chrome: 99.0.4844.51, Node: 16.13.0, Essentia.js: 0.1.3

albincorreya commented 2 years ago

For react usage, you can try the ES module imports. See the documentation example here.

The following snippet should work


import Essentia from "essentia.js/dist/essentia.js-core.es.js"
import { EssentiaWASM } from "essentia.js/dist/essentia-wasm.web.wasm.es.js"

const essentia = new Essentia(EssentiaWASM);