rbfx icon indicating copy to clipboard operation
rbfx copied to clipboard

Web: Build with ALLOW_MEMORY_GROWTH has intermittent undefined error on load.

Open JTippetts opened this issue 4 years ago • 0 comments

Using "-s ALLOW_MEMORY_GROWTH=1" in the web build results in occasional errors when reloading the page. Typically, the first load will work correctly, but refreshing the page results in an error of the sort:

GoldRush.js:1 Uncaught TypeError: Cannot read property 'buffer' of undefined at Object.write (GoldRush.js:1) at Object.write (GoldRush.js:1) at Object.createDataFile [as FS_createDataFile] (GoldRush.js:1) at DataRequest.finish (Resources.js:110) at DataRequest.onload (Resources.js:105) at processPackageData (Resources.js:295) at IDBRequest.getRequest.onsuccess (Resources.js:254)

Following the error into the generated JS leads to this line write: function(stream, buffer, offset, length, position, canOwn) { if (buffer.buffer === HEAP8.buffer) { canOwn = false } The undefined quantity is HEAP8, which is part of Emscripten's heap allocation boilerplate.

Spamming refresh on the page can occasionally result in a successful load.

System configuration: Have encountered this bug using both an in-tree source build of rbfx as well as rbfx built as an SDK. Emscripten v 2.0.21 Building under Windows natively (using MinGW for the PackageTool build) and Linux Subsystem for Windows both exhibit the bug. Final build hosted locally (using python server) and on github page, both exhibit the bug.

A bare project that shows the behavior is:

https://github.com/JTippetts/TestWebBugRBFX CMake configuration (SDK build):

cmake ..\TestWebBugRBFX -DWEB=1 -DSDK_PATH=c:\Users\verte\Projects\rbfx_WebGL_SDK -DEMSCRIPTEN_ROOT_PATH=c:\Users\verte\Projects\emsdk\upstream\emscripten -DCMAKE_TOOLCHAIN_FILE=c:\Users\verte\Projects\rbfx_WebGL_SDK\share\CMake\Toolchains\Emscripten.cmake -G "MinGW Makefiles"

ALLOW_MEMORY_GROWTH is specified in the project CMakeLists redundantly; using the option by way of EMSCRIPTEN_ALLOW_MEMORY_GROWTH also triggers the bug.

JTippetts avatar Jun 17 '21 23:06 JTippetts