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

Symbol lookup error on linux #2015

Open
ImRodry opened this issue Apr 2, 2022 · 9 comments
Open

Symbol lookup error on linux #2015

ImRodry opened this issue Apr 2, 2022 · 9 comments

Comments

@ImRodry
Copy link

ImRodry commented Apr 2, 2022

Issue or Feature

Whenever I try to create a canvas my app crashes with the following message:
node: symbol lookup error: /app/node_modules/canvas/build/Release/canvas.node: undefined symbol: pango_fc_font_map_set_default_substitute
There is no error stack associated with this crash, this is all the info I get from it.

Steps to Reproduce

This is a TS code sample but it should be easily convertible to JS. It also requires an image of size 800x200 on a folder called assets with the name joinBackground.png. I, unfortunately, cannot debug this issue further than this function as I don't have access to a Linux machine and this only happens on the server where I host my app.

import { createCanvas, loadImage } from "canvas"

function makeImage() {
// Define assets and create canvas
		const canvas = createCanvas(800, 200),
			ctx = canvas.getContext("2d"),
			userName = "Test username"

		const bg = await loadImage("assets/joinBackground.png")
		let nameWidth: number

		// GENERAL
		// Add background and set basic styling
		ctx.drawImage(bg, 0, 0, 800, 200)
		ctx.fillStyle = "white"

		// TEXT
		// Measure text widths
		ctx.font = "37.5px Arial, sans-serif"
		const welcome = ctx.measureText("Welcome ")
		ctx.font = "37.5px sans, Arial, sans-serif"
		const name = ctx.measureText(userName)
		if (name.width > 550 - welcome.width) nameWidth = 550 - welcome.width
		else nameWidth = name.width

		// Draw 'Welcome ' and '!'
		ctx.font = "37.5px Arial, sans-serif"
		ctx.fillText("Welcome ", 200, 92.5)
		ctx.fillText("!", 200 + welcome.width + nameWidth, 92.5)

		// Draw username
		ctx.font = "37.5px sans, Arial, sans-serif"
		ctx.fillText(userName, 200 + welcome.width, 92.5, 550 - welcome.width)

		// Draw member count
		ctx.font = "30px Bitter, Arial, sans-serif"
		ctx.fillText(`You're member #239`, 200, 132.5)

		// ICON
		// Draw a circle for the image to go into
		ctx.beginPath()
		ctx.arc(100, 100, 75, 0, 2 * Math.PI)
		ctx.closePath()

		// Put the image in the circle
		const userPic = await loadImage("https://cdn.discordapp.com/avatars/240875059953139714/1208d711840f42cd7041e675abeb44ae.png")
		ctx.clip()
		ctx.drawImage(userPic, 25, 25, 150, 150)
		ctx.restore()
}

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas): 2.9.1 (didn't happen in 2.9.0)
  • Environment (e.g. node 4.2.0 on Mac OS X 10.8): node v16.14.2 on Ubuntu 20.04.4 LTS
@flohall
Copy link

flohall commented Apr 25, 2022

I have the same error - not happening with canvas 2.9.0, but with canvas 2.9.1

canvas 2.9.1
AmazonLinux 2 / node 14 / docker container -> failure
Apple M1 Pro / MacOs 12.3.1 / node 14 -> works

node: symbol lookup error: /app/node_modules/canvas/build/Release/canvas.node: undefined symbol: pango_fc_font_map_set_default_substitute

I only had the issue if I called:
canvas.registerFont(font.filePath, {family: font.family});
Without this call I didn't experience the issue, but then I couldn't use my custom fonts anymore.

@flohall
Copy link

flohall commented Apr 25, 2022

@zbjornson - any ideas? - that might related to your last commits

@ezraamos
Copy link

ezraamos commented Jun 8, 2022

any update on this?

@ImRodry
Copy link
Author

ImRodry commented Jun 17, 2022

FYI this is fixed in Ubuntu 22 LTS, the only affected version seems to be v20

@sebastianarena
Copy link

I have the latest Ubuntu 22 LTS and this keeps happening, any idea how to fix? I'm on the latest 2.10.2. I had to revert back to 2.8.0

@rizzle-rohit
Copy link

I have the same error - not happening with canvas 2.9.0, but with canvas 2.9.1

canvas 2.9.1 AmazonLinux 2 / node 14 / docker container -> failure Apple M1 Pro / MacOs 12.3.1 / node 14 -> works

node: symbol lookup error: /app/node_modules/canvas/build/Release/canvas.node: undefined symbol: pango_fc_font_map_set_default_substitute

I only had the issue if I called: canvas.registerFont(font.filePath, {family: font.family}); Without this call I didn't experience the issue, but then I couldn't use my custom fonts anymore.

It worked for me

@sebastianarena
Copy link

I have been testing this.
I'm on the latest Ubuntu 22.04.5.
I have the latest library installed.
I'm using Node 10.
Sometimes I would test it, and it will work. Sometimes it will show the undefined symbol problem.
We do also use sharp, and it seems there are some shared libraries. Maybe that's the problem.
It's hard to pin down.
Will continue testing.

@sebastianarena
Copy link

I stand corrected on the version of Ubuntu. I was previously testing on Ubuntu 20, and now I'm on Ubuntu 22.04.1.
I still have this issue even on the latest ubuntu.
I did try running npm install --build-from-source canvas but ended up on the same place.
On MacOS works without a problem.
Any ideas?

@fakhamatia
Copy link

Any Update?

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

6 participants