Remove usages of RTTI in places used by react-native-windows#31694
Remove usages of RTTI in places used by react-native-windows#31694acoates-ms wants to merge 5 commits into
Conversation
Base commit: 36c0a7d |
Base commit: 6e2989a |
|
No concerns from me, this looks good! |
|
Hey @acoates-ms Thank you for the PR! The change looks great, could you add unit tests to https://github.com/facebook/react-native/blob/master/ReactCommon/react/renderer/core/tests/traitCastTest.cpp ? |
|
@JoshuaGross has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
Thank you @acoates-ms. |
|
@acoates-ms When these tests run on iOS I get the error "Death tests are not supported on this platform." - not sure if this is iOS in general or iOS test infra at FB. Can we remove the death tests or gate them to not-iOS? |
|
There are already ungated death tests in that file. Is it maybe indicating that the test failed? Or is it really a failure to run the test? |
I'm only getting those messages for traitCastTest.cpp for whatever reason... EDIT: I didn't answer your question, apologies. Here's the error messages: Edit 2: those are truncated, there are more but they all look similar to that ^ |
|
@acoates-ms Okay, let's try this again :) those are just the warning messages so probably not relevant. Here's the crash. |
|
Ah I think I see it. Sorry I haven't actually run these UTs -- Not sure if they are runnable in OSS. -- Fix incoming. I have some expectations inverted in the tests. |
|
@JoshuaGross has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Oops, looks like the test doesn't compile now. Here's a truncated error, hopefully it's enough info: |
|
@JoshuaGross has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
K, trying again to land - if this doesn't work we can iterate again tomorrow. |
|
I think the JS test failing is unrelated... I'll investigate tomorrow |
|
@JoshuaGross merged this pull request in 050922a. |
Summary
Adding runtime type information adds greatly to the binary size, so react-native-windows builds without it. But some parts of the fabric code currently uses dynamic_cast, which means to use fabric we have to build with RTTI turned on. This PR removes the usages of dynamic_cast that are hit in release builds, which should allow react-native-windows to turn off RTTI in release builds.
Required for: microsoft/react-native-windows#7981
One thing to note, the comment in ShadowNodeTraits indicates that core was reserving the first 16 bits. I'm adding two more. Is that ok? Should core be reserving more for future use?
Changelog
[Internal] [Fixed] - Remove uses of dynamic_cast in release builds
Test Plan
Verified that I can build react-native-windows with Fabric in release, without RTTI.
Boot / clicked around in RNW RNTester