Repository navigation
fix: keep a frame's surface texture alive through a detach - #558
Draft
YevheniiKotyrlo wants to merge 4 commits into
Draft
YevheniiKotyrlo wants to merge 4 commits into
YevheniiKotyrlo wants to merge 4 commits into
Conversation
…dence on the host SurfaceRegistry.h and AnimationReporter had no unit tests: CI built them and the e2e suite on a device was the only check. tests/cpp compiles the registry for the host against FakeWebGPU.cpp, a stand-in for the WebGPU C functions it calls that records every call Dawn would reject, and `yarn test:cpp` builds and runs it with CMake and GoogleTest. AnimationReporter's timing rule moves unchanged into AnimationCadence, which takes the time as an argument, so the same tests drive it. The Android CI job runs them before the Gradle build.
SurfaceInfo's detach dropped the Dawn surface at once, and Dawn destroys a surface's current texture with it, so a frame that acquired the texture before the UI thread detached the surface submitted a destroyed texture: an uncaptured validation error, "Destroyed texture [Texture "of [Surface]"] used in a submit". The surface now lives until that frame ends, still presenting nothing, or the next frame supersedes it; the native window is released at once as before. The host tests' fake now destroys the texture a surface hands out when the surface presents it, is configured again or is destroyed, and rejects a submit that uses one, as Dawn does.
YevheniiKotyrlo
force-pushed
the
fix/keep-frame-texture-through-detach
branch
from
October 16, 2026 14:10
e9ce30a to
f86d1cd
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #550, whose host tests carry this fix's test; the first commit here is #550's.
Problem
A canvas whose surface detaches while a frame is in flight, on the JS or a worklet thread while the UI thread tears the view down, logs an uncaptured validation error:
SurfaceInfo's detach drops the Dawn surface at once, and Dawn destroys a surface's current texture with it, so the frame's submit uses a destroyed texture. The detach already skips that frame's present; the texture has to last until the frame ends too, as a canvas texture does on the web.Solution
SurfaceInfokeeps the surface of a frame in flight past a detach until the frame ends:presentFrame(), which still presents nothing for it, or the nextgetCurrentTexture()superseding it. The native window is released at once as before. On AndroidreleaseSurfaceForDevicedrops it as well, so its swapchain never outlives a destroyed device.Tests
The host fake now destroys the texture a surface hands out when the surface presents it, is configured again or is destroyed, and rejects a submit that uses a destroyed texture.
SurfaceInfoTest.KeepsTheTextureOfAFrameInFlightThroughADetachhands the surface over, acquires a frame, detaches, copies into the frame's texture and presents: before the fix it fails withQueue.Submit with a destroyed texture, with it all 27 host tests pass.Verification
yarn test:cpp(WSL Ubuntu, g++ 13.3) ·:react-native-webgpu:externalNativeBuildDebug·yarn lint·yarn tsc· the package and web-template builds ·yarn test:plugin·yarn check-dawn·yarn build:docs· the example's iOS build for the simulator SDK. CI's Android e2e step (debug build, Metro withCI=true) on an Android 15 emulator: 219 of 221, as onmain; the two failures, the YUV cases ofExternalTextureColorSpaceandNativeBufferWrapper, fail onmainthere too. On devices the whole suite passes, 221 of 221: on a Galaxy S23 (Android 14), and on an iPhone 12 Pro Max (iOS 27.0.1) built and run as CI's iOS job does on a simulator (Debug build, Metro withCI=true).mainpasses 221 of 221 on both.