react-native-webgpu 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +9 -1
  2. package/android/CMakeLists.txt +1 -0
  3. package/android/cpp/cpp-adapter.cpp +19 -96
  4. package/android/src/main/java/com/webgpu/BackingViewKind.java +5 -22
  5. package/android/src/main/java/com/webgpu/WebGPUAPI.java +0 -2
  6. package/android/src/main/java/com/webgpu/WebGPUModule.java +31 -0
  7. package/android/src/main/java/com/webgpu/WebGPUView.java +17 -34
  8. package/apple/WebGPUModule.mm +22 -0
  9. package/cpp/rnwgpu/GpuPurge.cpp +86 -0
  10. package/cpp/rnwgpu/GpuPurge.h +66 -0
  11. package/cpp/rnwgpu/SurfaceRegistry.h +0 -610
  12. package/cpp/rnwgpu/api/GPUDevice.cpp +59 -32
  13. package/cpp/rnwgpu/api/GPUDevice.h +49 -4
  14. package/cpp/rnwgpu/api/RNWebGPU.h +29 -2
  15. package/cpp/rnwgpu/api/descriptors/CreateNativeBufferFromPointerOptions.h +46 -0
  16. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +21 -15
  17. package/lib/commonjs/Canvas.js +8 -26
  18. package/lib/commonjs/Canvas.js.map +1 -1
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/main/index.js +12 -0
  21. package/lib/commonjs/main/index.js.map +1 -1
  22. package/lib/commonjs/main/index.web.js +11 -0
  23. package/lib/commonjs/main/index.web.js.map +1 -1
  24. package/lib/commonjs/mock.js +4 -1
  25. package/lib/commonjs/mock.js.map +1 -1
  26. package/lib/commonjs/purgeGpuResources.js +29 -0
  27. package/lib/commonjs/purgeGpuResources.js.map +1 -0
  28. package/lib/commonjs/video.js +1 -1
  29. package/lib/commonjs/video.js.map +1 -1
  30. package/lib/module/Canvas.js +8 -26
  31. package/lib/module/Canvas.js.map +1 -1
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/main/index.js +1 -0
  34. package/lib/module/main/index.js.map +1 -1
  35. package/lib/module/main/index.web.js +1 -0
  36. package/lib/module/main/index.web.js.map +1 -1
  37. package/lib/module/mock.js +1 -0
  38. package/lib/module/mock.js.map +1 -1
  39. package/lib/module/purgeGpuResources.js +22 -0
  40. package/lib/module/purgeGpuResources.js.map +1 -0
  41. package/lib/module/video.js +1 -1
  42. package/lib/module/video.js.map +1 -1
  43. package/lib/typescript/lib/commonjs/Canvas.d.ts.map +1 -1
  44. package/lib/typescript/lib/commonjs/mock.d.ts +1 -0
  45. package/lib/typescript/lib/commonjs/mock.d.ts.map +1 -1
  46. package/lib/typescript/lib/commonjs/purgeGpuResources.d.ts +18 -0
  47. package/lib/typescript/lib/commonjs/purgeGpuResources.d.ts.map +1 -0
  48. package/lib/typescript/lib/commonjs/video.d.ts +1 -1
  49. package/lib/typescript/lib/commonjs/video.d.ts.map +1 -1
  50. package/lib/typescript/lib/module/Canvas.d.ts.map +1 -1
  51. package/lib/typescript/lib/module/main/index.d.ts +1 -0
  52. package/lib/typescript/lib/module/main/index.web.d.ts +1 -0
  53. package/lib/typescript/lib/module/mock.d.ts +1 -0
  54. package/lib/typescript/lib/module/mock.d.ts.map +1 -1
  55. package/lib/typescript/lib/module/purgeGpuResources.d.ts +2 -0
  56. package/lib/typescript/lib/module/purgeGpuResources.d.ts.map +1 -0
  57. package/lib/typescript/lib/module/video.d.ts +1 -1
  58. package/lib/typescript/lib/module/video.d.ts.map +1 -1
  59. package/lib/typescript/src/Canvas.d.ts +2 -12
  60. package/lib/typescript/src/Canvas.d.ts.map +1 -1
  61. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts +1 -1
  62. package/lib/typescript/src/WebGPUViewNativeComponent.d.ts.map +1 -1
  63. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts +1 -1
  64. package/lib/typescript/src/WebGPUViewNativeComponent.web.d.ts.map +1 -1
  65. package/lib/typescript/src/index.d.ts +3 -2
  66. package/lib/typescript/src/index.d.ts.map +1 -1
  67. package/lib/typescript/src/main/index.d.ts +1 -0
  68. package/lib/typescript/src/main/index.d.ts.map +1 -1
  69. package/lib/typescript/src/main/index.web.d.ts +1 -0
  70. package/lib/typescript/src/main/index.web.d.ts.map +1 -1
  71. package/lib/typescript/src/mock.d.ts +2 -1
  72. package/lib/typescript/src/mock.d.ts.map +1 -1
  73. package/lib/typescript/src/purgeGpuResources.d.ts +17 -0
  74. package/lib/typescript/src/purgeGpuResources.d.ts.map +1 -0
  75. package/lib/typescript/src/types.d.ts +12 -0
  76. package/lib/typescript/src/types.d.ts.map +1 -1
  77. package/lib/typescript/src/video.d.ts +2 -2
  78. package/lib/typescript/src/video.d.ts.map +1 -1
  79. package/package.json +1 -1
  80. package/scripts/prepare-apple-binaries.sh +9 -3
  81. package/src/Canvas.tsx +12 -50
  82. package/src/WebGPUViewNativeComponent.ts +1 -1
  83. package/src/WebGPUViewNativeComponent.web.ts +1 -1
  84. package/src/index.tsx +6 -1
  85. package/src/main/index.tsx +1 -0
  86. package/src/main/index.web.tsx +1 -0
  87. package/src/mock.ts +2 -1
  88. package/src/purgeGpuResources.ts +21 -0
  89. package/src/types.ts +13 -0
  90. package/src/video.ts +6 -1
  91. package/android/src/main/java/com/webgpu/WebGPUHardwareBufferView.java +0 -278
@@ -5,5 +5,6 @@ export * from "../WebGPUViewNativeComponent";
5
5
  export * from "../hooks";
6
6
  export * from "../GPUDeviceProvider";
7
7
  export * from "../formats";
8
+ export * from "../purgeGpuResources";
8
9
  export * from "../video";
9
10
  //# sourceMappingURL=index.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/main/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAEzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/main/index.web.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAEzB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC"}
@@ -8,7 +8,7 @@ export declare const GPUTextureUsage: GPUTextureUsage;
8
8
  export declare const GPUShaderStage: GPUShaderStage;
9
9
  export declare const GPUColorWrite: GPUColorWrite;
10
10
  export declare const GPUMapMode: GPUMapMode;
11
- export type { AndroidBackingView, AndroidCanvasProps, AndroidHardwareBufferViewProps, AndroidSurfaceViewProps, AndroidTextureViewProps, CanvasProps, CanvasRef, NativeCanvas, RNCanvasContext, } from "./Canvas";
11
+ export type { AndroidBackingView, AndroidCanvasProps, AndroidSurfaceViewProps, AndroidTextureViewProps, CanvasProps, CanvasRef, NativeCanvas, RNCanvasContext, } from "./Canvas";
12
12
  export declare const Canvas: ({ android: _android, ref, ...props }: CanvasProps) => React.FunctionComponentElement<Omit<import("react-native").ViewProps, "ref"> & {
13
13
  ref?: React.Ref<import("react-native").ViewInstance> | undefined;
14
14
  }>;
@@ -34,6 +34,7 @@ export declare const GPUDeviceProvider: ({ children }: {
34
34
  children?: ReactNode;
35
35
  }) => string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null;
36
36
  export declare const useMainDevice: () => never;
37
+ export declare const purgeGpuResources: () => undefined;
37
38
  export declare const importDevice: (_pointer: bigint) => GPUDevice;
38
39
  export declare const adoptTexture: (_pointer: bigint) => GPUTexture;
39
40
  export declare const installWebGPU: () => undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/mock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,WAAW,EAAiC,MAAM,UAAU,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAahE,cAAc,WAAW,CAAC;AAM1B,eAAO,MAAM,cAAc,EAAE,cAW5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,eAO7B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAI5B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,aAM3B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,UAGxB,CAAC;AAoBF,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,EACvB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,MAAM,GAAI,sCAAsC,WAAW;;EASvE,CAAC;AAEF,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,gBAAgB,GAAI,mFAK9B,qBAAqB;;EAQvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM;;;CAGtD,CAAC;AAEH,eAAO,MAAM,YAAY,6BAA2B,CAAC;AACrD,eAAO,MAAM,UAAU;;;CAAqD,CAAC;AAC7E,eAAO,MAAM,4BAA4B,iBAAkB,CAAC;AAE5D,eAAO,MAAM,SAAS;;;CAA0C,CAAC;AAEjE,eAAO,MAAM,iBAAiB,GAAI,cAAc;IAA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,GACpB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,gBAAgB,GAAI,mFAK9B,qBAAqB;;EAQvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,cAAc,MAAM;;;CAGtD,CAAC;AAEH,eAAO,MAAM,YAAY,6BAA2B,CAAC;AACrD,eAAO,MAAM,UAAU;;;CAAqD,CAAC;AAC7E,eAAO,MAAM,4BAA4B,iBAAkB,CAAC;AAE5D,eAAO,MAAM,SAAS;;;CAA0C,CAAC;AAEjE,eAAO,MAAM,iBAAiB,GAAI,cAAc;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,6UACtD,CAAC;AAEnB,eAAO,MAAM,aAAa,QAAO,KAEhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,iBAAkB,CAAC;AAEjD,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,SAE/C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,UAE/C,CAAC;AAEF,eAAO,MAAM,aAAa,iBAAkB,CAAC;AAE7C,eAAO,MAAM,qBAAqB,GAAI,UAAU,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,WAC/B,CAAC;AAE7C,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,SACV,CAAC;AAE1C,eAAO,MAAM,YAAY;;CAA2B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns the GPU memory nothing uses to the system. Most apps should never
3
+ * call it: `destroy()` lets Dawn reuse the memory, and react-native-webgpu
4
+ * purges on its own when the system is short of memory and, on Android, each
5
+ * time the app goes to the background.
6
+ *
7
+ * It is meant for a one-off peak (a video export) followed by a long stretch
8
+ * that needs far less GPU memory. Not for a render loop, not after each
9
+ * `destroy()`, not on unmount: memory Dawn would have reused has to be
10
+ * requested from the system again. It does not free what was not destroyed.
11
+ *
12
+ * It returns right away and works in the background. It covers every device
13
+ * created through react-native-webgpu; an imported device is purged by its
14
+ * owner. Not part of the WebGPU spec, and does nothing on the Web.
15
+ */
16
+ export declare const purgeGpuResources: () => void;
17
+ //# sourceMappingURL=purgeGpuResources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purgeGpuResources.d.ts","sourceRoot":"","sources":["../../../src/purgeGpuResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,QAAO,IAKpC,CAAC"}
@@ -137,6 +137,18 @@ export interface GPUSharedTextureMemory {
137
137
  endAccess(texture: GPUTexture): GPUSharedTextureMemoryEndAccessState;
138
138
  destroy(): void;
139
139
  }
140
+ /**
141
+ * The options of `createNativeBufferFromPointer()`.
142
+ */
143
+ export interface CreateNativeBufferFromPointerOptions {
144
+ /**
145
+ * How to read a YUV buffer that carries no color information of its own
146
+ * (an AHardwareBuffer from a MediaCodec ImageReader, for instance), as
147
+ * `sourceColorSpace` in `importExternalTexture()`. The members it sets
148
+ * replace what the buffer says.
149
+ */
150
+ colorSpace?: NativeBufferColorSpace;
151
+ }
140
152
  /**
141
153
  * The options of `createNativeBuffer()`. The buffer holds premultiplied
142
154
  * pixels.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IAGrB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9D,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACjE,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAClC,iBAAiB,CA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AE,CAAC;CAC/B;AAQD,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAMD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,UAAU,CAAC,EAAE,oBAAoB,GAAG,UAAU,CAAC;IAM7D,WAAW,CACT,OAAO,EAAE,UAAU,EACnB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE,mBAAmB,EAAE,GAC7B,IAAI,CAAC;IAGR,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,oCAAoC,CAAC;IAMrE,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;IACrD,yDAAyD;IACzD,UAAU,CAAC,EAAE,oBAAoB,CAAC;CACnC"}
@@ -1,4 +1,4 @@
1
- import type { CreateNativeBufferOptions, CreateTestVideoPlayerOptions, NativeBuffer, VideoPlayer } from "./types";
1
+ import type { CreateNativeBufferFromPointerOptions, CreateNativeBufferOptions, CreateTestVideoPlayerOptions, NativeBuffer, VideoPlayer } from "./types";
2
2
  /**
3
3
  * Decodes a video into native frames the GPU samples without any copy.
4
4
  *
@@ -35,7 +35,7 @@ export declare const createTestVideoPlayer: (source: string, options?: CreateTes
35
35
  * VisionCamera's `frame.getNativeBuffer().pointer`) into a `NativeBuffer`
36
36
  * that keeps it alive until released.
37
37
  */
38
- export declare const createNativeBufferFromPointer: (pointer: bigint) => NativeBuffer;
38
+ export declare const createNativeBufferFromPointer: (pointer: bigint, options?: CreateNativeBufferFromPointerOptions) => NativeBuffer;
39
39
  /**
40
40
  * Allocates a native frame of the given size filled with a test pattern (a
41
41
  * red/green gradient with diagonal stripes in the blue channel), for examples
@@ -1 +1 @@
1
- {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,MAAM,EACd,UAAU,4BAA4B,KACrC,WAIA,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GAAI,SAAS,MAAM,KAAG,YAG7D,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,YACiE,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,UAAU,yBAAyB,KAClC,YACsE,CAAC"}
1
+ {"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../../src/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,MAAM,EACd,UAAU,4BAA4B,KACrC,WAIA,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,UAAU,oCAAoC,KAC7C,YAIA,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,YACiE,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,UAAU,yBAAyB,KAClC,YACsE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webgpu",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "description": "React Native WebGPU",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -201,7 +201,7 @@ copy_library() {
201
201
  # The caller holds the assembly lock across both assembly and linker staging.
202
202
  assemble_module() {
203
203
  local root="$CONTAINERS/$MODULE" library existing=true temporary previous='' old_archs platform variant ignored deployment
204
- local signature_file="$CONTAINERS/$MODULE/.slices/$SDK.signature"
204
+ local signature_file="$CONTAINERS/$MODULE/.slices/$SDK.stamp"
205
205
  CONTAINER_ROOT="$root"
206
206
  for library in "${MODULE_LIBRARIES[@]}"; do
207
207
  if [[ ! -f "$root/${library%.a}.xcframework/$META_IDENTIFIER/$library" || ! -f "$root/${library%.a}.xcframework/Info.plist" ]]; then existing=false; fi
@@ -217,6 +217,7 @@ assemble_module() {
217
217
  previous="$platform-$(printf '%s\n' "$old_archs" | LC_ALL=C sort | paste -sd _ -)${variant:+-$variant}"
218
218
  fi
219
219
  mkdir -p "$temporary/.slices"
220
+ rm -f "$temporary/.slices/$SDK.signature"
220
221
  cp "$SOURCE_DIRECTORY/metadata.json" "$temporary/.slices/$SDK.json"
221
222
  for library in "${MODULE_LIBRARIES[@]}"; do
222
223
  local container="$temporary/${library%.a}.xcframework"
@@ -225,7 +226,7 @@ assemble_module() {
225
226
  copy_library "$SOURCE_DIRECTORY/$library" "$container/$META_IDENTIFIER/$library"
226
227
  write_xcframework_plist "$container" "$library" "$temporary/.slices"
227
228
  done
228
- printf '%s\n' "$SOURCE_SIGNATURE" > "$temporary/.slices/$SDK.signature"
229
+ printf '%s\n' "$SOURCE_SIGNATURE" > "$temporary/.slices/$SDK.stamp"
229
230
  replace_directory "$temporary" "$root"
230
231
  note "Prepared $SDK XCFramework slices ($(printf '%s' "$META_ARCHS" | tr '\n' ' '))"
231
232
  }
@@ -237,10 +238,15 @@ assemble_module() {
237
238
  # rather than dynamic frameworks copied into the app's Frameworks directory.
238
239
  # Build-product stamps include SDK/version/source identity, avoiding equal-size
239
240
  # archives from another platform and unnecessary copies on incremental builds.
241
+ # Stamps must never use the .signature extension: Xcode collects *.signature
242
+ # files from build products into the archive, and App Store Connect rejects
243
+ # them as invalid XCFramework code signatures (ITMS-91063).
240
244
  stage_module() {
241
- local library destination temporary stamp="$OUTPUT/.rnwgpu-$MODULE.signature"
245
+ local library destination temporary stamp="$OUTPUT/.rnwgpu-$MODULE.stamp"
242
246
  local signature="$SDK:$VERSION:$SOURCE_SIGNATURE" name
243
247
  mkdir -p "$OUTPUT"
248
+ # Archive build folders persist across runs; drop stamps from older releases.
249
+ rm -f "$OUTPUT/.rnwgpu-$MODULE.signature"
244
250
  for library in "${MODULE_LIBRARIES[@]}"; do
245
251
  name="${library#lib}"
246
252
  destination="$OUTPUT/librnwgpu_$name"
package/src/Canvas.tsx CHANGED
@@ -12,8 +12,7 @@ export type { CanvasRef, NativeCanvas, RNCanvasContext } from "./types";
12
12
  const generateContextId = () => RNWebGPU.allocateContextId();
13
13
 
14
14
  /** The Android view a canvas draws into, see {@link AndroidCanvasProps}. */
15
- export type AndroidBackingView =
16
- "TextureView" | "SurfaceView" | "HardwareBufferView";
15
+ export type AndroidBackingView = "TextureView" | "SurfaceView";
17
16
 
18
17
  /** The options of a canvas backed by a `TextureView`, the default. */
19
18
  export interface AndroidTextureViewProps {
@@ -62,17 +61,6 @@ export interface AndroidSurfaceViewProps {
62
61
  zOrderMediaOverlay?: boolean;
63
62
  }
64
63
 
65
- /** The options of a canvas backed by a `HardwareBufferView`. */
66
- export interface AndroidHardwareBufferViewProps {
67
- /**
68
- * A plain view drawing each frame's `AHardwareBuffer` inline: composited
69
- * like a `TextureView`, without its extra copy. Opt-in and experimental,
70
- * on Android 10 and later; below that the canvas uses a `TextureView`,
71
- * with a warning in development. Always composites with alpha.
72
- */
73
- backingView: "HardwareBufferView";
74
- }
75
-
76
64
  /**
77
65
  * Android-only rendering options: the native view behind the canvas and its
78
66
  * options. The view is created when the canvas mounts and kept: a change of
@@ -81,9 +69,7 @@ export interface AndroidHardwareBufferViewProps {
81
69
  * z-order options on Android 11 and later. Ignored on iOS and web.
82
70
  */
83
71
  export type AndroidCanvasProps =
84
- | AndroidTextureViewProps
85
- | AndroidSurfaceViewProps
86
- | AndroidHardwareBufferViewProps;
72
+ AndroidTextureViewProps | AndroidSurfaceViewProps;
87
73
 
88
74
  export interface CanvasProps extends ViewProps {
89
75
  /**
@@ -128,25 +114,16 @@ const resolveBackingView = (
128
114
  android?: AndroidCanvasProps,
129
115
  ): AndroidBackingView => {
130
116
  const { backingView } = options(android);
131
- return backingView === "SurfaceView" || backingView === "HardwareBufferView"
132
- ? backingView
133
- : "TextureView";
117
+ return backingView === "SurfaceView" ? backingView : "TextureView";
134
118
  };
135
119
 
136
- // Whether the canvas composites as opaque, see BackingViewKind.resolveOpaque():
137
- // a SurfaceView is opaque unless asked otherwise, a TextureView is translucent
138
- // unless asked otherwise, and a HardwareBufferView always composites with
139
- // alpha.
120
+ // Whether the canvas composites as opaque: a SurfaceView is opaque unless
121
+ // asked otherwise, a TextureView is translucent unless asked otherwise.
140
122
  const resolveOpaque = (android?: AndroidCanvasProps): boolean => {
141
123
  const { opaque } = options(android);
142
- switch (resolveBackingView(android)) {
143
- case "SurfaceView":
144
- return opaque !== false;
145
- case "TextureView":
146
- return opaque === true;
147
- case "HardwareBufferView":
148
- return false;
149
- }
124
+ return resolveBackingView(android) === "SurfaceView"
125
+ ? opaque !== false
126
+ : opaque === true;
150
127
  };
151
128
 
152
129
  // The native props the `android` prop resolves to.
@@ -169,28 +146,13 @@ const warnIgnoredChange = (prop: string) =>
169
146
  "to change it.",
170
147
  );
171
148
 
172
- // Warns, in development on Android, about an option a mounting canvas asks
173
- // for that the native view cannot honour, and about a change of these props
174
- // that the native view ignores: the backing view is created from them when
175
- // the canvas mounts (see WebGPUView.java, whose setters these rules mirror).
176
- // The native side only says so in logcat, which is not where a JS developer
177
- // looks.
149
+ // Warns, in development on Android, about a change of these props that the
150
+ // native view ignores: the backing view is created from them when the canvas
151
+ // mounts (see WebGPUView.java, whose setters these rules mirror). The native
152
+ // side only says so in logcat, which is not where a JS developer looks.
178
153
  const useBackingViewWarning = (android?: AndroidCanvasProps) => {
179
154
  const mount = useRef(android);
180
155
  const prev = useRef(android);
181
- useEffect(() => {
182
- if (
183
- __DEV__ &&
184
- Platform.OS === "android" &&
185
- resolveBackingView(mount.current) === "HardwareBufferView" &&
186
- Number(Platform.Version) < 29
187
- ) {
188
- console.warn(
189
- "android.backingView: HardwareBufferView needs Android 10, the " +
190
- "canvas uses a TextureView.",
191
- );
192
- }
193
- }, []);
194
156
  useEffect(() => {
195
157
  if (__DEV__ && Platform.OS === "android") {
196
158
  const { current: before } = prev;
@@ -5,7 +5,7 @@ export interface NativeProps extends ViewProps {
5
5
  contextId: CodegenTypes.Int32;
6
6
  // The `android` prop, resolved (see Canvas.tsx)
7
7
  androidBackingView?: CodegenTypes.WithDefault<
8
- "TextureView" | "SurfaceView" | "HardwareBufferView",
8
+ "TextureView" | "SurfaceView",
9
9
  "TextureView"
10
10
  >;
11
11
  androidOpaque?: CodegenTypes.WithDefault<boolean, false>;
@@ -7,7 +7,7 @@ import { contextIdToId } from "./utils";
7
7
  export interface NativeProps extends ViewProps {
8
8
  contextId: CodegenTypes.Int32;
9
9
  // The `android` prop, resolved: Android-only, never reaches the DOM
10
- androidBackingView?: "TextureView" | "SurfaceView" | "HardwareBufferView";
10
+ androidBackingView?: "TextureView" | "SurfaceView";
11
11
  androidOpaque?: boolean;
12
12
  androidZOrderOnTop?: boolean;
13
13
  androidZOrderMediaOverlay?: boolean;
package/src/index.tsx CHANGED
@@ -15,6 +15,7 @@ import type {
15
15
  GPUSharedFenceDescriptor,
16
16
  GPUSharedFenceState,
17
17
  CreateNativeBufferOptions,
18
+ CreateNativeBufferFromPointerOptions,
18
19
  GPUDawnTogglesDescriptor,
19
20
  GPUNativeExternalTextureDescriptor,
20
21
  GPUSharedTextureMemory,
@@ -108,11 +109,15 @@ declare global {
108
109
  // Wrap a NativeBuffer.pointer (CVPixelBufferRef on iOS / AHardwareBuffer*
109
110
  // on Android) into a NativeBuffer. Matches the shape used by libraries
110
111
  // that emit NativeBuffer (e.g. react-native-vision-camera).
111
- createNativeBufferFromPointer: (pointer: bigint) => NativeBuffer;
112
+ createNativeBufferFromPointer: (
113
+ pointer: bigint,
114
+ options?: CreateNativeBufferFromPointerOptions,
115
+ ) => NativeBuffer;
112
116
  // Wrap an externally created WGPUDevice pointer (e.g. Skia's Graphite
113
117
  // device from Skia.getNativeDevice()) into a GPUDevice. Requires the
114
118
  // exporter to link this process's single Dawn copy.
115
119
  importDevice: (pointer: bigint) => GPUDevice;
120
+ purgeGpuResources: () => void;
116
121
  // Wrap an externally created WGPUTexture pointer into a GPUTexture,
117
122
  // taking ownership of one reference (pair with producers that return a
118
123
  // +1 pointer, e.g. Skia.Image.MakeGPUTextureFromImage()).
@@ -62,6 +62,7 @@ export * from "../WebGPUViewNativeComponent";
62
62
  export * from "../hooks";
63
63
  export * from "../GPUDeviceProvider";
64
64
  export * from "../importDevice";
65
+ export * from "../purgeGpuResources";
65
66
  export * from "../video";
66
67
  export * from "../formats";
67
68
 
@@ -6,6 +6,7 @@ export * from "../WebGPUViewNativeComponent";
6
6
  export * from "../hooks";
7
7
  export * from "../GPUDeviceProvider";
8
8
  export * from "../formats";
9
+ export * from "../purgeGpuResources";
9
10
  export * from "../video";
10
11
 
11
12
  // We don't need to set all global properties on web, webgpu is already available globally
package/src/mock.ts CHANGED
@@ -85,7 +85,6 @@ const NOT_AVAILABLE_UNDER_JEST =
85
85
  export type {
86
86
  AndroidBackingView,
87
87
  AndroidCanvasProps,
88
- AndroidHardwareBufferViewProps,
89
88
  AndroidSurfaceViewProps,
90
89
  AndroidTextureViewProps,
91
90
  CanvasProps,
@@ -147,6 +146,8 @@ export const useMainDevice = (): never => {
147
146
  throw new Error(`useMainDevice() ${NOT_AVAILABLE_UNDER_JEST}`);
148
147
  };
149
148
 
149
+ export const purgeGpuResources = () => undefined;
150
+
150
151
  export const importDevice = (_pointer: bigint): GPUDevice => {
151
152
  throw new Error(`importDevice() ${NOT_AVAILABLE_UNDER_JEST}`);
152
153
  };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns the GPU memory nothing uses to the system. Most apps should never
3
+ * call it: `destroy()` lets Dawn reuse the memory, and react-native-webgpu
4
+ * purges on its own when the system is short of memory and, on Android, each
5
+ * time the app goes to the background.
6
+ *
7
+ * It is meant for a one-off peak (a video export) followed by a long stretch
8
+ * that needs far less GPU memory. Not for a render loop, not after each
9
+ * `destroy()`, not on unmount: memory Dawn would have reused has to be
10
+ * requested from the system again. It does not free what was not destroyed.
11
+ *
12
+ * It returns right away and works in the background. It covers every device
13
+ * created through react-native-webgpu; an imported device is purged by its
14
+ * owner. Not part of the WebGPU spec, and does nothing on the Web.
15
+ */
16
+ export const purgeGpuResources = (): void => {
17
+ if (typeof RNWebGPU === "undefined") {
18
+ return;
19
+ }
20
+ RNWebGPU.purgeGpuResources();
21
+ };
package/src/types.ts CHANGED
@@ -328,6 +328,19 @@ export interface GPUSharedTextureMemory {
328
328
  destroy(): void;
329
329
  }
330
330
 
331
+ /**
332
+ * The options of `createNativeBufferFromPointer()`.
333
+ */
334
+ export interface CreateNativeBufferFromPointerOptions {
335
+ /**
336
+ * How to read a YUV buffer that carries no color information of its own
337
+ * (an AHardwareBuffer from a MediaCodec ImageReader, for instance), as
338
+ * `sourceColorSpace` in `importExternalTexture()`. The members it sets
339
+ * replace what the buffer says.
340
+ */
341
+ colorSpace?: NativeBufferColorSpace;
342
+ }
343
+
331
344
  /**
332
345
  * The options of `createNativeBuffer()`. The buffer holds premultiplied
333
346
  * pixels.
package/src/video.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ CreateNativeBufferFromPointerOptions,
2
3
  CreateNativeBufferOptions,
3
4
  CreateTestVideoPlayerOptions,
4
5
  NativeBuffer,
@@ -58,9 +59,13 @@ export const createTestVideoPlayer = (
58
59
  * VisionCamera's `frame.getNativeBuffer().pointer`) into a `NativeBuffer`
59
60
  * that keeps it alive until released.
60
61
  */
61
- export const createNativeBufferFromPointer = (pointer: bigint): NativeBuffer =>
62
+ export const createNativeBufferFromPointer = (
63
+ pointer: bigint,
64
+ options?: CreateNativeBufferFromPointerOptions,
65
+ ): NativeBuffer =>
62
66
  native("createNativeBufferFromPointer").createNativeBufferFromPointer(
63
67
  pointer,
68
+ options,
64
69
  );
65
70
 
66
71
  /**