Skip to content

webcanvas: multi-threaded rendering support#288

Open
tinyjin wants to merge 1 commit into
mainfrom
jinny/thread
Open

webcanvas: multi-threaded rendering support#288
tinyjin wants to merge 1 commit into
mainfrom
jinny/thread

Conversation

@tinyjin

@tinyjin tinyjin commented Jun 4, 2026

Copy link
Copy Markdown
Member

Added a thread preset build, compiled with Emscripten pthread support.

usage:

import ThorVG from '@thorvg/webcanvas/thread';

const TVG = await ThorVG.init({
    renderer: 'sw',
    threads: navigator.hardwareConcurrency,
});
const canvas = new TVG.Canvas('#canvas', { width: 800, height: 600 });

issue: #286

@tinyjin tinyjin self-assigned this Jun 4, 2026
Copilot AI review requested due to automatic review settings June 4, 2026 07:20
@tinyjin tinyjin requested a review from hermet as a code owner June 4, 2026 07:20
@tinyjin tinyjin added enhancement Improve features webcanvas WebCanvas labels Jun 4, 2026

This comment was marked as outdated.

Added a thread preset build, compiled with Emscripten pthread support.

usage:
```
import ThorVG from '@thorvg/webcanvas/thread';

const TVG = await ThorVG.init({
      renderer: 'sw',
      threads: navigator.hardwareConcurrency,
});
const canvas = new TVG.Canvas('#canvas', { width: 800, height: 600 });
```

issue: #286

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 11 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/webcanvas/src/index.ts:227

  • The thread preset currently won’t reliably load the pthread WASM on unpkg because the default locateFile override always returns .../dist/thorvg.wasm for any .wasm request. With @thorvg/webcanvas/thread, the WASM lives under dist/thread/, so this will fetch the single-threaded WASM unless the caller provides locateFile manually.
  // Load WASM module
  Module = await ThorVGModuleFactory({
    locateFile: locateFile ?? ((path: string) => path.endsWith('.wasm') ? THORVG_WASM_URL : path),
  }) as unknown as ThorVGModule;

Comment thread packages/webcanvas/src/index.ts
Comment thread packages/webcanvas/rollup.config.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improve features webcanvas WebCanvas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants