Using any of the png or jpg export functions, Canvas.toBuffer('png') or Canvas::get jpg()/png(), node.js is unable to quit.
Process.exit() just hangs, as does Ctrl+C. Catching the interrupt signal and process.exit() also just hangs.
I have narrowed it down to the toBuffer / get png() or jpg functions.
svg and pdf don't seem to have this problem
Comment out that line and it nodeJS exits no problem (except no image output...), however even quitting just after running toBuffer('png'); also fails to exit
Based on my [limited] understanding of node.js, my theory is that when gpu is enabled, the png/jpg exporter is leaving a thread open/un-reaped which is prevent node.js from exiting fully.
Worth noting, that toBuffer / get png / jpg work fine, and do not hang themselves. Everything works normally until you try and exit node/kill the script, and that's when it just refuses to exit.
(The script stops executing and freezes/hangs, but node does not exit, and requires the entire terminal to be killed or task-manager force quit.)
Workaround:
Set canvas.gpu = false before executing export commands
Environment:
skia-canvas version: 1.0.1
Node 18.12.0
GPU: GTX Titan X
nvidia driver version: 512.77
Windows 10 Pro - 10.0.19044 Build 19044
CPU i7-5960x - 64GB RAM
Important
/edit: The simplest test case exits gracefully, so there's another factor i'm trying to isolate, however what we do know is that it works fine with gpu = disabled OR if we just never export to png/jpg.
Other modules used
discord.js
pqueue
lots more. will try to narrow it down and update
FWIW, I can confirm this issue here. We must kill (SIGTERM) the node process (from inside the program code itself) to exit the application after using GPU rendering and toBuffer('png').
Problem:
Canvas.toBuffer('png')
orCanvas::get jpg()/png()
, node.js is unable to quit.Based on my [limited] understanding of node.js, my theory is that when gpu is enabled, the png/jpg exporter is leaving a thread open/un-reaped which is prevent node.js from exiting fully.
Worth noting, that toBuffer / get png / jpg work fine, and do not hang themselves. Everything works normally until you try and exit node/kill the script, and that's when it just refuses to exit. (The script stops executing and freezes/hangs, but node does not exit, and requires the entire terminal to be killed or task-manager force quit.)
Workaround:
Set
canvas.gpu = false
before executing export commandsEnvironment:
Important
/edit: The simplest test case exits gracefully, so there's another factor i'm trying to isolate, however what we do know is that it works fine with gpu = disabled OR if we just never export to png/jpg.
Other modules used
discord.js pqueue lots more. will try to narrow it down and update