Skip to content

[iOS] Image in a clipping view is clipped to its final size during a layout animation such as rotation #60252

Backlog

Description

@dileepapeiris

Description

On iOS, an <Image> (or any UIImageView subview of a clipping view) is clipped to its final size for the whole duration of a layout animation such as a device rotation. The surrounding view animates smoothly from the old size to the new one, but the image jumps to the new size on the first frame, so the parent's background shows through until the animation ends.

Cause: in RCTViewComponentView.invalidateLayer, when the view clips to bounds, every UIImageView subview gets a new CAShapeLayer mask whose path is the subview's bounds at layout time:

https://github.com/facebook/react-native/blob/ad969b28378ad5215d98178c033afea849e4ed62/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L1500-L1510

UIKit animates the image view's bounds during the rotation, but the mask is a fresh layer already at the final path, so the image is clipped to the final size from the first frame. The mask is applied regardless of whether the view has a border radius at all.

The same bug reaches libraries that host a UIImageView in a clipping view. It was first reported against expo-image in expo/expo#54040, where the mask that React Native installs on SDAnimatedImageView produces the same gap. A fix on the expo-image side only works around it for that library; <Image> itself and any other UIImageView child are still affected.

Steps to reproduce

  1. Clone https://github.com/dileepapeiris/react-native-image-rotation-mask-repro and run yarn and yarn ios in ReproducerApp.
  2. In the simulator, turn on Device > Slow Animations so the 0.4 s rotation becomes about 3 s.
  3. Rotate to landscape (Cmd+Right), then back to portrait (Cmd+Left).
  4. Watch the "Image, resizeMode cover" row during the rotation to portrait: each image is clipped to its narrow portrait width immediately and the green item background is visible on the right until the animation finishes. The "View (control)" row, which contains a plain view instead of an image, resizes smoothly.

React Native Version

0.88.1

Affected Platforms

Runtime - iOS

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

System:
  OS: macOS 27.2
  CPU: (10) arm64 Apple M5
  Memory: 88.34 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.23.5
    path: /opt/homebrew/opt/node@22/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.9
    path: /opt/homebrew/opt/node@22/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.17.0
    path: /opt/homebrew/bin/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.9437.185.2621.16467767
  Xcode:
    version: 27.2/27B52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.20.1
    path: /usr/bin/javac
  Ruby:
    version: 4.0.9
    path: /opt/homebrew/bin/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 rendering glitch during the rotation animation; see the recording below.

MANDATORY Reproducer

https://github.com/dileepapeiris/react-native-image-rotation-mask-repro

Screenshots and Videos

All recordings use the simulator's Slow Animations, so the 0.4 s rotation takes about 3.3 s. iPhone 17 Pro simulator, iOS 26.5.

0.2 s into the rotation from landscape to portrait, turned upright. The image row is already clipped to its portrait width while the green items are still wide; the control row resizes with its items:

0.2 s into the rotation to portrait

One frame every 0.5 s of the same rotation:

Frames of the rotation to portrait

Slow-motion rotation to portrait

Full recording: landscape-to-portrait-slow.mp4.

I have a fix that reuses the installed mask layer and copies the bounds.size animation UIKit puts on the image view's layer onto the mask path, verified with the same reproducer built against React Native from source (before and after). I will open a pull request for it.

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