Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): fix an endless loop when updating rootView's frame #3579

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading