jsartoolkit5
jsartoolkit5 copied to clipboard
Error: "FS is not defined"
This is the actual error shown in the console: artoolkit.api.js:1670 Uncaught ReferenceError: FS is not defined at writeByteArrayToFS (artoolkit.api.js:1670) at XMLHttpRequest.oReq.onload (artoolkit.api.js:1689)
It points to this function in artoolkit.api.js: function writeByteArrayToFS(target, byteArray, callback) { FS.writeFile(target, byteArray, { encoding: 'binary' }); // console.log('FS written', target); callback(byteArray); } Is there any way to get this fixed? For now I added FS.writeFile as an empty function to the global scope to get rid of the error.
@sorskoot: Same here please list the steps that you are taking until this error occurs, thanks.
I had the same issue, it is happening after reloading a page several times on Android/Chrome. My guess is that Chrome does not free all the memory used when reloading a page.
someone could look at this? same error https://github.com/artoolkitx/jsartoolkit5/issues/83
As posted on my branch-PR probably this is a "emscripten" issue the problem is described here: https://github.com/emscripten-core/emscripten/issues/854 and https://stackoverflow.com/questions/15056752/emscripten-using-filesystem-fs
So maybe the fact that the flow did not 'arrive' till a FS function call, meant that FS was not imported at all. Great, thanks!
So maybe the fact that the flow did not 'arrive' till a FS function call, meant that FS was not imported at all. Great, thanks!
@nicolocarpignoli yes, but the fact remains that the code works for me but not for you, This puzzling me a lot...
I'm running into the same issue with my own build now.
From what I found this is not related to Node.js or but actually a reference to Emscripten's own FS module as described here.
Their API seems to have changed now. Reading the documentation I'd expect an FS object to be available on the generated module but I can only see methods like FS_createFolder or FS_createDataFile. Also this API must be enabled by building the module with -s FORCE_FILESYSTEM=1
In case anyone has already solved this, how did you do it?
Solved ... you need to add this to your emscripten module build configuration:
FLAGS += ' -s "EXTRA_EXPORTED_RUNTIME_METHODS=[\'FS\']"';
Afterwards FS will be available as member on the exported module and you can reference it via artoolkit.FS - You simply need to replace FS. with artoolkit.FS. and it should work.