Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete traitCast and identifier traits #42748

Closed
wants to merge 2 commits into from

Conversation

NickGerleman
Copy link
Contributor

Summary:
React Native has globally enabled RTTI within rn_xplat_cxx_library, ahead of RTTI being forced on (regardless of flag) in Android apps.

This diff:

  1. Mechanically replaces usages of traitCast with equivalent calls to dynamic_cast or dynamic_pointer_cast
    1. These have similar semantics as current iteration of traitCast, where we return nullptr for pointer form, or throw on invalid cast for reference form.
  2. Removes IdentifierTrait as a requirement to cast to a ShadowNode
  3. Removes the ShadowNode traits used solely as cast identities

The OSS builds should already have RTTI on, and will be able to use dynamic_cast on RN provided types (traitCast is not extendable).

Changelog:
[General][Breaking] - Delete traitCast and identifier traits

Differential Revision: D53215009

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 30, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53215009

Summary:

If left and right are swapped, this code assumes every yoga layoutable shadownode is a view, and mutates its props as if they were ViewProps. This is not safe, and could lead to memory corruption.

Changelog: [Internal]

Differential Revision: D53213652
Summary:

React Native has globally enabled RTTI within `rn_xplat_cxx_library`, ahead of RTTI being forced on (regardless of flag) in Android apps.

This diff:
1. Mechanically replaces usages of `traitCast` with equivalent calls to `dynamic_cast` or `dynamic_pointer_cast`
    1. These have similar semantics as current iteration of `traitCast`, where we return `nullptr` for pointer form, or throw on invalid cast for reference form.
2. Removes `IdentifierTrait` as a requirement to cast to a ShadowNode
3. Removes the ShadowNode traits used solely as cast identities 

The OSS builds should already have RTTI on, and will be able to use `dynamic_cast` on RN provided types (`traitCast` is not extendable). 

Changelog:
[General][Breaking] - Delete traitCast and identifier traits

Differential Revision: D53215009
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D53215009

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 17,180,996 -16
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 20,559,896 -29
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: c7479b0
Branch: main

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 1, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 1170a68.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants