Skip to content

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

Open

Description

@maxlapides

Proposed fix: #60222

Description

On iOS, when a mount runs synchronously inside a UIKit animation block, the views that mount creates take part in the animation. Their first center and bounds (and animatable props such as backgroundColor) animate from their initial values, so new views grow in from the top-left corner of their parent, and recycled views move in from wherever they were last laid out.

The usual way to get a mount inside an animation block is an unstable_Immediate state update sent from one. Components do this so their children's new layout animates along with a native change, for example a container that resizes inside +[UIView animateWithDuration:animations:] or -[UISheetPresentationController animateChanges:]:

  1. EventQueue::enqueueStateUpdate flushes the update immediately: UIManager::updateState commits with the default commit options (mountSynchronously = true).
  2. RCTMountingManager -scheduleTransaction: is called on the main thread, so it mounts synchronously, inside the animation block.
  3. The mounting coordinator pulls the latest revision of the surface. If a React commit has been pushed but not mounted yet, its mutations are part of this transaction, and the views it creates are configured (updateProps:, updateLayoutMetrics:, finalizeUpdates:) inside the animation block.

Existing views animating along is the point of the immediate update. New views animating in from a zero frame is not.

We hit this with react-native-true-sheet: when a presented sheet changes detents, content that React commits just before the sheet's resize mounts inside the resize animation and grows in from the corner (details and recordings in lodev09/react-native-true-sheet#1038). The library's maintainer considers this a React Native issue, since any component that sends immediate state updates from an animation block can hit it, and suggested that a view's first layout shouldn't inherit the surrounding animation.

Steps to reproduce

  1. Clone https://github.com/maxlapides/rn-mount-animation-repro and run the iOS app: cd ReproducerApp && yarn install && cd ios && bundle install && bundle exec pod install && cd .. && yarn ios
  2. Tap Mount tiles.
  3. Tap Reset, then Mount tiles again.
  • Expected: the tiles appear in place at full size.
  • Actual: on the first tap the tiles grow in from the top-left corner of the screen over 1.5 seconds. On later taps the tiles reuse recycled native views and move in from those views' previous positions.

The reproducer has one native component, ImmediateStateView. Its command sends _state->updateState(..., EventQueue::UpdateMode::unstable_Immediate) from inside +[UIView animateWithDuration:1.5 animations:]. The press handler sends that command and sets state in the same JS task. React Native dispatches view commands at the end of the task (Scheduler::uiManagerDidDispatchCommand → RuntimeScheduler::scheduleRenderingUpdate), after the tiles' commit has been pushed but before it has been mounted, so the bug reproduces on every tap. The tiles aren't children of ImmediateStateView: any pending commit on the surface is mounted.

React Native Version

0.88.1

RCTPerformMountInstructions on main (d6ea9fc) is identical to 0.88.1.

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info

System:
  OS: macOS 27.2.1
  CPU: (15) arm64 Apple M5 Pro
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.22.1
    path: ~/.local/share/mise/installs/node/24.22.1/bin/node
  Yarn: Not Found
  npm:
    version: 11.19.1
    path: ~/.local/share/mise/installs/node/24.22.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.17.0
    path: ~/.local/share/mise/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 27.2
      - iOS 27.2
      - macOS 27.2
      - tvOS 27.2
      - visionOS 27.2
      - watchOS 27.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2026.2 AI-262.10968.63.2622.16730706
  Xcode:
    version: 27.2/27B52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 21.0.13.1
    path: /opt/homebrew/bin/javac
  Ruby:
    version: 4.0.10
    path: ~/.local/share/mise/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.2.0
    wanted: 20.2.0
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.88.1
    wanted: 0.88.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

No crash or log output; this is a visual bug.

MANDATORY Reproducer

https://github.com/maxlapides/rn-mount-animation-repro

Screenshots and Videos

iPhone 17 Pro simulator, iOS 27.2. "After" uses the proposed fix, built from source.

Before After
Before After

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

Before and after frame strips

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions