samizdatco / skia-canvas

A GPU-accelerated 2D graphics environment for Node.js
MIT License
1.67k stars 63 forks source link

Can't Initiate window on Windows (Solved after installing Visual C runtime and checking if GPU has Vulkan support) #142

Closed MauriceNorden closed 1 year ago

MauriceNorden commented 1 year ago

Hello there,

I've been stuck for a couple of days now getting you libary to work on any Windows machine. Initialy i was developing a application on my Linux machine but since I need to call some Windows only scripts i wanted to migrate my development enviroment.

So i installed all the packages but got the following error:

$ node index.js 
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: VkLoadingError(LoadingError(LoadLibraryExW { 
source: Os { code: 126, kind: Uncategorized, message: "Kan opgegeven module niet vinden." } }))', src\gpu\vulkan.rs:119:14note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
C:\Users\Gebruiker\Downloads\SysprepGUI-main\node_modules\skia-canvas\lib\index.js:58
      throw error
      ^

Error: internal error in Neon module: called `Result::unwrap()` on an `Err` value: VkLoadingError(LoadingError(LoadLibraryExW { source: Os { code: 126, kind: Uncategorized, message: "Kan opgegeven module niet vinden." } }))
    at App.launch (C:\Users\Gebruiker\Downloads\SysprepGUI-main\node_modules\skia-canvas\lib\index.js:131:10)
    at Timeout.<anonymous> (C:\Users\Gebruiker\Downloads\SysprepGUI-main\node_modules\skia-canvas\lib\index.js:381:65)    
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

First i tought it had something to do with graphics acceleration since i was running it in a virtual machine. So i installed Windows a second time on another machine. Still i got the same error as mentioned before.

I couldn't figure it out but someone suggested me to build the node binary from scratch.

After installing all your build dependencies i still got a error, this time a different one. This is concistent with version 1.0.1 and 1.0.0. I couldn't test versions below that since back in those versions the Window class was not yet introduced.

$ node index.js 
C:\Users\Gebruiker\Downloads\SysprepGUI-main\node_modules\skia-canvas\lib\index.js:382
    neon.App.openWindow(JSON.stringify(win.state), core(win.canvas.pages[win.state.page-1]))
             ^

TypeError: Cannot read property 'openWindow' of undefined
    at Object.openWindow (C:\Users\Gebruiker\Downloads\SysprepGUI-main\node_modules\skia-canvas\lib\index.js:382:14)      
    at new Window (C:\Users\Gebruiker\Downloads\SysprepGUI-main\node_modules\skia-canvas\lib\index.js:280:9)
    at Object.<anonymous> (C:\Users\Gebruiker\Downloads\SysprepGUI-main\index.js:4:11)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

If you have any clue or need extra information about my system or some extra debugging information. Please let me know.

Installed packages:

Node 14.5.0 (Also tried 18.16.1) RustUp 1.26.0 (5af9b9484 2023-04-05) Python 3.11 - 2.7.0 - 3.7 LLVM 16.0.0 Microsoft Build Tools 2022.

System:

CPU: Intel(R) Core(TM) i5-4310U CPU GPU: Intel® HD Graphics 4400 RAM: 8GB DDR3 OS: Windows 10 PRO 22H2 - 19045.3155

MauriceNorden commented 1 year ago

I've "Fixed" the issue. After some more troubleshooting i've found out that the problem is that my GPU does NOT support vulkan wich is essential. So i've grabbed another laptop and after installing NodeJS 18.14.1 and all the Visual C++ Runtimes (This is essential since otherwise the Rust code can't interface with the system) i'm very happy to announce that i can now continue developing.

If you also have a error code something like this:

PS C:\Users\Gebruiker\Desktop\SysprepGUI> node .\index.js 
node:internal/modules/cjs/loader:1340
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: Kan opgegeven module niet vinden.
\\?\C:\Users\Gebruiker\Desktop\SysprepGUI\node_modules\skia-canvas\lib\v6\index.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (C:\Users\Gebruiker\Desktop\SysprepGUI\node_modules\skia-canvas\lib\index.js:23:29)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v18.16.1

I suggest trying installing the Visual C++ Runtimes if you don't have them already. Sadly i don't know wich edition is essential so i suggest installing all of them via this link.

Happy coding everyone!