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

Deterministic onLayout event ordering for iOS Paper #40748

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
*/
@property (nonatomic, assign) YGDirection baseDirection;

- (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews;
- (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
}
}

- (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews
- (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews
{
NSHashTable<NSString *> *other = [NSHashTable new];

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
{
RCTAssertUIManagerQueue();

NSHashTable<RCTShadowView *> *affectedShadowViews = [NSHashTable weakObjectsHashTable];
NSPointerArray *affectedShadowViews = [NSPointerArray weakObjectsPointerArray];
[rootShadowView layoutWithAffectedShadowViews:affectedShadowViews];

if (!affectedShadowViews.count) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Views/RCTLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;

struct RCTLayoutContext {
CGPoint absolutePosition;
__unsafe_unretained NSHashTable<RCTShadowView *> *_Nonnull affectedShadowViews;
__unsafe_unretained NSPointerArray *_Nonnull affectedShadowViews;
__unsafe_unretained NSHashTable<NSString *> *_Nonnull other;
};
typedef struct CG_BOXABLE RCTLayoutContext RCTLayoutContext;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Views/RCTRootShadowView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
*/
@property (nonatomic, assign) YGDirection baseDirection;

- (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews;
- (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews;

@end
2 changes: 1 addition & 1 deletion packages/react-native/React/Views/RCTRootShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (instancetype)init
return self;
}

- (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews
- (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews
{
NSHashTable<NSString *> *other = [NSHashTable new];

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/Views/RCTShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ - (void)layoutWithMetrics:(RCTLayoutMetrics)layoutMetrics layoutContext:(RCTLayo
{
if (!RCTLayoutMetricsEqualToLayoutMetrics(self.layoutMetrics, layoutMetrics)) {
self.layoutMetrics = layoutMetrics;
[layoutContext.affectedShadowViews addObject:self];
[layoutContext.affectedShadowViews addPointer:((__bridge void *)self)];
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rn-tester/RNTesterUnitTests/RCTShadowViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ - (void)testApplyingLayoutRecursivelyToShadowView
[self.parentView insertReactSubview:mainView atIndex:1];
[self.parentView insertReactSubview:footerView atIndex:2];

[self.parentView layoutWithAffectedShadowViews:[NSHashTable weakObjectsHashTable]];
[self.parentView layoutWithAffectedShadowViews:[NSPointerArray weakObjectsPointerArray]];

XCTAssertTrue(
CGRectEqualToRect([self.parentView measureLayoutRelativeToAncestor:self.parentView], CGRectMake(0, 0, 440, 440)));
Expand Down Expand Up @@ -187,7 +187,7 @@ - (void)_withShadowViewWithStyle:(void (^)(YGNodeRef node))configBlock
RCTShadowView *view = [self _shadowViewWithConfig:configBlock];
[self.parentView insertReactSubview:view atIndex:0];
view.intrinsicContentSize = contentSize;
[self.parentView layoutWithAffectedShadowViews:[NSHashTable weakObjectsHashTable]];
[self.parentView layoutWithAffectedShadowViews:[NSPointerArray weakObjectsPointerArray]];
CGRect actualRect = [view measureLayoutRelativeToAncestor:self.parentView];
XCTAssertTrue(
CGRectEqualToRect(expectedRect, actualRect),
Expand Down