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

Canvas crashes bun #13171

Closed
0PandaDEV opened this issue Aug 8, 2024 · 5 comments
Closed

Canvas crashes bun #13171

0PandaDEV opened this issue Aug 8, 2024 · 5 comments
Labels
crash An issue that could cause a crash runtime windows An issue that is known to occur on Windows

Comments

@0PandaDEV
Copy link

How can we reproduce the crash?

"canvas": "^2.11.2"

// generate.ts

import { createCanvas } from 'canvas';
import { fetchDataForAllYears } from './github';
import fs from 'fs';

async function generateContributionImage(username) {
  const data = await fetchDataForAllYears(username, 'flat');
  const contributions = data.contributions;
  const canvasWidth = 53 * 12;
  const canvasHeight = 7 * 12;
  const canvas = createCanvas(canvasWidth, canvasHeight);
  const ctx = canvas.getContext('2d');

  ctx.fillStyle = '#ffffff';
  ctx.fillRect(0, 0, canvasWidth, canvasHeight);

  contributions.forEach(contribution => {
    const date = new Date(contribution.date);
    const x = ((date.getDay() + 1) % 7) * 12; 
    const y = Math.floor(date.getTime() / (1000 * 60 * 60 * 24 * 7)) % 53 * 12; 
    ctx.fillStyle = contribution.color;
    ctx.fillRect(x, y, 10, 10); 
  });

  const buffer = canvas.toBuffer('image/png');
  fs.writeFileSync('./output.png', buffer);
}

generateContributionImage('0pandadev').catch(console.error);
bun run generate.ts

Relevant log output

1 | 'use strict'
2 |
3 | const bindings = require('../build/Release/canvas.node')
          ^
TypeError: LoadLibrary failed: A dynamic link library (DLL) in
      at C:\Users\pandadev\Documents\Developer\Node\twitter-banner\node_modules\canvas\lib\bindings.js:3:7
      at C:\Users\pandadev\Documents\Developer\Node\twitter-banner\node_modules\canvas\lib\canvas.js:9:7
      at C:\Users\pandadev\Documents\Developer\Node\twitter-banner\node_modules\canvas\index.js:1:7

Bun v1.1.15 (Windows x64)
============================================================
Bun v1.1.15 (b23ba1fe) Windows x64
Args: "bun" "run" "src\generate.ts"
Features: jsc dotenv transpiler_cache(3) 
Builtins: "bun:main" "node:assert" "node:buffer" "node:events" "node:fs" "node:http" "node:https" "node:path" "node:stream" "node:string_decoder" "node:url" "node:util" "node:util/types" "node:zlib" 
Elapsed: 366ms | User: 0ms | Sys: 0ms
RSS: 0.14GB | Peak: 0.14GB | Commit: 0.16GB | Faults: 36396

Stack Trace (bun.report)

Bun v1.1.15 (b23ba1f) on windows x86_64 [RunCommand]

Segmentation fault at address 0x7FFC67DF0C70

  • 1 unknown/js code
  • ??? at 0x5177c in ntdll.dll
  • ??? at 0x514d7 in ntdll.dll
  • ??? at 0x5117d in ntdll.dll
  • ??? at 0x17fab in KERNEL32.DLL
  • ??? at 0x1bed8 in ucrtbase.dll
  • ??? at 0x1c099 in ucrtbase.dll
  • Global.zig:123: exitWide
  • Global.zig:106: exit
  • javascript.zig:1094: eventLoop
@0PandaDEV 0PandaDEV added the crash An issue that could cause a crash label Aug 8, 2024
@github-actions github-actions bot added runtime windows An issue that is known to occur on Windows labels Aug 8, 2024
Copy link
Contributor

github-actions bot commented Aug 8, 2024

@0PandaDEV, the latest version of Bun is v1.1.21, but this crash was reported on Bun v1.1.15.

Are you able to reproduce this crash on the latest version of Bun?

bun upgrade

@0PandaDEV
Copy link
Author

upgrading did not fix the problem

@zoto-ff
Copy link

zoto-ff commented Aug 8, 2024

canvas depends on V8 C++ API which is not implemented now, but will be added soon.
try to use @napi-rs/canvas or smth else

@Jarred-Sumner
Copy link
Collaborator

Duplicate of #5835

@Jarred-Sumner Jarred-Sumner marked this as a duplicate of #5835 Aug 8, 2024
@Jarred-Sumner
Copy link
Collaborator

Please follow along in #5835

@Jarred-Sumner Jarred-Sumner closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash runtime windows An issue that is known to occur on Windows
Projects
None yet
Development

No branches or pull requests

3 participants