Avoid exception-based nativeID parsing#9966
Draft
zxrl wants to merge 1 commit into
Draft
Conversation
Member
|
Good catch, I forgot to backport it to Legacy! Why is it a draft still? Do you intend to do more changes? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #7163.
React Native exposes
nativeIDas a string and uses non-numeric values internally. The legacy layout animation proxy currently parses every non-emptynativeIDwithstoiand relies on exceptions to reject unrelated IDs. In iOS applications whose native link graph contains code compiled with-fno-exceptions, that invalid parse can terminate the process instead of reaching the catch block.This change moves
nativeIDparsing intoLayoutAnimationsProxyCommonand uses the existing non-throwing digit validation from the experimental proxy. Both layout animation proxies now share one parser, non-numeric IDs are ignored, and numeric Reanimated IDs continue transferring their animation configuration.Test plan
Formatting and common C++ validation:
clang-format --dry-run --Werror \ packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.{cpp,h} \ packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.{cpp,h} \ packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.{cpp,h} cd packages/react-native-reanimated ../../scripts/validate-common.shPhysical iOS reproduction uses React Native 0.86, Fabric, Hermes, and a native dependency graph containing
-fno-exceptions. Mounting a view with a non-numericnativeIDwhile Reanimated processes layout insertions previously aborted inLayoutAnimationsProxy_Legacy::transferConfigFromNativeIDthroughstd::__1::stoi.Minimal affected view:
After this change, the non-numeric ID is ignored without throwing. Numeric IDs still reach
LayoutAnimationsManager::transferConfigFromNativeID.