Skip to content

Conversation

@JakubGonera
Copy link
Contributor

Description

Fix exception handling in C++ native code so that it results in JS promise getting rejected with an appropriate message. There are two fixes here:

  1. Runtime type information in the current version of React Native is disabled because one of its dependencies, which results in C++ not being able to recognize that std::runtime_error is inheriting from std::exception so to extract the exception message we need to match the type exactly. A fix has been introduced in RN repo, but not yet present in any release: facebook/react-native@3132cc8.
  2. When rejecting a promise the old code was accessing JS runtime in an unsafe way, this is fixed now.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improves or adds clarity to existing documentation)

Tested on

  • iOS
  • Android

@JakubGonera JakubGonera force-pushed the @jakubgonera/style-transfer-exceptions branch from 63172e6 to 0fd19e3 Compare May 7, 2025 11:13
@JakubGonera JakubGonera marked this pull request as ready for review May 7, 2025 11:14
@JakubGonera JakubGonera force-pushed the @jakubgonera/style-transfer-cpp branch from c8cbe4a to a991245 Compare May 19, 2025 07:57
@JakubGonera JakubGonera force-pushed the @jakubgonera/style-transfer-exceptions branch from 20ba72c to 452ede5 Compare May 20, 2025 08:25
Base automatically changed from @jakubgonera/style-transfer-cpp to @jakubgonera/cpp May 20, 2025 13:13
@JakubGonera JakubGonera changed the base branch from @jakubgonera/cpp to v0.4.0-rc1 May 20, 2025 13:18
@JakubGonera JakubGonera changed the base branch from v0.4.0-rc1 to @jakubgonera/cpp May 20, 2025 13:18
@JakubGonera JakubGonera force-pushed the @jakubgonera/style-transfer-exceptions branch from d72b399 to 1ae1b35 Compare May 20, 2025 13:37
@JakubGonera JakubGonera merged commit 1a567c3 into @jakubgonera/cpp May 20, 2025
1 check passed
@JakubGonera JakubGonera deleted the @jakubgonera/style-transfer-exceptions branch May 20, 2025 13:48
JakubGonera added a commit that referenced this pull request May 28, 2025
## Description

Fix exception handling in C++ native code so that it results in JS
promise getting rejected with an appropriate message. There are two
fixes here:
1. Runtime type information in the current version of React Native is
disabled because one of its dependencies, which results in C++ not being
able to recognize that `std::runtime_error` is inheriting from
`std::exception` so to extract the exception message we need to match
the type exactly. A fix has been introduced in RN repo, but not yet
present in any release:
facebook/react-native@3132cc8.
2. When rejecting a promise the old code was accessing JS runtime in an
unsafe way, this is fixed now.

### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Documentation update (improves or adds clarity to existing
documentation)

### Tested on

- [x] iOS
- [x] Android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle errors in C++ native code gracefully Port style transfer model to C++

4 participants