Closed netmaxt3r closed 5 months ago
Thanks for the reproducer @netmaxt3r
One possible solution i see is using strong warapper class/struct for alias types, Or is there any compiler flag we can use to fix function overloading?
Type wrappers could be a solution here, or we could qualify the fromRawValue
function with the module name so they won't clash at runtime.
Let me get back to you on potential solution here.
we could qualify the
fromRawValue
function with the module name
we need to consider single module having multiple array enum props as well , which could clash each other in this case
we could qualify the
fromRawValue
function with the module namewe need to consider single module having multiple array enum props as well , which could clash each other in this case
Ah that's also a really valid scenario
same problem, need help
@cortinico any news on the possible approach to fix this ? If i get direction i can start working on a PR
One possible solution i see is using strong warapper class/struct for alias types
@netmaxt3r I believe the best solution would be the one you suggested, to wrap the types into a struct and use them so the overload resolution won't be ambiguous. If you could send over a PR to draft this fix, we can look into merging it (or see if there are any blockers)
@cortinico please see PR #44123 , I am pretty new to codegen, i need to figure out the call stack for static inline std::string toString(const ${enumMask}Wrapped &wrapped)
function and check other platforms + update jest snapshots. Please review changes with internal team if i missed any scenario.
Any ideas how to apply the PR to an existing 0.74.1 project? Seems the PR code is typescript while the code in node_modules/@react-native/codegen is javascript
I feel I'm missing a step here?
@knro try @react-native/codegen version 0.75.0-nightly-20240429-b7de91666 might work with 0.74
Thank you @netmaxt3r. It's still crashing (with the same backtrace that you have). I noticed we have two codegens apparently.
node_modules/@react-native/codegen which is updated to 0.75 night above node_modules/react-native-codegen which is v0.71
I tried deleting the react-native-codegen but after yarn install it gets added again to node_modules, so not sure how to make it select the first one?
Ok I was able to remove react-native-codegen from package.json so that's resolved. But I noticed the app is still crashing, then I noticed when I install the bundle, I get this:
Installing React (0.74.1)
Installing React-Codegen (0.74.1)
Installing React-Core (0.74.1)
It appears that it installing Pod for 0.74.1 ? Not sure how you can override them to 0.75 nightly if that's at all possible?
This is the backtrace:
Thread 9 Crashed:: com.facebook.react.JavaScript
0 libsystem_kernel.dylib 0x1063c53b0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x10644f124 pthread_kill + 256
2 libsystem_c.dylib 0x1801655c0 abort + 104
3 stellarmate 0x104881e58 facebook::react::fromRawValue(facebook::react::PropsParserContext const&, facebook::react::RawValue const&, unsigned int&) + 580 (Props.h:180)
4 stellarmate 0x10487e974 unsigned int facebook::react::convertRawProp<unsigned int, unsigned int>(facebook::react::PropsParserContext const&, facebook::react::RawProps const&, char const*, unsigned int const&, unsigned int const&, char const*, char const*) + 116 (propsConversions.h:130)
5 stellarmate 0x10497a3bc facebook::react::ModalHostViewProps::ModalHostViewProps(facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&) + 436 (Props.cpp:123)
6 stellarmate 0x104a0a474 facebook::react::ModalHostViewProps* std::__1::construct_at[abi:ue170006]<facebook::react::ModalHostViewProps, facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&, facebook::react::ModalHostViewProps*>(facebook::react::ModalHostViewProps*, facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&) + 4 (construct_at.h:41) [inlined]
7 stellarmate 0x104a0a474 void std::__1::allocator_traits<std::__1::allocator<facebook::react::ModalHostViewProps>>::construct[abi:ue170006]<facebook::react::ModalHostViewProps, facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&, void, void>(std::__1::allocator<facebook::react::ModalHostViewProps>&, facebook::react::ModalHostViewProps*, facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&) + 4 (allocator_traits.h:304) [inlined]
8 stellarmate 0x104a0a474 std::__1::__shared_ptr_emplace<facebook::react::ModalHostViewProps, std::__1::allocator<facebook::react::ModalHostViewProps>>::__shared_ptr_emplace[abi:ue170006]<facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&>(std::__1::allocator<facebook::react::ModalHostViewProps>, facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&) + 40 (shared_ptr.h:300)
9 stellarmate 0x104a0a41c std::__1::__shared_ptr_emplace<facebook::react::ModalHostViewProps, std::__1::allocator<facebook::react::ModalHostViewProps>>::__shared_ptr_emplace[abi:ue170006]<facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&>(std::__1::allocator<facebook::react::ModalHostViewProps>, facebook::react::PropsParserContext const&, facebook::react::ModalHostViewProps const&, facebook::react::RawProps const&) + 16 (shared_ptr.h:292) [inlined]
@knro
I noticed we have two codegens apparently.
please add using yarn resolution example
I noticed when I install the bundle
that is native code , we just need to bump the js package for this fix
I noticed the app is still crashing
I tested with latest rn app see reproducer app. could you try rebuilding app from clean Pods
@netmaxt3r Thank you!!! The resolutions field did the trick and now it no longer crashes.
Closing as https://github.com/facebook/react-native/pull/44123 got merged which fixes this issue
@cortinico is it possible keep this open till fix land on release version or create fix release for 0.74.x (current) rn version?
is it possible keep this open till fix land on release version or create fix release for 0.74.x (current) rn version?
We generally close issues once they're fixed to keep track of the remaining actionable work. As there is nothing actionable here, I'd rather keep it closed.
We'll be cutting the 0.75 release branch really soon, and this change will go out in 0.75.0-rc.0
Description
codegen generates duplicate
fromRawValue
for array enum type props across different modules in same namespace facebook::react with different type alias foruint32_t
In the reproducer app i usedreact-native-webview
as an example to crash with Modal component fromreact-native
Modal generatesnode_modules/react-native/ReactCommon/react/renderer/components/rncore/Props.h
from line 295 for parsingsupportedOrientations
prop at line 323WebView generates
/ios/Pods/Headers/Private/React-Codegen/react/renderer/components/RNCWebViewSpec/Props.h
from line 110 for parsingdataDetectorTypes
prop at line 142both function only differ in result parameter but they same at runtime because of same type alias
In the stack trace of crash we can see it starts to parse
ModalHostViewProps
then callfromRawValue
fromRNCWebViewSpec/Props.h
with method signaturefacebook::react::fromRawValue(facebook::react::PropsParserContext const&, facebook::react::RawValue const&, unsigned int&)
One possible solution i see is using strong warapper class/struct for alias types, Or is there any compiler flag we can use to fix function overloading?
Note:- I haven't used react-native-webview in the js side, it is just for the codegen. If i remove
supportedOrientations
prop completely app wont crashSteps to reproduce
clone repo
https://github.com/netmaxt3r/rn-codegen-runtime-crash
yarn install
bundle install
RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
yarn start
yarn ios
React Native Version
0.73.6
Affected Platforms
Runtime - iOS
Areas
Codegen
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/netmaxt3r/rn-codegen-runtime-crash
Screenshots and Videos
No response