Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

bug(@typegpu/gl): long-lived roots retain unused uniforms and destroyed texture wrappers

オープン
#3,153 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, typescript

調査の方向性

Run pnpm verify in the linked reproduction, then read packages/typegpu-gl/src/tgpuRootWebGL.ts and packages/typegpu-gl/src/webglTexture.ts. Trace how root uniform and texture collections retain entries after resource retirement; done means destroyed texture wrappers are no longer retained by a live root and the issue's supported uniform retirement and pipeline-discovery behavior is resolved.

索引モデルが issue の本文から書いたものです。

説明

While replacing resources on one long-lived GL root, I found that the root retains uniform records after callers drop them and texture wrappers after texture.destroy(). The collections grow with each replacement batch and only clear when root.destroy() runs.

Versions

  • @typegpu/gl: 0.12.5
  • typegpu: 0.12.6
  • Chromium: 153.0.8010.12
  • macOS: 27.0.1, arm64, Apple M4

I reproduced the retention with both ANGLE Metal and ANGLE SwiftShader.

Minimal reproduction

The repository https://github.com/Kaleidosium/typegpu-gl-retention-repro contains a small Vite page and a Playwright verification script. It uses no app code, shaders, rendering, images, or TypeGPU build plugin. After cloning it, run:

pnpm install
pnpm exec playwright install chromium
pnpm verify

The browser code creates one root and runs this batch three times:

import { d } from "typegpu";
import { initWithGL } from "@typegpu/gl";

const gl = new OffscreenCanvas(1, 1).getContext("webgl2");
if (!gl) throw new Error("WebGL2 is unavailable");
const root = initWithGL({ gl });

function allocate(count) {
  for (let i = 0; i < count; i++) {
    root.createUniform(d.vec4f);
    const texture = root.createTexture({
      size: [1, 1],
      format: "rgba8unorm",
    });
    texture.destroy();
  }
}

for (let batch = 0; batch < 3; batch++) allocate(100);

After each batch, the verifier forces garbage collection through CDP and reads the root's private collections. It releases its inspection handles after each read. There are no pipelines or caller-owned resource collections keeping these uniforms or textures alive.

Actual result

Checkpoint Root uniform records Raw uniform bytes Root texture wrappers Already destroyed texture wrappers
Initial 0 0 0 0
Batch 1 100 1,600 100 100
Batch 2 200 3,200 200 200
Batch 3 300 4,800 300 300
After root.destroy() 0 0 0 0

The verifier also confirms 300 native deleteTexture calls before root destruction. Native texture deletion works; the destroyed wrappers remain referenced by the root.

Source findings

In TgpuRootWebGL, createUniform() appends to #uniforms and createTexture() appends to #textures. Individual resource retirement does not remove these entries. GL uniforms have no public release method, and the internal uniform implementation's destroy() is a no-op.

createRenderPipeline() also passes this.#uniforms.slice() to the pipeline constructor, which scans the entire collection to find uniforms used by the shader. Its copy and scan therefore include historically created uniforms.

Root implementation, texture destruction.

Expected behavior

Destroyed texture wrappers should be eligible for collection while the root remains alive. For uniforms, is there an intended way to retire records that are no longer used by any pipeline? A supported retirement mechanism would let applications replace resources without retaining all historical records for the root's lifetime.

Pipeline binding discovery should also avoid work proportional to every uniform ever created on the root, where possible.

This report concerns JavaScript bookkeeping retention. The reproduction does not measure physical driver memory or establish a performance regression.

主要言語
TypeScript
スター
3.3k
フォーク
135
平均マージ
4日 1時間
マージ済み PR(30日)
64

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

software-mansion/TypeGPU のほかの issue

software-mansion/TypeGPU の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。