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

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

Open
UlyssesZh opened this issue Jan 4, 2024 · 0 comments

Comments

@UlyssesZh
Copy link

UlyssesZh commented Jan 4, 2024

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.

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

1 participant