Skip to content

[iOS][Fabric] Image is clipped to its final size during the rotation animation (static mask on UIImageView subviews in invalidateLayer) #60231

Open

Description

@JasperH8g

Description

When an image view changes size during an iOS rotation, its visible area jumps straight to the final size instead of animating with the rest of the layout. Growing images are cropped first and then revealed. Shrinking images are cut to the final size immediately, while their parent views are still animating.

During rotation, RCTSurfaceHostingView -layoutSubviews lays out and mounts synchronously inside UIKit's transition animation, so center/bounds changes animate along with the rotation. That part works as intended. The problem is in -[RCTViewComponentView invalidateLayer], which runs after every layout change. When the container clips its content (and enableIOSViewClipToPaddingBox is off, the default), it creates a new, static mask layer for every UIImageView subview:

for (UIView *subview in self.currentContainerView.subviews) {
  if ([subview isKindOfClass:[UIImageView class]]) {
    ...
    subview.layer.mask = [self createMaskLayer:subview.bounds cornerInsets:cornerInsets];
  }
}

subview.bounds already holds the final (model) value, and the new CAShapeLayer mask isn't part of the running animation. The image view's bounds animate from the old size to the new one, but the mask is at the final size from the first frame.

Notes:

  • The loop runs whenever clipsToBounds is true, even without any border radius, so a plain <Image> is affected through its default overflow: 'hidden' style.
  • Third-party image components are affected too. Any RCTViewComponentView subclass that clips and has a UIImageView subview hits the same loop, e.g. expo-image's ImageView, which sets clipsToBounds = YES itself. Changing overflow to visible later doesn't help them: clipsToBounds is updated, but the mask that was already set on the subview is never removed. A fix in invalidateLayer would cover all of these. A change limited to <Image>, such as its default overflow, would not.
  • Setting overflow: 'visible' on a React Native <Image> from the first render avoids the issue, which confirms the mask as the cause.
  • The loop is unchanged on main.

Possible fixes: only apply the subview mask when the border radii are non-zero, since clipsToBounds already clips to the rectangle. Or update/animate the mask together with the subview's bounds.

Steps to reproduce

  1. Clone https://github.com/JasperH8g/rn-image-mask-repro, then npm install and npx expo start.
  2. Open it on an iPhone or iPad (New Architecture) and rotate between portrait and landscape.
  3. During the rotation animation, each image is clipped to its final width while the green item behind it still animates. Slow Animations in the Simulator makes this easy to see.

React Native Version

0.88.1

Affected Platforms

Runtime - iOS

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

System:
  OS: macOS 27.2.1
  CPU: (10) arm64 Apple M2 Pro
Binaries:
  Node: 24.21.0
  Yarn: 1.22.22
  npm: 11.19.0
  Watchman: Not Found
Managers:
  CocoaPods: 1.16.2
SDKs:
  iOS SDK: iOS 27.2
IDEs:
  Xcode: 27.2/27B52
npmPackages:
  "@react-native-community/cli": 20.2.0
  react: 19.3.0
  react-native: 0.88.1
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

N/A: this is a visual issue, there is no crash or log output.

MANDATORY Reproducer

https://github.com/JasperH8g/rn-image-mask-repro

Screenshots and Videos

Screen.Recording.2026-11-23.at.14.35.48.mov

Activity

  1. Prerna2024-cyber commented on Nov 23, 2026

    @Prerna2024-cyber

    /assign

  2. Prerna2024-cyber commented on Nov 23, 2026

    @Prerna2024-cyber

    assign please

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions