pixijs / node

Run PixiJS but in Node.js environments, no browser required!
https://pixijs.com
MIT License
36 stars 5 forks source link

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

Open UlyssesZh opened 9 months ago

UlyssesZh commented 9 months ago

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.