Skip to content

Chore: Upgrade node-canvas to v3.1.0 #12187

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

Conversation

personalizedrefrigerator
Copy link
Collaborator

Summary

This pull request upgrades canvas from v2.11.2 to v3.1.0.

According to the v3.1.0 release, the only breaking change is

Dropped support for Node.js 16.x and below.

canvas also switched from node-pre-gyp to prebuild-install.

Note

pdfjs-dist depends on canvas@npm:^2.11.2. This is overridden in this pull request, using yarn set resolution.

@personalizedrefrigerator
Copy link
Collaborator Author

personalizedrefrigerator commented Apr 29, 2025

Closing for now — canvas v3 is causing build issues on Windows.

Error message:

  ➤ YN0000: │ canvas@npm:3.1.0 STDOUT D:\a\joplin\joplin\packages\app-desktop\node_modules\canvas\src\backend\Backend.h(3,10): error C1083: Cannot open include file: 'cairo.h': No such file or directory [D:\a\joplin\joplin\packages\app-desktop\node_modules\canvas\build\canvas.vcxproj]

@laurent22
Copy link
Owner

For macOS we have this: brew install pango. Maybe we need the equivalent for Windows?

But even better is if we could get rid of canvas as it's causing a lot of problems on all platforms.

@personalizedrefrigerator
Copy link
Collaborator Author

personalizedrefrigerator commented Apr 29, 2025

But even better is if we could get rid of canvas as it's causing a lot of problems on all platforms.

Is canvas used in app-cli for OCR? If not, we could try converting the OCR tests to Playwright end-to-end tests.

Edit: OCR seems to be desktop-only — the OCR service is currently only created in app-desktop/app.ts and in tests. pdfToImages (where node-canvas is used) is currently only used in the plugin API and in OCR service.

Edit 2: If converting the OCR tests to Playwright tests isn't feasible, skia-canvas is another NodeJS canvas library we could try.

@laurent22
Copy link
Owner

As far as I remember, I only added it for the test on CLI. On desktop, we can use the built-in Electron canvas

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

Successfully merging this pull request may close these issues.

2 participants