Repository navigation
feat(🚨): add named Skia errors and raise them from native code - #4533
Open
wcandillon wants to merge 6 commits into
Open
wcandillon wants to merge 6 commits into
wcandillon wants to merge 6 commits into
Conversation
First step of the v3 error handling RFC: one family of named errors, modelled on WebGPU's error types, that every public API will throw or reject with. - SkiaError and its subclasses (SkiaDecodeError, SkSLCompilationError, SkiaValidationError, SkiaOutOfMemoryError, SkiaGPUUnavailableError, SkiaInternalError), plus the NotSupportedError, AbortError and NotFoundError names WebGPU uses, and isSkiaError() to recognize them by name on any runtime. - RNJsi::NamedError: a C++ exception that becomes the JS error of its name where it crosses into JS, in every host function the NativeObject installers create and in promises (executor, settle, reject). The JS errors are built with the constructors the package registers on the React Native runtime, so instanceof holds there; a worklet runtime gets an Error with the same name and extra field. - The web backend throws NotSupportedError for the APIs it does not have. - An Errors documentation page. No public API changes its behaviour yet: the factories and promises move to these errors in the following changes.
wcandillon
marked this pull request as ready for review
November 26, 2026 09:21
Copilot stopped work on behalf of
wcandillon due to an error
November 26, 2026 09:21
isSkiaError matched on the error name alone, so a DOMException of the same name (the AbortError of an aborted fetch) passed as a Skia error. The errors now carry a non-enumerable __rnskiaError brand, set by the SkiaError class and by NamedError when it builds a plain Error on a runtime without the classes, and isSkiaError requires it. This also removes the worklet's capture of SkiaErrorNames, which was declared after isSkiaError and read before its initialization.
…g surface The web renderer and the shared WebGL context threw plain Errors when the browser refused a WebGL, graphics or 2D context, so apps had to match the message to show an empty state. They now throw SkiaSurfaceUnavailableError, whose context field says which one failed (webgl, graphics or 2d).
This branch has not been deployed
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.
Description
Part 1 of 5 of the v3 error handling RFC: the public API reports failures the way WebGPU does. Factories throw named errors instead of returning null, promises reject instead of resolving null, a lost GPU device yields dead objects instead of throws, and failures with no caller go to an
uncapturederrorevent.Stack:
uncapturederroronSkia.gpuAgent-written content
SkiaErrorand its subclasses (SkiaDecodeError,SkSLCompilationError,SkiaValidationError,SkiaOutOfMemoryError,SkiaGPUUnavailableError,SkiaInternalError), plus theNotSupportedError,AbortErrorandNotFoundErrornames WebGPU uses.isSkiaError()recognizes them by name on any runtime.RNJsi::NamedError, a C++ exception that becomes the JS error of its name where it crosses into JS: in every host function the NativeObject installers create, and in promises (executor, settle, reject). The JS errors are built with constructors the package registers on the React Native runtime, soinstanceofholds there. A worklet runtime gets anErrorwith the same name and extra field.NotSupportedErrorfor the APIs it does not have.No public API changes behaviour yet.
Testing:
yarn tsc,yarn lintandyarn testpass. The C++ was syntax-checked against the Skia, Dawn and JSI headers (Android configuration) but not built or run on a device.Generated by Claude Code