From ec0d956510e3aa3227876506657a6756d4c903ec Mon Sep 17 00:00:00 2001 From: Sebastien Hecart <7248073+batical@users.noreply.github.com> Date: Mon, 9 Nov 2026 09:52:52 +0100 Subject: [PATCH] Update dependencies to Skia 3.9.2 and WebGPU 0.21.2; enhance documentation and patch files --- README.md | 10 +- android/BUILD_VALIDATION.md | 2 +- docs/UPSTREAM_NOTES.md | 12 ++- example/ios/Podfile.lock | 8 +- example/package.json | 4 +- package-lock.json | 16 +-- package.json | 10 +- patches/react-native-skia+3.9.2.patch | 150 ++++++++++++++++++++++++++ scripts/skia-canvas-patch.json | 8 +- 9 files changed, 190 insertions(+), 30 deletions(-) create mode 100644 patches/react-native-skia+3.9.2.patch diff --git a/README.md b/README.md index d0e9c96..f264e78 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ CI npm Status: stable - React Native Skia 3.9.1 - React Native WebGPU 0.21.0 + React Native Skia 3.9.2 + React Native WebGPU 0.21.2 MIT license

@@ -37,8 +37,8 @@ A new Skia 3 / WebGPU frame-interop layer, written from scratch with explicit re | --- | --- | | React Native | `0.86.2` tested; declared peer range `>=0.83 <0.87` | | React | `19.2.3` tested | -| React Native Skia | **`react-native-skia@3.9.1`** | -| React Native WebGPU | **`react-native-webgpu@0.21.0`** (both resolve `react-native-webgpu-dawn@157.1.0`) | +| React Native Skia | **`react-native-skia@3.9.2`** | +| React Native WebGPU | **`react-native-webgpu@0.21.2`** (both resolve `react-native-webgpu-dawn@157.1.0`) | | Reanimated / Worklets | **`4.5.3` / `0.11.3`** | | Native runtime | New Architecture and Hermes | | Android | API **28+**, Vulkan 1.1 (declared as a required feature by Skia) | @@ -50,7 +50,7 @@ On ProMotion iPhones, add `CADisableMinimumFrameDurationOnPhone` (Boolean, `YES` ### Install ```sh -npm install --save-exact react-native-skia@3.9.1 react-native-webgpu@0.21.0 react-native-reanimated@4.5.3 react-native-worklets@0.11.3 +npm install --save-exact react-native-skia@3.9.2 react-native-webgpu@0.21.2 react-native-reanimated@4.5.3 react-native-worklets@0.11.3 npm install --save-exact react-native-skia-webgpu-video ``` diff --git a/android/BUILD_VALIDATION.md b/android/BUILD_VALIDATION.md index 01f4eda..d08a80c 100644 --- a/android/BUILD_VALIDATION.md +++ b/android/BUILD_VALIDATION.md @@ -1,6 +1,6 @@ # Android validation and frame ownership -The Android example in `../example/android` pins React Native 0.86.2, Skia 3.9.1, WebGPU 0.21.0, the shared `react-native-webgpu-dawn` 157.1.0 (chrome-m157) and Graphite Android 157.1.0; Gradle needs `node` to resolve that Dawn package. Since WebGPU 0.19.0, export renders straight into the codec's input Surface through a WebGPU canvas context on it (`MakeWebGPUCanvasContextFromNativeWindow`, Vulkan swapchain), with no EGL; CPU readback, drawn into the Surface by EGL, stays the fallback. On API 29+, 8-bit SDR H.264/HEVC clips go through an `ImageReader`, whose YUV buffers WebGPU converts, crops, rotates and scales to the frame's size (capped or explicit sizes included since the 3.7.4 migration); since 3.6.1 each buffer is imported once, and exports sample the converted frame in place. The 3.7.0 build was assembled and run on a Pixel 8a on 2026-10-19 ([verification](../migration/skia-3.7.0/verification.md)), after the 3.6.1 build of 2026-10-16 ([verification](../migration/skia-3.6.1/verification.md)) and the 3.4.4 build of 2026-10-14/15 ([verification](../migration/skia-3.4.4/verification.md)); the evidence below is from Skia 3.0.6 / WebGPU 0.12.1 / Graphite 154.1.0. It uses Java 17, Gradle 9.3.1, Android SDK 36 and NDK 27.1.12297006. The library requires API 28; a consuming application with a lower minimum receives an explicit Gradle configuration error. The default example ABI is arm64-v8a; `RNSKV_ANDROID_ABI` selects another ABI for the validation script. +The Android example in `../example/android` pins React Native 0.86.2, Skia 3.9.2, WebGPU 0.21.2, the shared `react-native-webgpu-dawn` 157.1.0 (chrome-m157) and Graphite Android 157.1.0; Gradle needs `node` to resolve that Dawn package. Since WebGPU 0.19.0, export renders straight into the codec's input Surface through a WebGPU canvas context on it (`MakeWebGPUCanvasContextFromNativeWindow`, Vulkan swapchain), with no EGL; CPU readback, drawn into the Surface by EGL, stays the fallback. On API 29+, 8-bit SDR H.264/HEVC clips go through an `ImageReader`, whose YUV buffers WebGPU converts, crops, rotates and scales to the frame's size (capped or explicit sizes included since the 3.7.4 migration); since 3.6.1 each buffer is imported once, and exports sample the converted frame in place. The 3.7.0 build was assembled and run on a Pixel 8a on 2026-10-19 ([verification](../migration/skia-3.7.0/verification.md)), after the 3.6.1 build of 2026-10-16 ([verification](../migration/skia-3.6.1/verification.md)) and the 3.4.4 build of 2026-10-14/15 ([verification](../migration/skia-3.4.4/verification.md)); the evidence below is from Skia 3.0.6 / WebGPU 0.12.1 / Graphite 154.1.0. It uses Java 17, Gradle 9.3.1, Android SDK 36 and NDK 27.1.12297006. The library requires API 28; a consuming application with a lower minimum receives an explicit Gradle configuration error. The default example ABI is arm64-v8a; `RNSKV_ANDROID_ABI` selects another ABI for the validation script. Run `android/scripts/validate.sh build` from the repository. It assembles the example Debug and unsigned Release APKs, library AAR, standalone instrumentation APK and JVM tests. Release uses the installed `hermes-compiler` package, and both native and Metro build concurrency are bounded to two workers. The Release APK is unsigned: device installation requires signing a separate local qualification artifact. The project supplies no publishing or release signing configuration. diff --git a/docs/UPSTREAM_NOTES.md b/docs/UPSTREAM_NOTES.md index 3802d8f..d27e0a0 100644 --- a/docs/UPSTREAM_NOTES.md +++ b/docs/UPSTREAM_NOTES.md @@ -1,5 +1,15 @@ # Points amont à revoir lors d'une mise à jour Skia +**Mise à jour du 9 novembre 2026 :** **`react-native-skia@3.9.2`** et **`react-native-webgpu@0.21.2`**, toujours sur Dawn/Graphite **157.1.0**. Le `main` amont du jour (`cf9240bd6`) ne diffère de la v3.9.2 que par un banc de performance de l'exemple et de la CI ([#4385](https://github.com/wcandillon/react-native-skia/pull/4385)) : le paquet publié est le même. +- **Patch :** `JsiSkSurface.h` et `JsiSkApi.h` sont identiques octet pour octet à ceux de la 3.9.1. `RNDawnContext.h` change, mais les 8 éditions s'y appliquent telles quelles. +- **Une ligne ajoutée au patch :** `submitRecordingChecked` marque son snap et son exécution comme travail GPU (`RNSkGpuActivity::Scope`), comme le fait désormais `submitRecording` en amont. + - La 3.9.2 compile en tâche de fond les pipelines courants et ceux du lancement précédent (`RNSkPipelineWarmup`, [#4398](https://github.com/wcandillon/react-native-skia/pull/4398)). + - Ce warmup ne compile que si aucun travail GPU n'est marqué, car chaque compilation tient le verrou du device Dawn. + - Sans le marquage, nos soumissions vérifiées (l'export) passeraient pour un device au repos. +- **Autres changements amont :** cadence des vues refaite ([#4398](https://github.com/wcandillon/react-native-skia/pull/4398)), le thread principal Android n'attend plus le thread de présentation ([#4395](https://github.com/wcandillon/react-native-skia/pull/4395)), `MakeGPUTextureFromImage` n'attend plus le CPU ([#4401](https://github.com/wcandillon/react-native-skia/pull/4401), non utilisé ici). +- **WebGPU 0.21.1 et 0.21.2 :** un `null` dans une liste d'emplacements garde son index ([#617](https://github.com/wcandillon/react-native-webgpu/pull/617)), `device.queue` rend toujours le même objet ([#614](https://github.com/wcandillon/react-native-webgpu/pull/614)), pod compatible `use_frameworks!` ([#612](https://github.com/wcandillon/react-native-webgpu/pull/612)). +- [#4276](https://github.com/wcandillon/react-native-skia/pull/4276) est toujours ouverte : le patch ne rétrécit pas. + **Mise à jour du 4 novembre 2026 :** **`react-native-skia@3.9.1`** et **`react-native-webgpu@0.21.0`**, sur Dawn/Graphite **157.1.0** ; les deux paquets montent ensemble. - **Patch :** `RNDawnContext.h` et `JsiSkApi.h` changent en amont, mais les 8 éditions s'appliquent telles quelles ; seuls les empreintes et les décalages changent. - **Readbacks asynchrones (3.9.0, [#4368](https://github.com/wcandillon/react-native-skia/pull/4368)) :** `canvas.readPixels` renvoie une promesse et ne prend plus de tableau de destination. Le readback CPU de secours de l'export attend donc la lecture avant d'encoder. @@ -129,7 +139,7 @@ La [source Skia de ce build](https://chromium.googlesource.com/skia/+/2466dcf393 Fichiers inspectables : -- [`patches/react-native-skia+3.8.1.patch`](../patches/react-native-skia+3.8.1.patch) : diff du correctif courant ; ceux des versions précédentes sont conservés comme historique. +- [`patches/react-native-skia+3.9.2.patch`](../patches/react-native-skia+3.9.2.patch) : diff du correctif courant ; ceux des versions précédentes sont conservés comme historique. - [`scripts/skia-canvas-patch.json`](../scripts/skia-canvas-patch.json) : version, empreintes avant/après et substitutions attendues. - [`scripts/apply-skia-canvas-patch.mjs`](../scripts/apply-skia-canvas-patch.mjs) : vérifie tout avant toute écriture, accepte un patch déjà appliqué, refuse un paquet différent. diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 48ef0c0..dcdca99 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1426,7 +1426,7 @@ PODS: - ReactCommon/turbomodule/core - ReactNativeDependencies - Yoga - - react-native-skia (3.9.1): + - react-native-skia (3.9.2): - hermes-engine - RCTRequired - RCTTypeSafety @@ -1473,7 +1473,7 @@ PODS: - ReactCommon/turbomodule/core - ReactNativeDependencies - Yoga - - react-native-webgpu (0.21.0): + - react-native-webgpu (0.21.2): - hermes-engine - RCTRequired - RCTTypeSafety @@ -2350,9 +2350,9 @@ SPEC CHECKSUMS: React-Mapbuffer: 44dd007f917e2396afa0e70bbd70273237d93fde React-microtasksnativemodule: f413ee411341fb3c34d20e85e9f6f524921fab15 React-mutationobservernativemodule: 58f6d2adf7d98e72b241608dfa2ddce414d2a4e7 - react-native-skia: bafae4183d4bbaf0dc433a6b48d59dc0dcbfde81 + react-native-skia: 664894286ccbf0d0f9727c2f132499dbd4122792 react-native-skia-webgpu-video: 3dfd41b1018b347ade67c12d48b787b3ae4fc819 - react-native-webgpu: c764ad1fab604bd41260f78844bbd16d167b0b6c + react-native-webgpu: d56183ba5d1b525477d49add6a8d43cd6b146bed React-NativeModulesApple: 167e532fb9bae30f3c66636b8ee0092bab263667 React-networking: 89f6b69755a3176f30e56ba1ba8e214b1518ecfb React-oscompat: db6675ddaef3bddd1b41533627f3d26ec710c05f diff --git a/example/package.json b/example/package.json index 447d5ab..3ddef20 100644 --- a/example/package.json +++ b/example/package.json @@ -9,8 +9,8 @@ "dependencies": { "react": "19.2.3", "react-native": "0.86.2", - "react-native-skia": "3.9.1", - "react-native-webgpu": "0.21.0", + "react-native-skia": "3.9.2", + "react-native-webgpu": "0.21.2", "react-native-reanimated": "4.5.3", "react-native-worklets": "0.11.3", "react-native-skia-webgpu-video": "file:.." diff --git a/package-lock.json b/package-lock.json index 93ecac3..54013a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,8 +32,8 @@ "react-native": "0.86.2", "react-native-builder-bob": "^0.43.0", "react-native-reanimated": "4.5.3", - "react-native-skia": "3.9.1", - "react-native-webgpu": "0.21.0", + "react-native-skia": "3.9.2", + "react-native-webgpu": "0.21.2", "react-native-worklets": "0.11.3", "react-test-renderer": "19.2.3", "typescript": "^6.0.3" @@ -8751,9 +8751,9 @@ } }, "node_modules/react-native-skia": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/react-native-skia/-/react-native-skia-3.9.1.tgz", - "integrity": "sha512-kVJZ5BEyjfsN5HmGkiO90PjbpD/Smghkcd/fn4yqK/hO8jjkTtKjLorn+Kv77/gI1mu73EUaafIWstRSSpaI2g==", + "version": "3.9.2", + "resolved": "https://registry.npmjs.org/react-native-skia/-/react-native-skia-3.9.2.tgz", + "integrity": "sha512-MeCsOD9g8B+b935sQLu3QtYYsOCyzqxJcSkhlFQu6xEXJ7nmbKqIB5t8/Jzf/cqDOP706cYKCGekBUlhbHaYNw==", "dev": true, "license": "MIT", "dependencies": { @@ -8815,9 +8815,9 @@ "license": "MIT" }, "node_modules/react-native-webgpu": { - "version": "0.21.0", - "resolved": "https://registry.npmjs.org/react-native-webgpu/-/react-native-webgpu-0.21.0.tgz", - "integrity": "sha512-7UfVyIWTmf1EIyxfzX4wocpf7RWpHb7UL3IRFxoFpPn9375kbcwPjS2e8gUe7LNvCDCkOFgVVhbyLr+MZlFS5g==", + "version": "0.21.2", + "resolved": "https://registry.npmjs.org/react-native-webgpu/-/react-native-webgpu-0.21.2.tgz", + "integrity": "sha512-9RLfytphFeNVjg0/bdnzcGrjHSPS9YkH30ciRUGcH5GrHPv/EHWt4JSIDxtGB+DyTC5TDfkCmwXPJPrmUZGolw==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 8d98d13..01b6584 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "!**/.*", "scripts/apply-skia-canvas-patch.mjs", "scripts/skia-canvas-patch.json", - "patches/react-native-skia+3.9.1.patch", + "patches/react-native-skia+3.9.2.patch", "docs/UPSTREAM_NOTES.md", "!ios/tests", "!android/src/androidTest", @@ -101,8 +101,8 @@ "react-native": "0.86.2", "react-native-builder-bob": "^0.43.0", "react-native-reanimated": "4.5.3", - "react-native-skia": "3.9.1", - "react-native-webgpu": "0.21.0", + "react-native-skia": "3.9.2", + "react-native-webgpu": "0.21.2", "react-native-worklets": "0.11.3", "react-test-renderer": "19.2.3", "typescript": "^6.0.3" @@ -111,8 +111,8 @@ "react": ">=19", "react-native": ">=0.83 <0.87", "react-native-reanimated": "4.5.3", - "react-native-skia": "3.9.1", - "react-native-webgpu": "0.21.0", + "react-native-skia": "3.9.2", + "react-native-webgpu": "0.21.2", "react-native-worklets": "0.11.3" }, "jest": { diff --git a/patches/react-native-skia+3.9.2.patch b/patches/react-native-skia+3.9.2.patch new file mode 100644 index 0000000..46e935c --- /dev/null +++ b/patches/react-native-skia+3.9.2.patch @@ -0,0 +1,150 @@ +--- a/node_modules/react-native-skia/cpp/rnskia/RNDawnContext.h ++++ b/node_modules/react-native-skia/cpp/rnskia/RNDawnContext.h +@@ -492,6 +492,44 @@ + } + current->context->submit(syncToCpu); + return inserted; ++ } ++ ++ // Checked only for surfaces that explicitly opt into this contract: like ++ // submitRecording, but a recording that would not run throws instead of ++ // being dropped. A valid empty Recording is accepted; Recorder::snap() ++ // returns nullptr on failure. ++ void submitRecordingChecked( ++ skgpu::graphite::Recorder *recorder, ++ skgpu::graphite::SyncToCpu syncToCpu = skgpu::graphite::SyncToCpu::kNo) { ++ if (recorder == nullptr) { ++ throw std::runtime_error( ++ "Checked GPU submissions require a Graphite recorder"); ++ } ++ // As in submitRecording: the snap compiles the pipelines the recording ++ // needs, inline, GPU work the pipeline warmup stays behind (see ++ // RNSkGpuActivity), as is the run. ++ RNSkGpuActivity::Scope activity; ++ auto recording = recorder->snap(); ++ if (recording == nullptr) { ++ throw std::runtime_error("Cannot create checked Graphite recording"); ++ } ++ std::lock_guard lock(_mutex); ++ auto *current = _current.load(std::memory_order_acquire); ++ if (generationOf(recorder) != current->id || ++ current->lost.load(std::memory_order_acquire)) { ++ throw std::runtime_error( ++ "The GPU device was lost; a checked recording cannot run"); ++ } ++ skgpu::graphite::InsertRecordingInfo info; ++ info.fRecording = recording.get(); ++ auto status = current->context->insertRecording(info); ++ if (!static_cast(status)) { ++ throw std::runtime_error("Graphite rejected a checked recording: " + ++ status.message()); ++ } ++ if (!current->context->submit(syncToCpu)) { ++ throw std::runtime_error("Graphite checked submission failed"); ++ } + } + + /** +--- a/node_modules/react-native-skia/cpp/api/JsiSkSurface.h ++++ b/node_modules/react-native-skia/cpp/api/JsiSkSurface.h +@@ -52,6 +52,26 @@ + } + } + ++ // Opt-in for consumers that release native buffers after GPU completion. ++ // Other Skia surfaces preserve their existing flush/snapshot behavior. ++ void enableCheckedSubmissions() { ++ if (!getObject()->recorder()) { ++ throw std::runtime_error( ++ "Checked GPU submissions require a Graphite surface"); ++ } ++ _checkedSubmissions = true; ++ } ++ ++ void submitRecording(skgpu::graphite::Recorder *recorder, ++ skgpu::graphite::SyncToCpu syncToCpu = ++ skgpu::graphite::SyncToCpu::kNo) { ++ if (_checkedSubmissions) { ++ DawnContext::getInstance().submitRecordingChecked(recorder, syncToCpu); ++ } else { ++ DawnContext::getInstance().submitRecording(recorder, syncToCpu); ++ } ++ } ++ + // TODO-API: Properties? + double width() { return static_cast(getObject()->width()); } + double height() { return static_cast(getObject()->height()); } +@@ -85,9 +105,8 @@ + // only Graphite-backed surfaces need to snap and submit a recording. One + // made on a GPU device lost since submits nothing (see DawnContext). + if (auto *recorder = surface->recorder()) { +- DawnContext::getInstance().submitRecording( +- recorder, sync ? skgpu::graphite::SyncToCpu::kYes +- : skgpu::graphite::SyncToCpu::kNo); ++ submitRecording(recorder, sync ? skgpu::graphite::SyncToCpu::kYes ++ : skgpu::graphite::SyncToCpu::kNo); + } + } + +@@ -120,10 +139,15 @@ + } else { + image = surface->makeImageSnapshot(); + } ++ // A checked surface keeps the previously published image if snapshot ++ // allocation failed. ++ if (!image && _checkedSubmissions) { ++ throw jsi::JSError(runtime, "Cannot allocate Skia surface snapshot"); ++ } + // A raster surface (e.g. Skia.Surface.Make) has no Graphite recorder; its + // snapshot is already a valid CPU image, so skip the recording submit. + if (auto *recorder = surface->recorder()) { +- DawnContext::getInstance().submitRecording(recorder); ++ submitRecording(recorder); + } + if (count > 1 && arguments[1].isObject()) { + auto jsiImage = getJsiObject(runtime, arguments[1]); +@@ -196,6 +220,8 @@ + &JsiSkSurface::makeImageSnapshot); + installMethod(runtime, prototype, "asImage", &JsiSkSurface::asImage); + installMethod(runtime, prototype, "flush", &JsiSkSurface::flush); ++ installMethod(runtime, prototype, "enableCheckedSubmissions", ++ &JsiSkSurface::enableCheckedSubmissions); + } + + protected: +@@ -222,6 +248,7 @@ + + std::shared_ptr _dispatcher; + std::shared_ptr _canvas; ++ bool _checkedSubmissions = false; + }; + + } // namespace RNSkia +--- a/node_modules/react-native-skia/cpp/api/JsiSkApi.h ++++ b/node_modules/react-native-skia/cpp/api/JsiSkApi.h +@@ -162,6 +162,16 @@ + } + JSI_HOST_FUNCTION(Color) { + return JsiSkColor::createCtor()(runtime, thisValue, arguments, count); ++ } ++ // Private video-export cleanup. Only the calling thread's recorders are ++ // trimmed; the shared Context cache and other threads' recorders are ++ // untouched. ++ JSI_HOST_FUNCTION(__rnskvTrimRecorderCache) { ++ auto &context = DawnContext::getInstance(); ++ context.submitRecordingChecked(context.getRecorder(), ++ skgpu::graphite::SyncToCpu::kYes); ++ DawnContext::trimThreadRecorders(std::chrono::milliseconds(0), true); ++ return jsi::Value::undefined(); + } + JSI_HOST_FUNCTION(getNativeDevice) { + // Raw WGPUDevice pointer of the Graphite device, as a BigInt. Consumed by +@@ -262,6 +272,8 @@ + } + + static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) { ++ installHostMethod(runtime, prototype, "__rnskvTrimRecorderCache", ++ &JsiSkApi::__rnskvTrimRecorderCache); + installHostMethod(runtime, prototype, "getNativeDevice", + &JsiSkApi::getNativeDevice); + installGetterWithRuntime(runtime, prototype, "gpu", &JsiSkApi::getGpu); diff --git a/scripts/skia-canvas-patch.json b/scripts/skia-canvas-patch.json index f7d3e0c..9e63e4c 100644 --- a/scripts/skia-canvas-patch.json +++ b/scripts/skia-canvas-patch.json @@ -1,13 +1,13 @@ { - "version": "3.9.1", + "version": "3.9.2", "files": { "cpp/rnskia/RNDawnContext.h": { - "before": "d9e9370842e544a3d1a9e4337298c9ea2165c60c87acfe16530ac1325990bab8", - "after": "6e003b921aa7f6f00eed0560fd199d9a21c35119854cb026a2d802e39b5a6157", + "before": "ed26c1390ac4912089b354651c970801d42db7318ed40c51c19357b2252c52d4", + "after": "bceaaf3cabcde96d4d3843210d74e2de23991631e85427ec34c4b481ff30e5a0", "edits": [ { "before": " current->context->submit(syncToCpu);\n return inserted;\n }\n", - "after": " current->context->submit(syncToCpu);\n return inserted;\n }\n\n // Checked only for surfaces that explicitly opt into this contract: like\n // submitRecording, but a recording that would not run throws instead of\n // being dropped. A valid empty Recording is accepted; Recorder::snap()\n // returns nullptr on failure.\n void submitRecordingChecked(\n skgpu::graphite::Recorder *recorder,\n skgpu::graphite::SyncToCpu syncToCpu = skgpu::graphite::SyncToCpu::kNo) {\n if (recorder == nullptr) {\n throw std::runtime_error(\n \"Checked GPU submissions require a Graphite recorder\");\n }\n auto recording = recorder->snap();\n if (recording == nullptr) {\n throw std::runtime_error(\"Cannot create checked Graphite recording\");\n }\n std::lock_guard lock(_mutex);\n auto *current = _current.load(std::memory_order_acquire);\n if (generationOf(recorder) != current->id ||\n current->lost.load(std::memory_order_acquire)) {\n throw std::runtime_error(\n \"The GPU device was lost; a checked recording cannot run\");\n }\n skgpu::graphite::InsertRecordingInfo info;\n info.fRecording = recording.get();\n auto status = current->context->insertRecording(info);\n if (!static_cast(status)) {\n throw std::runtime_error(\"Graphite rejected a checked recording: \" +\n status.message());\n }\n if (!current->context->submit(syncToCpu)) {\n throw std::runtime_error(\"Graphite checked submission failed\");\n }\n }\n" + "after": " current->context->submit(syncToCpu);\n return inserted;\n }\n\n // Checked only for surfaces that explicitly opt into this contract: like\n // submitRecording, but a recording that would not run throws instead of\n // being dropped. A valid empty Recording is accepted; Recorder::snap()\n // returns nullptr on failure.\n void submitRecordingChecked(\n skgpu::graphite::Recorder *recorder,\n skgpu::graphite::SyncToCpu syncToCpu = skgpu::graphite::SyncToCpu::kNo) {\n if (recorder == nullptr) {\n throw std::runtime_error(\n \"Checked GPU submissions require a Graphite recorder\");\n }\n // As in submitRecording: the snap compiles the pipelines the recording\n // needs, inline, GPU work the pipeline warmup stays behind (see\n // RNSkGpuActivity), as is the run.\n RNSkGpuActivity::Scope activity;\n auto recording = recorder->snap();\n if (recording == nullptr) {\n throw std::runtime_error(\"Cannot create checked Graphite recording\");\n }\n std::lock_guard lock(_mutex);\n auto *current = _current.load(std::memory_order_acquire);\n if (generationOf(recorder) != current->id ||\n current->lost.load(std::memory_order_acquire)) {\n throw std::runtime_error(\n \"The GPU device was lost; a checked recording cannot run\");\n }\n skgpu::graphite::InsertRecordingInfo info;\n info.fRecording = recording.get();\n auto status = current->context->insertRecording(info);\n if (!static_cast(status)) {\n throw std::runtime_error(\"Graphite rejected a checked recording: \" +\n status.message());\n }\n if (!current->context->submit(syncToCpu)) {\n throw std::runtime_error(\"Graphite checked submission failed\");\n }\n }\n" } ] },