Repository navigation
Description
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
clipsToBoundsis true, even without any border radius, so a plain<Image>is affected through its defaultoverflow: 'hidden'style. - Third-party image components are affected too. Any
RCTViewComponentViewsubclass that clips and has aUIImageViewsubview hits the same loop, e.g. expo-image'sImageView, which setsclipsToBounds = YESitself. Changingoverflowtovisiblelater doesn't help them:clipsToBoundsis updated, but the mask that was already set on the subview is never removed. A fix ininvalidateLayerwould cover all of these. A change limited to<Image>, such as its defaultoverflow, 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
- Clone https://github.com/JasperH8g/rn-image-mask-repro, then
npm installandnpx expo start. - Open it on an iPhone or iPad (New Architecture) and rotate between portrait and landscape.
- 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
Activity
Prerna2024-cyber commentedon Nov 23, 2026
/assign
Prerna2024-cyber commentedon Nov 23, 2026
assign please