bug(@typegpu/gl): long-lived roots retain unused uniforms and destroyed texture wrappers
メンテナーはふだん 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.5typegpu: 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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
software-mansion/TypeGPU のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
software-mansion/TypeGPU#3219 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
software-mansion/TypeGPU#3213 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
software-mansion/TypeGPU#3008 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
software-mansion/TypeGPU#2948 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
docs: Fix camera orientation in "Monocular Light Injection" example対応中かも @pullfrog が 60 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
software-mansion/TypeGPU#2890 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
software-mansion/TypeGPU の issue をすべて見る
似ている issue
-
check:failed streams:edit
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
iptv-org/iptv#55901 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
package:ios ships XCFrameworks with absolute symlinks, which SwiftPM refuses to extract対応中かも @cusnirvladislav が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
callstackincubator/rock#740 ·
-
S: triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
area:workflow bug ready-for-human
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
fil-donadoni/tolaria#6108 ·
メンテナーはふだん 1 日以内に返信