Repository navigation
chore(🐙): unit test the surface registry and the frame rate vote's cadence on the host - #550
Open
YevheniiKotyrlo wants to merge 3 commits into
Open
YevheniiKotyrlo wants to merge 3 commits into
YevheniiKotyrlo wants to merge 3 commits into
Conversation
Contributor
Author
|
Each test was also run against a deliberately broken registry or cadence: every one of nine single-place breaks of |
This was referenced Oct 16, 2026
…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.
YevheniiKotyrlo
force-pushed
the
test/native-unit-tiers
branch
from
October 16, 2026 13:59
57cf6bf to
ae0fc8b
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.
Most Android bugs land in two places: the surface registry, which carries a canvas's frames across attach, detach, resize and present, and the native code that tells a
SurfaceViewcanvas it animates, for its refresh rate vote. Neither has a unit test, so the e2e suite on a device is the only check on them. This adds a host unit tier for both, run by the CI job that builds that code.The surface registry
packages/webgpu/tests/cppcompilesSurfaceRegistry.hfor the host and linksFakeWebGPU.cppin place of Dawn: the WebGPU C functions the registry calls, which keep what each surface, device and queue was asked to do and record every call Dawn would reject, such as a present without an acquired texture. Every test ends with no rejected call and no leaked object.The tests cover the frame lifecycle: a canvas renders offscreen until a surface attaches; an attached surface is adopted only at a frame boundary, including from the JS thread's flush while another thread renders; the frame rendered before a surface attaches is copied onto it and presented; a frame whose surface is destroyed mid-frame is dropped; an outdated surface is reconfigured once and a failed acquire falls back offscreen; reconfigure resizes the drawing buffer; a pending surface replaced before adoption, and every window the entry holds when it dies, are released exactly once. The registry tests cover find-or-create, the entry React's StrictMode retires while its context still holds it, and an entry whose view owns a surface.
The frame rate vote's cadence
AnimationReporter's timing rule moves unchanged intoandroid/cpp/AnimationCadence.h: a frame presented within 25 ms of its predecessor is an animation frame, the first of an animation is reported once, andreleaseIfIdlere-arms the report once no animation frame came for the idle time Java asks about. It takes the time as an argument whereAnimationReporterread the clock, so the tests drive it with fixed times;AnimationReporterkeeps the clock and the call into Java.yarn test:cppconfigures both with CMake (GoogleTest 1.18.0 from its release tarball, Dawn's headers fromreact-native-webgpu-dawn), builds them intonode_modules/.cache/cpp-testsand runs them with ctest. The Android job runs it before the Gradle build. The hardware-buffer pool and the Metal scheduling wait stay with the e2e suite.Verification
yarn test:cppon Ubuntu 24.04 (g++ 13.3, CMake 3.28): 26 passed. BreakingSurfaceRegistry.hat any of nine single places, orAnimationCadence.hat any of six, fails at least one test.yarn lint·yarn tsc·yarn turbo run build --filter='./packages/*'· the Expo template's web build ·yarn test:plugin·yarn check-dawn·yarn build:docs, the package'scpplintcommand, and the example's Android build.CI=true) on an Android 15 emulator: 219 of 221, as onmain; the two failures, the YUV cases ofExternalTextureColorSpaceandNativeBufferWrapper, fail onmainthere too.Not run here: the workflow itself, which runs on this PR.