Skip to content

fix(device): drain GPU work before teardown#264

Open
besmpl wants to merge 1 commit into
gogpu:mainfrom
besmpl:besmpl/release-drain
Open

fix(device): drain GPU work before teardown#264
besmpl wants to merge 1 commit into
gogpu:mainfrom
besmpl:besmpl/release-drain

Conversation

@besmpl

@besmpl besmpl commented Jul 15, 2026

Copy link
Copy Markdown

Summary

Make Device.Release wait for the HAL device to become idle before releasing pending writes, flushing deferred destruction, destroying pooled encoders, and finally destroying the core/HAL device.

The public WaitIdle method still rejects calls after release. Teardown uses a private waitIdle path because Release marks the device unavailable first, preventing concurrent new work while the final submission is drained.

Why

The previous order set the released bit and then called the public WaitIdle, which immediately returned ErrReleased. Deferred encoder-recycling callbacks could therefore remain queued while HAL destruction reclaimed the same command pools.

Validation

  • go test ./...
  • go test -race .
  • a lifecycle test proves WaitIdle happens before HAL Destroy

This is intentionally separate from the Android work; it fixes native teardown ordering on every backend.

Android preview relationship

This Android-independent prerequisite is stacked into draft #268 at exact head 0ed17064f8c977f35d9b49b5cde0d0c69e867ecf. The draft will rebase it out after merge; Android runtime claims remain gated in that PR.

@besmpl

besmpl commented Jul 15, 2026

Copy link
Copy Markdown
Author

Stacked consumer preview: #268 at exact head b11d2671e80081a191705c41c4e77e8b61472017 incorporates this PR's head 0ed17064f8c977f35d9b49b5cde0d0c69e867ecf (matching stable patch ID).

The preview remains explicitly draft/non-mergeable and will be rebased to Android-only commits after this prerequisite lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant