Skip to content

feat: add VideoFrame.nativeBufferColorSpace, on react-native-webgpu 0.26.0 - #11

Merged
andreialecu merged 2 commits into
mainfrom
chore/drop-upstream-patches
Nov 26, 2026
Merged

andreialecu merged 2 commits into
mainfrom
chore/drop-upstream-patches

Conversation

@andreialecu

Copy link
Copy Markdown
Owner

What

Drops the Yarn patches to react-native-webgpu and react-native-skia, now that the changes are released (or turned out not to be needed), and adds VideoFrame.nativeBufferColorSpace.

VideoFrame.nativeBufferColorSpace is the frame's colorSpace in Dawn's names:

RNWebGPU.createNativeBufferFromPointer(frame.pixelBuffer, {
  colorSpace: frame.nativeBufferColorSpace,
});

Without it, Android reads BT.709 video with the BT.601 matrix. On iOS the pixel buffer has its own attachments, and passing it changes nothing. The NativeBufferColorSpace type is defined here, so react-native-webgpu stays a dev dependency.

The README's "Temporary patches" and "Unreleased changes" sections give way to the minimum versions (WebGPU 0.26.0, Skia 3.11.1).

Tests

  • New unit tests for the mapping (src/__tests__/unit/colorSpace.test.ts). yarn test:unit: 70/70.
  • tsc (root and example) and yarn lint are clean.
  • E2E on the Android emulator (API 35): "decodes the export and samples a frame with WebGPU" passes. The BT.709 red bar reads (253, 0, 0); it read (225, 0, 31) before #642. The GOP tests that sample frames through WebGPU pass too.
  • Not run on iOS.

….26.0

The Yarn patches to react-native-webgpu and react-native-skia go away:

- react-native-skia 3.11.1 ships wcandillon/react-native-skia#4510 (Dawn's
  AHardwareBuffer size check skipped on Android). The example moves to 3.13.1.
- react-native-webgpu 0.26.0 ships wcandillon/react-native-webgpu#642:
  createNativeBufferFromPointer takes a colorSpace. The released option names
  color spaces as Dawn does ("rec709", range: "narrow"), not as WebCodecs does
  ("bt709", fullRange), and throws on the WebCodecs names.
- The iOS 26 EDR part of the patch was not needed
  (wcandillon/react-native-webgpu#643 was closed).

VideoFrame.nativeBufferColorSpace is the frame's colorSpace in those names,
for createNativeBufferFromPointer(frame.pixelBuffer, { colorSpace }). Without
it, Android reads BT.709 video with the BT.601 matrix. The README's patch
instructions give way to the minimum versions.
- One ColorSpaceInit type, shared by video.ts and the mapping.
- The tables are Maps: no own-property guard, and the result is built in
  one expression.
- A type-level check in the unit test fails tsc if NativeBufferColorSpace
  drifts from react-native-webgpu's.
- .gitignore and the CI cache key no longer name .yarn/patches.
- Shorter getter docs and README version list; the explanation stays in the
  guide.
@andreialecu
andreialecu merged commit 12f1715 into main Nov 26, 2026
3 of 4 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant