react-native: OP-SQLite cannot build with 0.74RC and bridgeless
Description
Hi, I’m trying to test the library against the latest RC and also trying to get bridgeless to work. So far I’m facing two issues with the included example app in my library repo.
iOS:
It seems the codegen script is expecting the src files to be in node_modules, but the builder-bob template links the dependency directly via react-native.config.js
:
// react-native.config.js
const path = require('path');
const pak = require('../package.json');
module.exports = {
dependencies: {
[pak.name]: {
root: path.join(__dirname, '..'),
},
},
};
And I get the following error when trying to install the pods:
Android
After turning on all the flags (and bumping the minSDK to 23) I get a compilation error but no output to what is wrong:
Steps to reproduce
If you want to take a look yourself here is the branch. Just install deps via yarn
and then try to run the example app: cd example && yarn android
or the equivalent iOS commands.
React Native Version
0.74.0-rc.0
Affected Platforms
Build - MacOS
Areas
Bridgeless - The New Initialization Flow
Output of npx react-native info
System:
OS: macOS 14.3.1
CPU: (11) arm64 Apple M3 Pro
Memory: 2.49 GB / 36.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.19.0
path: ~/.nvm/versions/node/v18.19.0/bin/node
Yarn:
version: 4.0.2
path: ~/.nvm/versions/node/v18.19.0/bin/yarn
npm:
version: 10.2.3
path: ~/.nvm/versions/node/v18.19.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.14.0
path: /Users/osp/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.2
- iOS 17.2
- macOS 14.2
- tvOS 17.2
- visionOS 1.0
- watchOS 10.2
Android SDK:
Android NDK: 26.0.10792818
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11330709
Xcode:
version: 15.2/15C500b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 3.3.0
path: /Users/osp/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.0-rc.0
wanted: ^0.74.0-rc.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
### Stacktrace or Logs
```text
Pasted above
Reproducer
https://github.com/OP-Engineering/op-sqlite/tree/bridgeless
Screenshots and Videos
No response
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Reactions: 3
- Comments: 57 (56 by maintainers)
Commits related to this issue
- Fix findLibrariesFromReactNativeConfig Summary: This diff removes extra argument from the `extractLibrariesFromJSON` call inside `findLibrariesFromReactNativeConfig`. This should fix the iOS failurte... — committed to dmytrorykun/react-native by dmytrorykun 4 months ago
- Fix findLibrariesFromReactNativeConfig Summary: This diff removes extra argument from the `extractLibrariesFromJSON` call inside `findLibrariesFromReactNativeConfig`. This should fix the iOS failurte... — committed to dmytrorykun/react-native by dmytrorykun 4 months ago
- Fix findLibrariesFromReactNativeConfig Summary: This diff removes extra argument from the `extractLibrariesFromJSON` call inside `findLibrariesFromReactNativeConfig`. This should fix the iOS failurte... — committed to facebook/react-native by dmytrorykun 4 months ago
- Fix findLibrariesFromReactNativeConfig Summary: This diff removes extra argument from the `extractLibrariesFromJSON` call inside `findLibrariesFromReactNativeConfig`. This should fix the iOS failurte... — committed to facebook/react-native by dmytrorykun 4 months ago
- Fix findLibrariesFromReactNativeConfig Summary: This diff removes extra argument from the `extractLibrariesFromJSON` call inside `findLibrariesFromReactNativeConfig`. This should fix the iOS failurte... — committed to okwasniewski/react-native by dmytrorykun 4 months ago
- decouple RCTBridge+Private from jsinspector-modern Summary: Changelog: [Internal] fix for part of https://github.com/facebook/react-native/issues/43204 RCTBridge+Private is transitively bringing in... — committed to facebook/react-native by philIip 3 months ago
Ok, reverting to an old module works in all archs. Will close for now, and I guess we can have a discussion when old modules will be completely retired. Like I said, I don’t really care about having to migrate to a C++ Turbo Module, as long as I get to call the native functions that’s all I need.
@philIip ok, I got it, it is cumbersome and I’m short on time, but I will try to get it soon a report how it goes. Thanks!
I tried generating a patch-package with the changes but it failed to apply. Maybe some of these files are created on the install step? In any case, manually applying the changes to
node_modules/react-native
doesn’t seem to work for meHere is the patch file in case you want to check if I did it correctly:
https://github.com/OP-Engineering/op-sqlite/pull/60/files#diff-0c24a4c1e88df14537749bb451dbc3164819872c11700d39fa16f1abe54b1fdc
I re-applied the same changes again and I’m getting this:
Thanks for the help @arushikesarwani94! The app is now building correctly! 🎉
Waiting for instructions regarding iOS
@philIip thanks, I will give it a try when I can, this weekend.
@arushikesarwani94 you mean just casting to CallInvokerHolder? I will give it a try thanks
For Android, I couldn’t repro due to gradle issues but from cursory look the crash is happening since the newly added catalyst instance for Bridgeless is returning the interface
CallInvokerHolder
versus what OPSQLiteBridge expects is an implementing class of this interface i.e.CallInvokerHolderImpl
which is why the cast is failing.Also, since
CallInvokerHolderImpl
is aFrameworksAPI
: This API is provided only for React Native frameworks and not intended for general users, we recommend directly using the interface. LMK if this works.https://github.com/facebook/react-native/pull/43424 as well to fix failing test.
For Android https://github.com/facebook/react-native/pull/43400 should fix accessing the JSCallInvoker in Bridgeless.
I still haven’t received any info on how to solve the issues. Basically still at square 0.
iOS
I need more exact snippets on how to retrieve the call invoker for iOS (or in its absence the runtimeExecutor, which I didn’t find any way to retrieve it from existing exposed classes)
https://github.com/facebook/react-native/issues/43204#issuecomment-1972586329
The problem with the runtime executor is that then my Android and iOS codebases will diverge. So I need to use one or the other.
Android
I still did not manage to get a hold of the call invoker from the Bridgeless Android module.
https://github.com/facebook/react-native/issues/43204#issuecomment-1968380955
for iOS, accessing the raw runtime should be backwards compatible. this build issue seems like something else. dmitry is currently looking at it
hi!!! for android, in new architecture, we will be recommending to use RuntimeExecutor:
https://github.com/facebook/react-native/blob/c3b0a8f1626939cf5c7b3864a5acf9d3dad26fb3/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java#L219
it should be a simple drop in replacement and it is forward compatible so it will work in bridge as well
Thanks in the mean time I will patch it
@ospfranco sorry, I forgot to post an update here. iOS has been fixed https://github.com/facebook/react-native/pull/43210 The fix will be available in the next RC.
The methods on op-sqlite run in a different thread, therefore to return the data to JS without crashing the JS context I need to schedule the callback (or in this case promise resolve). I have used this extensively on other client modules whenever there needs to be async work that does not block the JS thread, e.g. authentication/fingerprint callbacks.
Edit: I read up a bit on the RuntimeExecutor, which I guess is meant to replace the CallInvoker, I don’t understand all the details though. Any pointers would be appreciated to understand where is the new arch headed to.
Hi @ospfranco, thanks for the issue.
For Android, we are aware that codegen and autolinking are not working with the RC.0 as we needed a commit that landed right after the branch cut. It should be solved in RC1
For iOS, @dmytrorykun, can you provide any insight? I remember that we had a similar report of
react-native.config.js
not being picked up by Codegen, but I remember we fixed that already. 🤔