fix(ShaderView): Android transparency + correct worklet WebGPU setup (bump rn-webgpu 0.5.15) - #20
Merged
Merged
Conversation
…bump rn-webgpu 0.5.15 - Forward the transparent prop to <Canvas> so transparency works on Android (Android ignores alphaMode; the native transparent prop controls it). - Replace the hand-rolled worklet global injection (which also overwrote the run-loop's setImmediate with requestAnimationFrame) with the official installWebGPU() called inside the render worklet. Removes the fragile cross-worklet ordering and the incorrect setImmediate override. - Bump react-native-webgpu 0.5.14 -> 0.5.15 (adds installWebGPU).
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.
What
Fixes the two high-severity issues found while auditing this library's react-native-webgpu × worklets usage, and bumps
react-native-webgputo the latest (0.5.15).Changes
1. Android transparency was broken
ShaderViewused thetransparentprop only for the clear color and never forwarded it to<Canvas>. Per the rn-webgpu docs, Android ignoresalphaMode— the nativetransparentprop is what enables a transparent surface there. Transparent effects (e.g. dissolves) therefore rendered on an opaque background on Android.2. Incorrect worklet globals setup (
setImmediateoverride + fragile injection)The hand-rolled
initWebGPUhelper injected WebGPU globals into the worklet runtime and, as part of that, did:The worklet run loop (
react-native-worklets≥ 0.8,enableEventLoopdefault) already installs a correctsetImmediate; overwriting it withrequestAnimationFramechanges its semantics (deferred to the next animation-frame flush, passes a timestamp arg). The manual injection also relied on fragile FIFO ordering between two separately-scheduled worklets.react-native-webgpu@0.5.15adds the officialinstallWebGPU()entry point — call it once at the top of a worklet to capture the WebGPU flag constants into that runtime. This PR adopts it and removessrc/utils/initWebGPU.tsentirely:This removes the
setImmediateoverride, drops the unusednavigator.gpu/selfinjection, and makes the WebGPU setup run inline in the render worklet (no cross-worklet ordering dependency).3. Bump
react-native-webgpu0.5.14→0.5.15(root + example), which is what bringsinstallWebGPU().Verification
yarn typecheck✅yarn lint(changed files) ✅Runtime verification on device/simulator still recommended, especially Android transparency.