PrismarineJS / prismarine-viewer

Web based viewer for servers and bots
https://prismarinejs.github.io/prismarine-viewer/
MIT License
260 stars 71 forks source link

Cannot read property 'getUniformLocation' of null #213

Closed weihao closed 3 years ago

weihao commented 3 years ago

Example demo code does not run, any ideas why? node-canvas-webgl is installed globally

GitHub/prismarine-viewer/examples/exporter$ node screenshot.js
THREE.WebGLRenderer: Cannot read property 'getUniformLocation' of null
(node:1052) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getUniformLocation' of null
    at NodeCanvasElement.getContext (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/node-canvas-webgl/lib/canvas.js:88:39)
    at getContext (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17304:29)
    at new WebGLRenderer (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17335:11)
    at main (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/examples/exporter/screenshot.js:25:20)
    at Object.<anonymous> (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/examples/exporter/screenshot.js:59:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1052) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1052) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
prismarine-viewer/examples$ node headless.js 
THREE.WebGLRenderer: Cannot read property 'getUniformLocation' of null
/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17358
                        throw error;
                        ^

TypeError: Cannot read property 'getUniformLocation' of null
    at NodeCanvasElement.getContext (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/node-canvas-webgl/lib/canvas.js:88:39)
    at getContext (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17304:29)
    at new WebGLRenderer (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17335:11)
    at module.exports (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/lib/headless.js:19:20)
    at EventEmitter.<anonymous> (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/examples/headless.js:10:3)
    at Object.onceWrapper (events.js:481:28)
    at EventEmitter.emit (events.js:387:35)
    at Client.<anonymous> (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/mineflayer/lib/plugins/health.js:13:11)
    at Object.onceWrapper (events.js:482:26)
    at Client.emit (events.js:387:35)
[nodemon] starting `node firstperson_bot.js`
THREE.WebGLRenderer: Cannot read property 'getUniformLocation' of null
/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17358
                        throw error;
                        ^

TypeError: Cannot read property 'getUniformLocation' of null
    at NodeCanvasElement.getContext (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/node-canvas-webgl/lib/canvas.js:88:39)
    at getContext (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17304:29)
    at new WebGLRenderer (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/three/build/three.js:17335:11)
    at module.exports (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/lib/headless.js:19:20)
    at EventEmitter.<anonymous> (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/examples/firstperson_bot.js:10:3)
    at Object.onceWrapper (events.js:481:28)
    at EventEmitter.emit (events.js:387:35)
    at Client.<anonymous> (/mnt/c/Users/forge/Documents/GitHub/prismarine-viewer/node_modules/mineflayer/lib/plugins/health.js:13:11)
    at Object.onceWrapper (events.js:482:26)
    at Client.emit (events.js:387:35)
[nodemon] app crashed - waiting for file changes before starting...
KreizDev commented 3 years ago

Same

KreizDev commented 3 years ago

I fixed this by using xvfb as desktop emulator

xvfb-run -e /dev/stdout -s "-ac -screen 0 800x600x30" python3 app.py