I am creating a game based on this boilerplate from RaananW and node v10.13.0. It uses webpack and supports hotloading ← dont take this to mean I have any idea of what I’m talking about, I just know that npm start
runs npx webpack serve --config webpack.dev.js
.
When I started using the boilerplate, assets loaded fine and hotloading was pretty quick. However, after I refactored scene creation a bit, it takes much longer for the game to load the first time, and hotloading fails with an out-of-memory error roughly 80% of the time.
I’m wondering if any Bablyon JS gurus know what I might be doing wrong. Here is where I load in assets, here is the file where I create the scene, and here is where I start the render loop (called by this bit of code that’s basically from the boilerplate).
And, finally, here is what the startup printout looks like:
(node:20876) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
i 「wdm」: assets by path *.glb 219 KiB
asset f1be5aa2d46a7f0ee5873282d82afc34.glb 128 KiB [emitted] (auxiliary name: main)
asset 4493b64ae5efa5687afd18111a91d836.glb 68.5 KiB [emitted] (auxiliary name: main)
asset a9fca8e4f2efa6172032ce70c93fcd52.glb 22.1 KiB [emitted] (auxiliary name: main)
asset js/babylonBundle.js 34.4 MiB [emitted] (name: main)
asset index.html 617 bytes [emitted]
runtime modules 25.4 KiB 12 modules
modules by path ./node_modules/@babylonjs/core/ 8.76 MiB 921 modules
modules by path ./node_modules/@babylonjs/gui/ 660 KiB 61 modules
modules by path ./node_modules/@babylonjs/loaders/glTF/ 349 KiB 38 modules
modules by path ./src/ 69.2 KiB 23 modules
modules by path ./node_modules/webpack-dev-server/ 21.2 KiB
modules by path ./node_modules/webpack-dev-server/client/ 20.9 KiB 10 modules
modules by path ./node_modules/webpack-dev-server/node_modules/ 296 bytes 2 modules
modules by path ./node_modules/webpack/hot/ 4.46 KiB 5 modules
modules by path ./node_modules/html-entities/lib/*.js 61 KiB 5 modules
modules by path ./assets/*.glb 2.57 KiB 4 modules
modules by path ./node_modules/url/ 37.4 KiB 3 modules
modules by path ./node_modules/querystring/*.js 4.51 KiB 3 modules
5 modules
webpack 5.13.0 compiled successfully in 108251 ms
and the error
<--- Last few GCs --->
[20876:000002AAB32DD690] 741000 ms: Scavenge 1308.6 (1422.0) -> 1308.0 (1422.5) MB, 4.5 / 0.0 ms (average mu = 0.255, current mu = 0.243) allocation failure
[20876:000002AAB32DD690] 741009 ms: Scavenge 1309.0 (1422.5) -> 1308.4 (1423.0) MB, 4.7 / 0.0 ms (average mu = 0.255, current mu = 0.243) allocation failure
[20876:000002AAB32DD690] 741018 ms: Scavenge 1309.5 (1423.0) -> 1308.8 (1423.5) MB, 5.4 / 0.0 ms (average mu = 0.255, current mu = 0.243) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 000000DC5625C5C1]
Security context: 0x00027581e6e1 <JSObject>
1: /* anonymous */ [0000033A6B202251] [path\to\guardin-gnomes\node_modules\source-map\lib\source-node.js:~342] [pc=000000DC57D65533](this=0x02cb55d1ad49 <JSGlobal Object>,chunk=0x01a358506621 <String[1]: .>,original=0x02f54db2b3b9 <Object map = 00000213D37BC069>)
2: SourceNode_walk [000002BBDBEEB811] [path\to\guardin-gnomes\...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF79F59ECE5
2: 00007FF79F578196
3: 00007FF79F578BA0
4: 00007FF79F808D5E
5: 00007FF79F808C8F
6: 00007FF79FD469D4
7: 00007FF79FD3D137
8: 00007FF79FD3B6AC
9: 00007FF79FD44627
10: 00007FF79FD446A6
11: 00007FF79F8E7767
12: 00007FF79F97F44A
13: 000000DC5625C5C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! guardin-gnomes@0.0.1 start: `npx webpack serve --config webpack.dev.js`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the guardin-gnomes@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.