bug(hosting): A host destroyed while its scene loads unconfigures its replacement's canvas
Maintainer thường phản hồi trong vòng 1 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
- 50/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- backend-api-design, web-dev
Hướng nghiên cứu
Start by reading the canvas surface release path and the web.host creation and destroy lifecycle, then reproduce the reported sequence with a pending createScene and two hosts sharing one canvas. The issue proposes guarding unconfigure() so an old surface cannot affect its replacement, and optionally aborting scene creation on destroy; done means the replacement can draw after the old load resolves, with any cancellation behavior covered.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
destroy() is meant to be called from import.meta.hot.dispose or an effect cleanup, and "releases everything in order, even while the scene is starting". When destroy arrives while createScene is still pending, it is queued until creation resolves. createScene is never told, so the old scene keeps loading on its own. When it finally resolves, release destroys its canvas surface, which calls context.unconfigure().
A canvas has only one GPUCanvasContext. If a replacement host configured that canvas in the meantime, the replacement's next getCurrentTexture() throws and its scene stops. Any scene that awaits assets or compiles can hit this when it is re-hosted on the same canvas while it loads: Vite HMR, React StrictMode's mount, unmount and remount, or a route change and back.
const first = web.host(async () => {
await slowLoad(); // e.g. models, pipelines.compile
return { frame() {} };
}, { canvas });
first.destroy(); // HMR dispose / effect cleanup, while slowLoad is pending
const second = web.host((root, surface) => ({
frame(frame) { surface.view(frame); },
}), { canvas });
// slowLoad resolves -> first's release unconfigures the shared context
// -> second's first frame: getCurrentTexture() on an unconfigured context, scene stops
Reproduced on 0.1.0 with web.host on recording roots and a single-context canvas stand-in:
configure // first host
first.destroy() // while createScene is pending
configure // second host, same canvas
first scene created // the destroyed load still completes
unconfigure // first's release
second: getCurrentTexture on an unconfigured context (0 frames drawn)
Proposal
- Fix, no API change. A canvas surface unconfigures its context only if it is still the last kit surface configured on that canvas, e.g. a module-level
WeakMap<HTMLCanvasElement, Surface>. - Opt-in cancellation.
createScenegets a fourth argument whose signal aborts when the host or stage is destroyed, or the watched device fails, before creation resolves. The destroyed load can then stop downloading and compiling instead of running to completion on its own:
export type CreateScene<Options, S extends Scene> = (
root: TgpuRoot,
surface: Surface,
options: Options,
context: { readonly signal: AbortSignal },
) => S | Promise<S>;
export async function createScene(root, surface, options, { signal }) {
const bytes = await fetch(url, { signal });
// ...
}
On a React Native worklet runtime without AbortController, the context could offer a cancelled getter instead.
Alternatives
- User land. Keep an
AbortControllerbeside the host, abort it beforedestroy, and pass it in through the options. That covers part 2 but not part 1, sincereleaseruns insideweb.host. - Wait for the old release before hosting again. That needs a promise from
destroy, and HMR disposes and React cleanups are synchronous.
Cost when not used
Part 1 adds one WeakMap lookup per surface destroy. Part 2 adds one AbortController per host; existing createScene functions ignore the extra argument.
- Ngôn ngữ chính
- TypeScript
- Star
- 69
- Fork
- 7
- Merge trung bình
- 1 giờ 48 phút
- Pull request đã merge (30 ngày)
- 15
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-kit
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
software-mansion/typegpu-kit#44 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
software-mansion/typegpu-kit#27 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
software-mansion/typegpu-kit#26 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
software-mansion/typegpu-kit#25 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
software-mansion/typegpu-kit#15 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của software-mansion/typegpu-kit
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ehmpathy/rhachet-roles-bhrain#878 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Chat UI: Message actions dropdown is cut off beneath composer when message is near bottom of chatCó thể đã có người làm @koeria đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
milind-soni/OpenMausBot#8023 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows microphone listing treats words in a device name as DirectShow labelsCó thể đã có người làm @Sujal-chaudhary đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
clipy-recorder/clipy#447 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
nightly-labs/openbot#19162 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
triage:in-progress
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Cotal-AI/Cotal#11229 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày