Skip to content

Commit d6113df

Browse files
authored
fix(⬆️): upgrade to chromium 7770 (#342)
1 parent f1ca282 commit d6113df

11 files changed

Lines changed: 57 additions & 80 deletions

File tree

packages/webgpu/android/cpp/AndroidPlatformContext.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ class AndroidPlatformContext : public PlatformContext {
9393
return createImageBitmapFromData(data);
9494
}
9595

96-
void createImageBitmapAsync(
97-
std::string blobId, double offset, double size,
98-
std::function<void(ImageData)> onSuccess,
99-
std::function<void(std::string)> onError) override {
96+
void
97+
createImageBitmapAsync(std::string blobId, double offset, double size,
98+
std::function<void(ImageData)> onSuccess,
99+
std::function<void(std::string)> onError) override {
100100
std::thread([this, blobId = std::move(blobId), offset, size,
101101
onSuccess = std::move(onSuccess),
102102
onError = std::move(onError)]() {
@@ -189,7 +189,8 @@ class AndroidPlatformContext : public PlatformContext {
189189
void createImageBitmapFromDataAsync(
190190
std::span<const uint8_t> data, std::function<void(ImageData)> onSuccess,
191191
std::function<void(std::string)> onError) override {
192-
std::thread([this, ownedData = std::vector<uint8_t>(data.begin(), data.end()),
192+
std::thread([this,
193+
ownedData = std::vector<uint8_t>(data.begin(), data.end()),
193194
onSuccess = std::move(onSuccess),
194195
onError = std::move(onError)]() mutable {
195196
jni::Environment::ensureCurrentThreadIsAttached();

packages/webgpu/apple/ApplePlatformContext.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class ApplePlatformContext : public PlatformContext {
1616
ImageData createImageBitmap(std::string blobId, double offset,
1717
double size) override;
1818

19-
void createImageBitmapAsync(
20-
std::string blobId, double offset, double size,
21-
std::function<void(ImageData)> onSuccess,
22-
std::function<void(std::string)> onError) override;
19+
void
20+
createImageBitmapAsync(std::string blobId, double offset, double size,
21+
std::function<void(ImageData)> onSuccess,
22+
std::function<void(std::string)> onError) override;
2323

2424
ImageData createImageBitmapFromData(std::span<const uint8_t> data) override;
2525

packages/webgpu/apple/ApplePlatformContext.mm

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,18 @@ void checkIfUsingSimulatorWithAPIValidation() {
8282
std::move(onError));
8383
}
8484

85-
ImageData ApplePlatformContext::createImageBitmapFromData(
86-
std::span<const uint8_t> data) {
85+
ImageData
86+
ApplePlatformContext::createImageBitmapFromData(std::span<const uint8_t> data) {
8787
// This avoids a copy by assuming the UIImage/NSImage constructors
8888
// decode `nsData` eagerly before the memory for the wrapped `data`
8989
// is freed.
9090
//
9191
// Since we get the `CGImageRef` from `image` and then throw
9292
// it away, that's a fairly safe assumption.
93-
NSData *nsData = [NSData dataWithBytesNoCopy:const_cast<uint8_t *>(data.data())
94-
length:data.size()
95-
freeWhenDone:NO];
93+
NSData *nsData =
94+
[NSData dataWithBytesNoCopy:const_cast<uint8_t *>(data.data())
95+
length:data.size()
96+
freeWhenDone:NO];
9697

9798
#if !TARGET_OS_OSX
9899
UIImage *image = [UIImage imageWithData:nsData];
@@ -141,17 +142,16 @@ void checkIfUsingSimulatorWithAPIValidation() {
141142
auto ownedData =
142143
std::make_shared<std::vector<uint8_t>>(data.begin(), data.end());
143144

144-
dispatch_async(
145-
dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
146-
@autoreleasepool {
147-
try {
148-
auto result = createImageBitmapFromData(*ownedData);
149-
onSuccess(std::move(result));
150-
} catch (const std::exception &e) {
151-
onError(e.what());
152-
}
153-
}
154-
});
145+
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
146+
@autoreleasepool {
147+
try {
148+
auto result = createImageBitmapFromData(*ownedData);
149+
onSuccess(std::move(result));
150+
} catch (const std::exception &e) {
151+
onError(e.what());
152+
}
153+
}
154+
});
155155
}
156156

157157
} // namespace rnwgpu

packages/webgpu/apple/WebGPUModule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#import <React/RCTCallInvokerModule.h>
66
#import <React/RCTEventEmitter.h>
77

8-
@interface WebGPUModule : RCTEventEmitter <NativeWebGPUModuleSpec, RCTCallInvokerModule>
8+
@interface WebGPUModule
9+
: RCTEventEmitter <NativeWebGPUModuleSpec, RCTCallInvokerModule>
910

1011
+ (std::shared_ptr<rnwgpu::RNWebGPUManager>)getManager;
1112

packages/webgpu/apple/WebGPUModule.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ - (void)invalidate {
5555
return @true;
5656
}
5757

58-
// self.bridge works in both Legacy (RCTBridge) and Bridgeless (RCTBridgeProxy).
58+
// self.bridge works in both Legacy (RCTBridge) and Bridgeless
59+
// (RCTBridgeProxy).
5960
jsi::Runtime *runtime = (jsi::Runtime *)self.bridge.runtime;
6061
if (!runtime) {
6162
NSLog(@"Failed to install react-native-wgpu: jsi::Runtime* was null! "
62-
@"(self.bridge=%@)", self.bridge);
63+
@"(self.bridge=%@)",
64+
self.bridge);
6365
return [NSNumber numberWithBool:NO];
6466
}
6567

packages/webgpu/cpp/rnwgpu/PlatformContext.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ class PlatformContext {
2828
double size) = 0;
2929

3030
// Async version that performs image decoding on a background thread
31-
virtual void createImageBitmapAsync(
32-
std::string blobId, double offset, double size,
33-
std::function<void(ImageData)> onSuccess,
34-
std::function<void(std::string)> onError) = 0;
31+
virtual void
32+
createImageBitmapAsync(std::string blobId, double offset, double size,
33+
std::function<void(ImageData)> onSuccess,
34+
std::function<void(std::string)> onError) = 0;
3535

3636
// Create ImageBitmap from raw encoded image bytes (PNG/JPEG/etc.)
37-
virtual ImageData createImageBitmapFromData(std::span<const uint8_t> data) = 0;
37+
virtual ImageData
38+
createImageBitmapFromData(std::span<const uint8_t> data) = 0;
3839

39-
virtual void createImageBitmapFromDataAsync(
40-
std::span<const uint8_t> data, std::function<void(ImageData)> onSuccess,
41-
std::function<void(std::string)> onError) = 0;
40+
virtual void
41+
createImageBitmapFromDataAsync(std::span<const uint8_t> data,
42+
std::function<void(ImageData)> onSuccess,
43+
std::function<void(std::string)> onError) = 0;
4244
};
4345

4446
} // namespace rnwgpu

packages/webgpu/cpp/rnwgpu/api/GPUFeatures.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include <string>
44

5-
#include "webgpu/webgpu_cpp.h"
5+
#include <cstdio>
66

7-
#include "WGPULogger.h"
7+
#include "webgpu/webgpu_cpp.h"
88

99
namespace rnwgpu {
1010

@@ -89,9 +89,6 @@ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
8989
case wgpu::FeatureName::Unorm16TextureFormats:
9090
*outUnion = "unorm16-texture-formats";
9191
break;
92-
case wgpu::FeatureName::Snorm16TextureFormats:
93-
*outUnion = "snorm16-texture-formats";
94-
break;
9592
case wgpu::FeatureName::MultiPlanarFormatExtendedUsages:
9693
*outUnion = "multi-planar-format-extended-usages";
9794
break;
@@ -122,18 +119,12 @@ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
122119
case wgpu::FeatureName::AdapterPropertiesVk:
123120
*outUnion = "adapter-properties-vk";
124121
break;
125-
case wgpu::FeatureName::R8UnormStorage:
126-
*outUnion = "r8unorm-storage";
127-
break;
128122
case wgpu::FeatureName::DawnFormatCapabilities:
129123
*outUnion = "format-capabilities";
130124
break;
131125
case wgpu::FeatureName::DawnDrmFormatCapabilities:
132126
*outUnion = "drm-format-capabilities";
133127
break;
134-
case wgpu::FeatureName::Norm16TextureFormats:
135-
*outUnion = "norm16-texture-formats";
136-
break;
137128
case wgpu::FeatureName::MultiPlanarFormatNv16:
138129
*outUnion = "multi-planar-format-nv16";
139130
break;
@@ -204,7 +195,7 @@ static void convertEnumToJSUnion(wgpu::FeatureName inEnum,
204195
*outUnion = "dawn-load-resolve-texture";
205196
break;
206197
default:
207-
Logger::logToConsole("Unknown feature name %d", inEnum);
198+
fprintf(stderr, "Unknown feature name %d\n", static_cast<int>(inEnum));
208199
*outUnion = "";
209200
}
210201
}

packages/webgpu/cpp/rnwgpu/api/RNWebGPU.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ class RNWebGPU : public NativeObject<RNWebGPU> {
103103
auto bufferVal = obj.getProperty(runtime, "buffer");
104104
if (bufferVal.isObject() &&
105105
bufferVal.getObject(runtime).isArrayBuffer(runtime)) {
106-
const auto &ab =
107-
bufferVal.getObject(runtime).getArrayBuffer(runtime);
106+
const auto &ab = bufferVal.getObject(runtime).getArrayBuffer(runtime);
108107
auto byteOffset = static_cast<size_t>(
109108
obj.getProperty(runtime, "byteOffset").asNumber());
110109
auto byteLength = static_cast<size_t>(
@@ -120,15 +119,13 @@ class RNWebGPU : public NativeObject<RNWebGPU> {
120119

121120
return Promise::createPromise(
122121
runtime,
123-
[platformContext, callInvoker,
124-
dataCopy = std::move(dataCopy)](
122+
[platformContext, callInvoker, dataCopy = std::move(dataCopy)](
125123
jsi::Runtime & /*runtime*/,
126124
std::shared_ptr<Promise> promise) mutable {
127125
platformContext->createImageBitmapFromDataAsync(
128126
dataCopy,
129127
[callInvoker, promise](ImageData imageData) {
130-
auto imageBitmap =
131-
std::make_shared<ImageBitmap>(imageData);
128+
auto imageBitmap = std::make_shared<ImageBitmap>(imageData);
132129
callInvoker->invokeAsync([promise, imageBitmap]() {
133130
promise->resolve(
134131
JSIConverter<std::shared_ptr<ImageBitmap>>::toJSI(
@@ -158,12 +155,11 @@ class RNWebGPU : public NativeObject<RNWebGPU> {
158155
blobId, offset, size,
159156
[callInvoker, promise](ImageData imageData) {
160157
auto imageBitmap = std::make_shared<ImageBitmap>(imageData);
161-
callInvoker->invokeAsync(
162-
[promise, imageBitmap]() {
163-
promise->resolve(
164-
JSIConverter<std::shared_ptr<ImageBitmap>>::toJSI(
165-
promise->runtime, imageBitmap));
166-
});
158+
callInvoker->invokeAsync([promise, imageBitmap]() {
159+
promise->resolve(
160+
JSIConverter<std::shared_ptr<ImageBitmap>>::toJSI(
161+
promise->runtime, imageBitmap));
162+
});
167163
},
168164
[callInvoker, promise](std::string error) {
169165
callInvoker->invokeAsync(

packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,6 @@ inline void convertJSUnionToEnum(const std::string &inUnion,
463463
*outEnum = wgpu::FeatureName::PixelLocalStorageNonCoherent;
464464
} else if (inUnion == "unorm16-texture-formats") {
465465
*outEnum = wgpu::FeatureName::Unorm16TextureFormats;
466-
} else if (inUnion == "snorm16-texture-formats") {
467-
*outEnum = wgpu::FeatureName::Snorm16TextureFormats;
468466
} else if (inUnion == "multi-planar-format-extended-usages") {
469467
*outEnum = wgpu::FeatureName::MultiPlanarFormatExtendedUsages;
470468
} else if (inUnion == "multi-planar-format-p010") {
@@ -485,12 +483,8 @@ inline void convertJSUnionToEnum(const std::string &inUnion,
485483
*outEnum = wgpu::FeatureName::AdapterPropertiesD3D;
486484
} else if (inUnion == "adapter-properties-vk") {
487485
*outEnum = wgpu::FeatureName::AdapterPropertiesVk;
488-
} else if (inUnion == "r8unorm-storage") {
489-
*outEnum = wgpu::FeatureName::R8UnormStorage;
490486
} else if (inUnion == "format-capabilities") {
491487
*outEnum = wgpu::FeatureName::DawnFormatCapabilities;
492-
} else if (inUnion == "norm16-texture-formats") {
493-
*outEnum = wgpu::FeatureName::Norm16TextureFormats;
494488
} else if (inUnion == "multi-planar-format-nv16") {
495489
*outEnum = wgpu::FeatureName::MultiPlanarFormatNv16;
496490
} else if (inUnion == "multi-planar-format-nv24") {
@@ -629,9 +623,6 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum,
629623
case wgpu::FeatureName::Unorm16TextureFormats:
630624
*outUnion = "unorm16-texture-formats";
631625
break;
632-
case wgpu::FeatureName::Snorm16TextureFormats:
633-
*outUnion = "snorm16-texture-formats";
634-
break;
635626
case wgpu::FeatureName::MultiPlanarFormatExtendedUsages:
636627
*outUnion = "multi-planar-format-extended-usages";
637628
break;
@@ -662,12 +653,6 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum,
662653
case wgpu::FeatureName::AdapterPropertiesVk:
663654
*outUnion = "adapter-properties-vk";
664655
break;
665-
case wgpu::FeatureName::R8UnormStorage:
666-
*outUnion = "r8unorm-storage";
667-
break;
668-
case wgpu::FeatureName::Norm16TextureFormats:
669-
*outUnion = "norm16-texture-formats";
670-
break;
671656
case wgpu::FeatureName::MultiPlanarFormatNv16:
672657
*outUnion = "multi-planar-format-nv16";
673658
break;

packages/webgpu/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-wgpu",
3-
"version": "0.5.10",
3+
"version": "0.5.11",
44
"description": "React Native WebGPU",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
@@ -20,7 +20,7 @@
2020
"libs/**",
2121
"*.podspec"
2222
],
23-
"dawn": "chromium/7472",
23+
"dawn": "chromium/7770",
2424
"scripts": {
2525
"test": "NODE_OPTIONS='--experimental-require-module' jest -i",
2626
"test:ref": "REFERENCE=true NODE_OPTIONS='--experimental-require-module' jest -i",

0 commit comments

Comments
 (0)