Skip to content
CAI
Software that uses CAICheck a score

gpujs/gpu.js

48.2

Weak · 1 October 2026

30.4k

lines of production code

JavaScript

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a JavaScript library that enables GPU-accelerated computing by compiling user-defined kernels for execution across multiple backends, including WebGL, WebGL2, WebGPU, WebAssembly, CPU, and HeadlessGL. It provides a unified API for managing asynchronous kernel execution, supporting features like multi-kernel pipelines, graphical rendering modes, and various input types such as images, video, and arrays. The library ensures broad compatibility through modular backend implementations and extensive cross-platform testing, allowing developers to offload heavy computations to the GPU or run them in server-side environments without WebGL support.

How it got here

2016–2018 — Backend expansion and architectural overhaul

11 changes.

This period focused on a major architectural restructuring of the library, introducing a unified Pipeline API and expanding backend support with new implementations for WebGPU, CPU, and WebGL 2. The underlying compilation logic was modularized into dedicated FunctionBuilder and FunctionNode components to improve type inference and support nested functions. Concurrently, extensive test suites were added to validate the new backends, ensure cross-environment consistency, and address numerous regression issues.

2019 — WebGL2 support and backend refactoring

17 changes.

This period focused on expanding GPU.js capabilities by introducing a HeadlessGL backend for server-side execution and implementing full WebGL2 kernel value support. Significant refactoring of the WebGL backend improved texture management, fixed video sizing and binding bugs, and enhanced numerical precision. The work was complemented by extensive unit testing across all backends and the addition of diverse examples demonstrating new features like video processing and TypeScript integration.

2026 — WebGPU and WebAssembly backend expansion

7 changes.

The project introduced new WebGPU and WebAssembly backends to enable high-performance GPU-like computations with fused pipeline execution and asynchronous support. This expansion was accompanied by a comprehensive migration of build and benchmark tooling from Gulp to plain Node scripts, alongside the addition of extensive test suites and BrowserStack infrastructure to validate the new features across diverse environments.

Features

Add WebGL 2 kernel value implementations

This change introduces the WebGL 2-specific implementations for all kernel value types (such as arrays, textures, images, and inputs) in the \src/backend/web-gl2/kernel-value\ directory. Each file defines a class that extends the corresponding base WebGL kernel value, providing the necessary GLSL source generation and value update logic required for the WebGL 2 backend to handle kernel arguments and constants.

src/backend/web-gl2/kernel-value · high confidence

Add cat-image and raster-globe browser examples

Two new interactive browser examples are now available in the examples directory. The cat-image example demonstrates converting an image to a GPU.js kernel for real-time wobble animation, while the raster-globe example showcases a rotating 3D globe using azimuthal equal-area and orthographic projections with custom rotation functions.

examples/cat-image · high confidence

Initial WebGL 2 backend implementation

This change introduces the core files for a new WebGL 2 rendering backend, including the kernel entry point, fragment and vertex shaders, and the function node and kernel value mapping logic. The fragment shader provides GLSL implementations for JavaScript Math functions (such as atan2, cbrt, and bitwise operations) and supports both single-precision and unsigned integer types. The kernel value maps define how various input types (like arrays, textures, and HTML images) are handled in both static and dynamic modes for the WebGL 2 context.

src/backend/web-gl2 · high confidence

Introduce HeadlessGL backend for server-side GPU computation

Adds a new \HeadlessGLKernel\ class in \src/backend/headless-gl/kernel.js\ that extends the existing WebGL kernel to support headless rendering environments. This enables GPU-accelerated kernel execution in Node.js or other non-browser contexts by initializing a virtual GL context, detecting available extensions (such as texture float and draw buffers), and handling canvas resizing via the \STACKGL\_resize\_drawingbuffer\ extension. The implementation includes support for serializing the kernel state via \toString()\ for reuse and ensures proper cleanup of the GL context.

src/backend/headless-gl · high confidence

Major API restructuring and introduction of Pipeline and WebGPU backends

The library has undergone a significant architectural overhaul, introducing a new \Pipeline\ API that allows users to compile multi-kernel computations into a single callable plan with resident intermediates, and adding a \WebGPU\ backend (accessible via \mode: 'webgpu'\) alongside existing WebGL, WebGL2, CPU, and WebAssembly backends. The \GPU\ class now manages these backends through a unified \kernelOrder\ and supports an \async\ mode for non-blocking graphical kernel execution. Additionally, the \Input\ class now exposes a \toArray()\ method for easier data retrieval, and the global binding logic in \browser.js\ has been hardened to prevent conflicts with native WebGPU interfaces and strict-mode loads.

src · high confidence

New CPU backend implementation for kernel execution

The library now includes a CPU-based execution backend, allowing kernels to run in Node.js or environments without WebGL support. This new backend translates kernel logic into standard JavaScript, supporting features such as graphical output via HTMLCanvas, media input handling, and strict integer modes. It provides a fallback path for computation, ensuring broader compatibility across different runtime environments.

src/backend/cpu · high confidence

New WebAssembly backend for GPU computations

A new WebAssembly backend has been added to the library, enabling GPU-like computations to run in the browser or Node.js via WebAssembly. This includes a binary emitter for generating WASM modules, a function node walker for translating kernel logic, a kernel implementation with SIMD and threading support, a fused pipeline executor for efficient multi-step execution, and a worker pool for parallel processing. The backend supports both scalar and SIMD operations, with automatic fallback to scalar paths when SIMD is unavailable, and handles memory management with a bounded cache to prevent excessive memory usage.

src/backend/web-assembly · high confidence

New WebGPU backend with fused pipeline execution and graphical mode

Introduces a new WebGPU backend (mode 'webgpu') that enables high-performance GPU acceleration via compute shaders and storage buffers. This release adds a fused-encoder pipeline executor that batches multiple kernel steps into a single command submission for improved efficiency, and introduces a graphical mode where compute shaders write colors to a buffer that is then presented to a canvas. The backend is fully asynchronous, requiring users to await kernel results, and includes robust handling for device loss and resource management through a shared context singleton and refcounted buffer results.

src/backend/web-gpu · high confidence

New examples for TypeScript typing, JSON serialization, and GPU-accelerated simulations

Added several new demonstration files to the examples directory: \advanced-typescript.ts\ and \simple-typescript.ts\ showcase kernel type inheritance and TypeScript integration; \json-saving.js\ demonstrates serializing and deserializing kernels via JSON; \mandelbulb.html\, \mandelbrot-set.html\, \random.html\, \fluid.html\, and \internal-variable-precision.html\ provide visual examples of 3D fractals, random number generation, fluid dynamics, and variable precision rendering.

examples · high confidence

New video processing example with GPU acceleration

Added a new interactive example in \examples/video/index.html\ that demonstrates real-time video processing using GPU.js. The demo allows users to load a video source and apply graphical kernels to it, with UI controls to toggle GPU/CPU execution, flip the video axes, and alter color channels, while displaying the current frames per second.

examples/video · high confidence

WebGL backend refactored into modular components with precision tactics and bitwise support

The WebGL backend has been restructured into distinct modules (fragment-shader, function-node, kernel, kernel-value-maps, vertex-shader) to support a new precision system and improved type handling. The fragment shader now includes GLSL implementations for bitwise operations (AND, OR, XOR, NOT, shifts) and trigonometric functions (atan2, acosh, etc.), enabling correct behavior for these operators on the GPU. The kernel-value-maps module introduces a 'precision' setting ('unsigned' or 'single') that selects specific kernel value handlers, replacing the previous 'floatOutput' feature. The function-node module handles AST transpilation with support for scalar argument shadowing and strict integer division accuracy fixes. This modularization also supports dynamic output and argument handling, allowing kernels to switch types at runtime without full recompilation.

src/backend/web-gl · high confidence

Security

Removed unused filesystem code from vendored gl-wiretap to resolve security alert

The vendored gl-wiretap library has been updated to remove the unused \writePPM\ function, its associated \readPixelsFile\ option, and the \imageCount\ counter. Although this code was never executed by gpu.js, static analysis tools flagged the presence of \require('fs').writeFileSync\ in the generated transcript as a critical supply-chain risk. Removing this dead code eliminates the false-positive security alert without affecting the core WebGL recording functionality used for kernel export.

src/vendor · high confidence

Architecture

Introduce new backend compilation architecture with FunctionBuilder and FunctionNode

The backend compilation pipeline has been restructured into dedicated modules: \FunctionBuilder\ now orchestrates the state and conversion of function nodes, \FunctionNode\ handles the parsing and validation of individual function sources (including AST scanning and type tracking), and \FunctionTracer\ manages identifier and context tracking during AST traversal. This change replaces the previous monolithic compilation logic with a modular system that supports nested functions, dynamic argument types, and improved type inference for kernel arguments and constants.

src/backend · high confidence

Behavioural changes

Build and benchmark tooling migrated from Gulp to plain Node scripts

The project's build and benchmark tooling has been rewritten from Gulp to plain Node scripts. The build pipeline now uses rolldown instead of browserify, and the banner generation no longer depends on lodash.template. Several new benchmark scripts have been added to measure performance across different backends and configurations: benchmark-async.mjs measures main-thread availability under readback load, benchmark-pipeline-webgpu.mjs benchmarks the WebGPU fused-encoder pipeline against per-pass chaining in a browser, benchmark-pipeline.mjs performs the same comparison in plain Node, benchmark-webasm.mjs compares the WebAssembly backend against CPU and headlessGL, and benchmark-webgpu.mjs compares CPU, WebGL2, and WebGPU in a browser. Additionally, scripts/beautify.js replaces the previous Gulp beautify task, scripts/build-tests.js regenerates the test HTML file, and scripts/dev.js serves the repository for local testing.

scripts · high confidence

Replace triangle-distribution random noise with uniformly distributed PRNG

The plugin system now uses a new \math-random-uniformly-distributed\ plugin to replace the previous \math-random-triangle-noise\ implementation. This change alters the statistical distribution of values generated by \Math.random()\ replacements in shaders from a triangle distribution to a uniform distribution, providing more accurate random sampling. The new plugin also supports deterministic seeding via \kernel.randomSeed\, allowing for reproducible results across runs, whereas the previous implementation relied on a simple noise seed.

src/plugins · high confidence

Fixes

Refactored WebGL kernel generation and string serialization

The WebGL backend's kernel string generation and kernel class implementation have been restructured to improve reliability and feature support. The new \kernel-string.js\ module centralizes the logic for serializing kernel source code, handling argument uploads, and managing framebuffer readbacks for mapped outputs. The \GLKernel\ class now exposes detailed feature detection capabilities, including checks for float read accuracy, integer division precision, and speed tactic support, allowing the runtime to adapt to specific WebGL context limitations. This change also introduces support for \fixIntegerDivisionAccuracy\ and \setPrecision\ settings, ensuring correct numerical results in edge cases across different hardware.

src/backend/gl · high confidence

Refactored WebGL kernel value handling to fix texture binding and video sizing bugs

The WebGL backend's kernel value system has been restructured into specific modules (e.g., \array.js\, \html-image.js\, \single-input.js\) to resolve critical rendering issues. A key fix addresses video inputs that previously sampled arbitrary texels due to incorrect size detection; the new \mediaSize\ helper now correctly prioritizes \videoWidth\/\videoHeight\ over presentational attributes. Additionally, the refactoring introduces a \rebind()\ method to the \WebGLKernelArray\ base class, ensuring that texture bindings are correctly restored to their shared context units between kernel runs, which prevents one kernel's arguments from clobbering another's (issue \#862).

src/backend/web-gl/kernel-value · high confidence

Refactored WebGL texture backend with dedicated classes and reference counting

The WebGL texture backend has been restructured to use a hierarchy of specific texture classes (such as GLTextureFloat, GLTextureUnsigned, and their 2D/3D/array variants) instead of a monolithic implementation. This change introduces explicit reference counting (via the \\_refs\ property) to manage texture lifecycle, preventing memory leaks and framebuffer loss when textures are deleted or cloned. It also adds a \toArray()\ method to all texture types, allowing users to efficiently retrieve kernel output data as standard JavaScript arrays.

src/backend/gl/texture · high confidence

Update browser bundle to version 2.24.1

The distributed browser bundle (dist/gpu-browser-core.js) has been updated to version 2.24.1. This release includes the latest fixes and features for the GPU.js library, ensuring compatibility with the current build environment and providing the most recent bug fixes for kernel execution and backend support.

dist · high confidence

Test coverage

Add BrowserStack real-device and browser testing infrastructure; Added internal test suites for kernel features and resource management; Added regression tests for GPU.js kernel execution and compilation issues; Added test coverage for the new pipeline execution system; Added tests for kernel serialization with single-precision arguments and constants; Added unit tests for CPU and GL kernel internals; Added unit tests for FunctionNode safety checks; Added unit tests for WebGL kernel value texture size validation; Added unit tests for WebGL2 kernel value validation and argument setup; Added unit tests for WebGLFunctionNode AST handling; Added unit tests for WebGLKernel internal setup and validation logic; Expanded WebAssembly backend test coverage and browser test harness; Expanded test coverage for kernel argument types, custom functions, and async mode; WebGPU test suite added.

Dependencies

Update to gpu.js v2.24.1 with dependency and build tooling changes

The package is updated to version 2.24.1, introducing several dependency and build tooling changes. The \gl\ library has been upgraded to version 8.1.6 and moved to optional dependencies, while \acorn\ is pinned to 8.14.0 and \webgpu\ to 0.2.9. The build system has shifted from browserify to rolldown (v1.2.0), and the code coverage tool has been updated from istanbul to c8 (v10.1.2). Browser testing now utilizes Playwright (v1.62.0) alongside Selenium WebDriver (v4.27.0), and the minification tool has been updated to terser (v5.49.0).

(dependencies) · high confidence

Housekeeping

Project scaffolding and documentation updates

This change introduces foundational project documentation and configuration files, including a new CLAUDE.md detailing the build environment (Node 22, rolldown, terser), test execution, and release procedures; a CONTRIBUTING.md outlining pull request guidelines; an ISSUE\_TEMPLATE.md for bug reports; a LICENSE file under the MIT license; and a SECURITY.md defining vulnerability reporting and scope. It also adds a playwright.config.js for running the QUnit suite in real browsers (Chromium, WebKit, Firefox) via Playwright, and updates the .gitignore to exclude runtime data, coverage, and new test artifacts. Additionally, the legacy Ant build.xml file has been removed.

(repo-wide) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 49 → 48 (-0.6)
  • Rubric changed (rubric-2026.09.11 → rubric-2026.09.18) — scores are not directly comparable.

Lenses

  • Code Health 36 → 36 (+0.0)
  • Architecture 93 → 81 (-12.1)
  • Maturity 53 → 53 (+0.1)
  • Readiness 51 → 52 (+1.7)
  • Security 87 → 90 (+2.9)
  • Performance 69 (new)

Resolved (12)

  • Dependency hygiene PARTLY measured — npm pinning read, dependency currency not (no pnpm-resolved versions to grade)
  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)
  • High CVE: [GHSA redacted] (package-lock.json)
  • Hotspot: src/backend/cpu/function-node.js (src/backend/cpu/function-node.js)
  • Hotspot: src/backend/cpu/kernel.js (src/backend/cpu/kernel.js)
  • Hotspot: src/backend/gl/kernel-string.js (src/backend/gl/kernel-string.js)
  • Hotspot: src/backend/gl/kernel.js (src/backend/gl/kernel.js)
  • Hotspot: src/backend/web-gl2/kernel.js (src/backend/web-gl2/kernel.js)
  • Hotspot: src/backend/web-gpu/pipeline-executor.js (src/backend/web-gpu/pipeline-executor.js)
  • Hotspot: src/utils.js (src/utils.js)
  • Off-boarding risk: anonymized user #1

New (12)

  • High CVE: [GHSA redacted] (package-lock.json)
  • High CVE: [GHSA redacted] (package-lock.json)
  • Low cohesion: GLKernel (LCOM4 4) (src/backend/gl/kernel.js)
  • Low cohesion: Kernel (LCOM4 15) (src/backend/kernel.js)
  • Low cohesion: WebGL2Kernel (LCOM4 11) (src/backend/web-gl2/kernel.js)
  • Low cohesion: WebGLFunctionNode (LCOM4 10) (src/backend/web-gl/function-node.js)
  • Medium CVE: [GHSA redacted] (package-lock.json)
  • No assertions: a negated operand never fuses into a decrement (#874) (test/internal/wgsl-codegen.js)
  • Off-boarding risk: anonymized user #1
  • Outdated (npm): acorn
  • Outdated (npm): webgpu
  • Projects may be oversized for their cohesion

Changes since last survey

  • 3 commits — 1 feature/other, 2 fixes

By area

  • (root) — 1 commit
  • src/backend — 1 commit
  • test/issues — 1 commit

Notable commits

  • fix: fix: Parenthesize negated operands so a - -b compiles (#874)
  • fix: test: Keep the #874 regression exact at half precision
  • change: chore: Release 2.24.1

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

gpujs/gpu.js was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 1 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 95c1d6922e8f14f1a9693193c9efe69cfd58dd48 — the exact code this score is about.
  • Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-e569280dd5e2.