Skip to content

Commit

Permalink
fix(ios): fix an endless loop when updating rootView's frame
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Oct 30, 2023
1 parent d8653ca commit 65a5e95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
7 changes: 7 additions & 0 deletions renderer/native/ios/renderer/HippyRootView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ - (void)setFrame:(CGRect)frame {
}
}

- (void)hippySetFrame:(CGRect)frame {
// Override hippySetFrame,
// to prevent an endless loop when synchronizing shadowView's frame to view.
// HippyRootContentView's frame is the source of truth,
// So we do nothing here.
}

#pragma mark - HippyComponent Method

- (void)insertHippySubview:(UIView *)subview atIndex:(NSInteger)atIndex {
Expand Down
17 changes: 0 additions & 17 deletions renderer/native/ios/renderer/component/view/UIView+Hippy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,6 @@ - (void)didUpdateHippySubviews {
}

- (void)hippySetFrame:(CGRect)frame {
// These frames are in terms of anchorPoint = topLeft, but internally the
// views are anchorPoint = center for easier scale and rotation animations.
// Convert the frame so it works with anchorPoint = center.
CGPoint position = { CGRectGetMidX(frame), CGRectGetMidY(frame) };
CGRect bounds = { CGPointZero, frame.size };

// Avoid crashes due to nan coords
if (isnan(position.x) || isnan(position.y) || isnan(bounds.origin.x) || isnan(bounds.origin.y) || isnan(bounds.size.width)
|| isnan(bounds.size.height)) {
HippyLogError(
@"Invalid layout for (%@)%@. position: %@. bounds: %@", self.hippyTag, self, NSStringFromCGPoint(position), NSStringFromCGRect(bounds));
return;
}

// self.center = position;
// self.bounds = bounds;

self.frame = frame;
}

Expand Down

0 comments on commit 65a5e95

Please sign in to comment.