Skip to content

Commit 1c2aa2e

Browse files
hryhoriiK97claude
andcommitted
Skip layer invalidation when an iOS View only changes opacity
An opacity change set `needsInvalidateLayer`, so `finalizeUpdates:` ran the whole `invalidateLayer`: shadow path, borders, and the background, box-shadow, outline and mask layers. `invalidateLayer` reads the opacity only to combine it with `filter`, and the new opacity is already applied to the layer in `updateProps:`, so the invalidation is now requested only when the view has a filter. Native-driver and Reanimated opacity animations update every animated view on every frame, so each styled view paid the full invalidation per frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 96dddb0 commit 1c2aa2e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,10 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
355355
if (oldViewProps.opacity != newViewProps.opacity &&
356356
![_propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN containsObject:@"opacity"]) {
357357
self.layer.opacity = (float)newViewProps.opacity;
358-
needsInvalidateLayer = YES;
358+
// `invalidateLayer` only reads the opacity to combine it with `filter`.
359+
if (!newViewProps.filter.empty()) {
360+
needsInvalidateLayer = YES;
361+
}
359362
}
360363

361364
// Disable `removeClippedSubviews` when Fabric View Culling is enabled.

0 commit comments

Comments
 (0)