Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.11k stars 1.16k forks source link

canvas and sharp library conflict #1386

Open windreamlion opened 5 years ago

windreamlion commented 5 years ago

Issue or Feature

objc[2275]: Class GNotificationCenterDelegate is implemented in both //node_modules/canvas/build/Release/libgio-2.0.0.dylib (0x10cfd0498) and //node_modules/sharp/vendor/lib/libgio-2.0.0.dylib (0x10d612498). One of the two will be used. Which one is undefined.

Steps to Reproduce

const Canvas = require('canvas');
const sharp = require('sharp');
var canvas = Canvas.createCanvas(200, 200);
var ctx = canvas.getContext('2d');
// etc.

Your Environment

zbjornson commented 5 years ago

See #930 -- we need to do something to isolate the shared libraries that both modules are using. Unfortunately there's no easy fix or workaround for this. Will leave open for now for visibility, since it's a different error message.

regevaz commented 5 years ago

I'm having exactly the same issue, so I'd be happy too if you can fix it

MarcGodard commented 5 years ago

Same issue here

luminous8 commented 5 years ago

I have the same issue. Do you think that it could create some issues while running my app?

Thanks!

MarcGodard commented 5 years ago

It causes memory leaks for me... Big ones, however, to be fair, something else was causing issues at the same time and haven't figured out if its a combo thing or not.

sixclones commented 5 years ago

Hello

I'm facing the same issue as described previously. Hope you will find a way to resolve this.

Thanks!

occultskyrong commented 4 years ago
canvas              2.5.0
sharp                0.23.3

the same issue . Has someone solved it? ? Although it looks like a warning, it doesn't affect the use .

vin-ni commented 4 years ago

Same problem here

dungmv commented 4 years ago

nothing update

airstep commented 4 years ago

Same

maksym-plotnikov commented 4 years ago

Same here

dungmv commented 4 years ago

I have to use jimp instead of sharp to avoid conflict

jaredtmartin commented 4 years ago

same here

fsobh commented 2 years ago

same Issue here.....

xiaojielade commented 2 years ago

the latest version of sharp and node-cavans, this problem still exists,any solution?

karluiz commented 2 years ago

same here 🌵

Lucas-Geitner commented 2 years ago

Same here 👀

tiholic commented 2 years ago

same here

van-koelljor commented 2 years ago

I got this bug after I had added text-svg to my project dependencies. The package text-svg depends on node-canvas. Then again, node-canvas depends on globally installed libraries, such as cairo.

Installing libvips globally (as suggested in this comment) fixed the issue for me. I'm on mac, so I installed that package via brew: https://formulae.brew.sh/formula/vips#default

ghost commented 2 years ago

Seems canvas should ship up to date binaries.

https://github.com/lovell/sharp/issues/3007#issuecomment-988662604

BrodaNoel commented 1 year ago

Any updates here, people? Any workaround?

sachitha2 commented 1 year ago

same here

jusong-cmd commented 1 year ago

same here

danilstoyanov commented 1 year ago

same here For node I just ended up with firing script with canvas logic inside through the execSync API. So after I generate some content via canvas, I then run sharp via execSync and apply required transformations

VictorioMolina commented 11 months ago

this issue sucks

sepehrsamavati commented 11 months ago

The problem is that they both are running in the same V8/NodeJS instance, this can be solved by separating the instances, e.g. child_process or piscina worker pool. Create a wrapper/helper for canvas/sharp or both and call the wrapper instead of the lib directly.
I had this issue a year ago and if I'm not wrong I just used child process, didn't used piscina for this issue but I highly recommend it.

UPDATE:

favger commented 6 months ago

@sepehrsamavati it worked for me. thanks for your best guidance.

rambo-panda commented 1 month ago

macos: 14.5 (23F79)

sharp@0.33.4 & canvas@2.11.2

It works normally on Windows and Linux, but the following issue occurs on Mac.

But in Mac, although there are such errors, it does not affect the essential usage.