[HTML5 System_Create] [ERR] assert: assertion: ‘mCrit[crit]’ failed

Hello everyone,

I’m new to FMOD and I’m trying to use the HTML5 Javascript version of the API but I’m getting this error as soon as I call FMOD.System_Create:

I’ve tried on Chrome (Version 77.0.3865.90 (Official Build) (64-bit)) and Safari (Version 13.0.1) on Mac.

I’m basically trying to play a sound in the browser.

Any ideas?

Here’s my code:

function main () {
  var result
  var outval = {}
  
  result = FMOD.System_Create(outval)
  
  if (result !== FMOD.OK) {
    console.log('result:', result)
  }
}

var FMOD = {};                           // FMOD global object which must be declared to enable 'main' and 'preRun' and then call the constructor function.
FMOD['onRuntimeInitialized'] = main;     // Called when the Emscripten runtime has initialized
FMOD['TOTAL_MEMORY'] = 64 * 1024 * 1024; // (ASM.JS ONLY) FMOD Heap defaults to 16mb which is enough for this demo, but set it differently here for demonstration (64mb)
FMODModule(FMOD);                        // Calling the constructor function with our object

Thank you very much!!

you can ignore that. it is from the logging version and not actually asserting. its due to the no thread / cross platform port of the code. I can look into ifdeffing out that assert.

Use the non ‘L’ version by the way for better performance.

Hello Brett,

Sorry for my late reply, I was away last week.

I’ve tried to ignore the assert, but still no sound is playing. I had a warning saying:

warning: browser could not fully decode audio /ocean.wav, trying slower base64 approach

So I’ve encoded the file in m4a, now the warning disappeared but it seems like FMOD is having a hard time using it, because when I call System.createSound, it doesn’t give me a valid Sound object, in fact it’s giving me an undefined object.

Do you see something obvious I could’ve missed?

Here’s the full code:

function prerun () {
  FMOD.FS_createPreloadedFile(
    '/',
    'ocean.m4a',
    'sounds/',
    true,
    false,
  )
}

function main () {
  var result
  var outval = {}

  result = FMOD.System_Create(outval)

  if (result !== FMOD.OK) {
    console.log('result:', result)
  }

  var System = outval.val
  var outval2 = {}
  System.createSound('/sounds/ocean.m4a', FMOD.LOOP_OFF, null, outval2)
  var Ocean = outval2.val
  console.log('result:', Ocean)
  System.playSound(Ocean, null, false, null)
}

var FMOD = {};                           // FMOD global object which must be declared to enable 'main' and 'preRun' and then call the constructor function.
FMOD['preRun'] = prerun;                 // Will be called because FMOD runs, but after the Emscripten runtime has initialized
FMOD['onRuntimeInitialized'] = main;     // Called when the Emscripten runtime has initialized
FMOD['TOTAL_MEMORY'] = 64 * 1024 * 1024; // (ASM.JS ONLY) FMOD Heap defaults to 16mb which is enough for this demo, but set it differently here for demonstration (64mb)
FMODModule(FMOD);                        // Calling the constructor function with our object

Many thanks!

i think the url part of your createPreloadedFile is wrong
It is supposed to equal folder + filename

check some of the supplied examples first if you cant get basic sound loading to work.

fmod does not support .m4a by the way, but you would see createsound return FMOD.ERR_FORMAT for that. You can see the supported format list at https://www.fmod.com/resources/documentation-api?version=2.0&page=core-api-sound.html#fmod_sound_type

Hello Brett,

I’m sorry I didn’t see the examples.

Thank you very much!

Hi Brett, I’m having the same issue as Janick, but I’m trying to play a sound from an https source and the examples don’t provide any example for this. Issue is happening when I’m calling System.createStream :

let soundOut: any = {};
result = system.createStream('https://cdn2.ipnoscloud.com/streams/web/test.mp3', FMOD.LOOP_NORMAL, null, soundOut);

which results in this output from fmodL.js :

[LOG] SystemI::createSoundInternal             : Create name='https://cdn2.ipnoscloud.com/streams/web/test.mp3', mode=0x00000082

fmod.service.ts:13 fmod error:  A command issued was not supported by this object.  Possibly a plugin without certain callbacks specified. code 68

Thanks for any help!

you cannot use http streaming on this platform

Ok thanks for letting me know, out of curiosity, is it due to the lack of threading?

when the port was done access to sockets werent really available, but it looks like they have been added recently. If it blocks due to no threads, then yes that would be pretty bad. It wraps websockets by the look of it , we’d have to do some testing on this side to see how well it works.