bug(@typegpu/gl): long-lived roots retain unused uniforms and destroyed texture wrappers
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- computer-graphics
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.3k
- Fork
- 143
- Merge trung bình
- 2 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 72
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của software-mansion/TypeGPU
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
software-mansion/TypeGPU#3327 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
docs: Mnist on small phonesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
software-mansion/TypeGPU#3320 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Opt-out for the module-load eval probe (strict CSP reports a violation on import)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
software-mansion/TypeGPU#3276 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
software-mansion/TypeGPU#3219 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
texture.write(VideoFrame) uses the padded coded size instead of the visible sizeCó thể đã có người làm @RaphaelFakhri đã nhận 18 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
software-mansion/TypeGPU#3213 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của software-mansion/TypeGPU
Issue tương tự
-
content triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
tensorflow/tfjs#8754 ·
-
tool-submission
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
BraveOPotato/NoSignups#2348 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
code-yeongyu/oh-my-openagent#12784 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
external-issue to-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
Maintainer thường phản hồi trong vòng 1 ngày