Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting PNG or JPG image prevents nodejs exit when gpu = enabled. #126

Open
themrrobert opened this issue Nov 22, 2022 · 1 comment
Open

Comments

@themrrobert
Copy link

themrrobert commented Nov 22, 2022

Problem:

  • 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

@themrrobert themrrobert changed the title Exporting image prevents nodejs exit when gpu = enabled. Exporting PNG or JPG image prevents nodejs exit when gpu = enabled. Nov 22, 2022
@mpaperno
Copy link
Contributor

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').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants