Skip to content

fix(ios): Don't animate views created by a mount inside a UIKit animation block - #60222

Open
maxlapides wants to merge 1 commit into
react:mainfrom
maxlapides:fix/ios-mount-inherited-animation
Open

maxlapides wants to merge 1 commit into
react:mainfrom
maxlapides:fix/ios-mount-inherited-animation

Conversation

@maxlapides

Copy link
Copy Markdown

Summary:

Fixes #60221.

On iOS, a mount can run synchronously inside a UIKit animation block. The common case is a component that sends an unstable_Immediate state update from inside +[UIView animateWithDuration:animations:] or -[UISheetPresentationController animateChanges:], so that its children's new layout animates along with a native change. That mount pulls the latest revision of the surface, so it also includes any React commit that was pushed but not mounted yet. The views it creates are configured inside the animation block and inherit the animation: new views grow in from a zero frame (their parent's top-left corner), and recycled views move from their last frame. react-native-true-sheet hits this when a sheet changes detents (lodev09/react-native-true-sheet#1038).

With this change, a view's initial configuration no longer inherits the surrounding animation. When RCTPerformMountInstructions runs inside an animation block (+[UIView inheritedAnimationDuration] > 0), it records the tags the transaction creates, and configures those views on Insert (props, event emitter, state, layout metrics and finalizeUpdates:) inside +[UIView performWithoutAnimation:].

What stays the same:

  • Mounts outside an animation block take the same path as before, with no extra work.
  • Updates to existing views, and moved views (Remove + Insert without Create), still animate with the surrounding block, so existing content keeps animating along with the native change.
  • Nothing is mounted early or flushed, so a queued LayoutAnimation and other surfaces' state updates are unaffected.

Known limits:

  • If a newly created view starts its own UIView animation from its first updateProps: or finalizeUpdates: while mounted inside an outer animation block, that animation is now skipped and the end state applies immediately. Before, it inherited the outer block's duration and curve.
  • Layout that UIKit runs later in the same animation block, such as a new view's layoutSubviews, still inherits the animation. Core components set their subview frames in updateLayoutMetrics:, except RCTParagraphComponentView, which positions its text view in layoutSubviews. In the react-native-true-sheet case below, text inside new views also appeared in place.

Changelog:

[IOS] [FIXED] - Views created by a mount that runs inside a UIKit animation block, for example from an immediate state update, no longer animate in from a zero frame

Test Plan:

Reproducer: https://github.com/maxlapides/rn-mount-animation-repro, from the react-native-community template on React Native 0.88.1, whose RCTMountingManager.mm is identical to main before this change. All runs used an iPhone 17 Pro simulator on iOS 27.2 with Xcode 27.2, Debug builds.

  1. Built the reproducer against the prebuilt core (pod install), and from source (RCT_USE_PREBUILT_RNCORE=0 pod install) with and without this patch applied to node_modules/react-native (fix/RCTMountingManager.patch in the reproducer).
  2. Tapped Mount tiles and Reset repeatedly:
    • Prebuilt 0.88.1: 3 of 3 mounts animated (the first grew in from the top-left corner, later ones moved from the recycled views' old frames).
    • From source without the patch: 5 of 5 mounts animated.
    • From source with the patch: 5 of 5 mounts appeared in place.
  3. Checked the original case in react-native-true-sheet's bare example (React Native 0.88.0 built from source with this patch, library at main without a workaround). Its Resize Race sheet changes detents while a grid commit is pending. With stock React Native, the grid grew in from the corner on 3 of 3 expands. With the patch, it appeared in place on 5 of 5, and the existing sheet content still moved with the sheet. Text labels added to the tiles also appeared in place.
  4. clang-format 21 with the repository's .clang-format reports no changes.

Not run: RNTester, physical devices, other iOS versions. There are no unit tests for RCTMountingManager. Android doesn't use this code.

Before After
Before After

Reproducer, first tap, frames 0.15 s apart (top: before, bottom: after):

Reproducer frame strips

react-native-true-sheet Resize Race, first expand, frames 67 ms apart (top: stock React Native, bottom: this patch):

react-native-true-sheet frame strips

…tion block

A transaction can be mounted synchronously from inside a UIKit animation block, for example when a component sends an unstable_Immediate state update from one. That mount includes any React commit that was pushed but not yet mounted, and the views it creates picked up the surrounding animation: they grew in from a zero frame, or moved from a recycled view's last frame. Views created by the transaction are now configured inside performWithoutAnimation. Existing views keep animating along.
@meta-cla

meta-cla Bot commented Nov 22, 2026

Copy link
Copy Markdown

Hi @maxlapides!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Nov 22, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla 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 Nov 22, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 22, 2026

This branch has not been deployed

No deployments
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Views mounted inside a UIKit animation block animate in from a zero frame

1 participant