node icon indicating copy to clipboard operation
node copied to clipboard

Loading SVG does not report useful info when node-canvas is compiled without SVG support

Open UlyssesZh opened this issue 2 years ago • 0 comments

To reproduce:

npm install @pixi/node
apt remove librsvg2-dev # On Debian/Ubuntu; use other commands on other platforms
npm rebuild canvas --build-from-source
vim test.mjs
// test.mjs
import { Assets, SVGResource, BaseImageResource, utils } from '@pixi/node';
import { Image } from 'canvas';

await Assets.init({ skipDetections: true }); // work around #6

// work around #4
let src = SVGResource.prototype._loadSvg.toString().match(/\{(.*)\}/s)[1];
src = src.replace(/tempImage\.src\s*=\s*this\.svg[,;]/, '');
src += 'tempImage.src = this.svg;';
SVGResource.prototype._loadSvg = new Function(
	'Image', 'BaseImageResource', 'uid',
	`return (function _loadSvg() { ${src} });`
)(Image, BaseImageResource, utils.uid);

const asset = await Assets.load('https://raw.githubusercontent.com/UlyssesZh/drawings/master/78(/78(.svg');
console.log(asset);

On Ubuntu 20.04, node test.mjs exits with status 13 without printing anything. On Windows Server 2022, it is stuck forever.

Reproduceable with both @pixi/node 7.2.0 and 7.3.0.

UlyssesZh avatar Jan 04 '24 01:01 UlyssesZh