Automattic/node-canvas

Assertion failure when drawing after calling canvas.toBuffer() for PDF or SVG canvas

Open

#1 195 ouverte le 2 juil. 2018

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)JavaScript (1 140 forks)batch import
BugHelp wanted

Métriques du dépôt

Stars
 (9 524 stars)
Métriques de merge PR
 (Merge moyen 34j 18h) (2 PRs mergées en 30 j)

Description

Steps to Reproduce

const canvas = createCanvas(200,200,"svg")
const ctx = canvas.getContext("2d");
canvas.toBuffer()
ctx.fillRect(10,10,100,100) 
canvas.toBuffer()

results in

File: cairo-surface.c, Line 385

Expression: ! surface->finished

toBuffer has a call to cairo_surface_finish. After calling cairo_surface_finish() the only valid operations on a surface are getting and setting user, referencing and destroying, and flushing and finishing it.

We should at least catch that failure so the process doesn't crash. I don't see a way to actually let the canvas continue to be usable for drawing though. (Thought there might be an easy way to copy the content, but not seeing one.)

Your Environment

  • Version of node-canvas (e.g. 1.4.0): master @ b10d204
  • Environment (e.g. node 4.2.0 on Mac OS X 10.8): node 8.x, Win10 x64

Guide contributeur