Skip to content

[iOS] Animate the image view clipping mask along with the view bounds - #60253

Open
dileepapeiris wants to merge 1 commit into
react:mainfrom
dileepapeiris:fix/ios-image-view-mask-animation
Open

dileepapeiris wants to merge 1 commit into
react:mainfrom
dileepapeiris:fix/ios-image-view-mask-animation

Conversation

@dileepapeiris

Copy link
Copy Markdown

Summary:

When a view clips its content, RCTViewComponentView.invalidateLayer puts a CAShapeLayer mask on every UIImageView subview so the image follows the border radius. The mask is a fresh layer whose path is the image view's bounds at layout time. When the layout change is animated by UIKit, for example during a device rotation, the image view's bounds animate but the mask is already at the final size, so the image is clipped to its final size on the first frame while the view is still animating.

This is visible with <Image> directly and with any library that hosts a UIImageView in a clipping view (expo/expo#54040 is the same bug through expo-image).

This change reuses the mask layer that is already installed and, when UIKit has added a bounds.size animation to the image view's layer, copies that animation onto the mask's path so the mask follows the view with the same timing.

Fixes #60252.

Changelog:

[IOS] [FIXED] - Image views in clipping views are no longer clipped to their final size while a layout animation, such as a rotation, is in progress

Test Plan:

Reproducer: https://github.com/dileepapeiris/react-native-image-rotation-mask-repro (community reproducer template, React Native 0.88.1). The screen has a row of three <Image resizeMode="cover"> inside green overflow: 'hidden' items, and a control row with plain views. Rotate the simulator from landscape to portrait with Slow Animations on.

Before: the image rows show the green item background on the right for the whole rotation, because the image is already clipped to its portrait width. After: the image fills its item through the whole animation. The control row is unchanged.

Portrait and landscape at rest render identically before and after.

Before and after frames, 0.2 s into the rotation, iPhone 17 Pro simulator, iOS 26.5:

Before and after, 0.2 s into the rotation to portrait

@meta-cla

meta-cla Bot commented Nov 24, 2026

Copy link
Copy Markdown

Hi @dileepapeiris!

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 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 24, 2026
@meta-cla

meta-cla Bot commented Nov 24, 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!

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant