From c5f250e851f83d270a2a406d8a1486e0c2760817 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Thu, 4 Apr 2024 06:42:27 -0700 Subject: [PATCH] Use String as Id instead of integer Summary: Using integers as Id was not a good idea. This is because the size of int on iOS is 64bits is 64bits unsigned long, where as the max safe int in a js is 9007199254740991 What happens whne you send a large int than this is that the number is truncated. Coupled to this NSString hash function is not randomly distributed and share a common prefix, this causes us to get collisions in ids in bloks where share a common client id prefix. To fix we send ids as strings, this allows us to represent numbers of any length at a small performance penalty Reviewed By: lblasa Differential Revision: D55692665 fbshipit-source-id: 2fc0725fbd14adb681a328ca9f5f119a7d088199 --- .../Core/UIDAttributeEditor.h | 2 +- .../Core/UIDAttributeEditor.m | 5 ++-- .../Core/UIDUpdate.h | 2 +- .../Descriptors/UIDDescriptor.h | 2 +- .../Descriptors/UIDNodeDescriptor.h | 2 +- .../Descriptors/UIDNodeDescriptor.m | 4 +-- .../Descriptors/UIView+UIDDescriptor.m | 4 +-- .../Events/UIDFrameScanEvent.h | 2 +- .../Events/UIDInitEvent.h | 2 +- .../Model/UIDFrameworkEvent.h | 2 +- .../Model/UIDNode.h | 8 ++--- .../Model/UIDNode.mm | 2 +- .../Observer/UIDTreeObserverManager.m | 2 +- .../UIDFrameScanEvent+Foundation.m | 2 +- .../UIDFrameworkEvent+Foundation.m | 2 +- .../Serializers/UIDInitEvent+Foundation.m | 2 +- .../Serializers/UIDNode+Foundation.m | 2 +- .../Traversal/UIDAllyTraversal.m | 9 +++--- .../Traversal/UIDHierarchyTraversal.h | 2 +- .../Traversal/UIDHierarchyTraversal.m | 29 ++++++++----------- 20 files changed, 40 insertions(+), 47 deletions(-) diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.h index 7f0e8c9c476..f3417d368a4 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.h @@ -36,7 +36,7 @@ typedef void (^ReportAttributeEditorResult)(NSError* _Nullable); + (instancetype)attributeEditorWithDescriptorRegister: (UIDDescriptorRegister*)descriptorRegister; -- (void)editNodeWithId:(NSNumber*)nodeId +- (void)editNodeWithId:(NSString*)nodeId value:(id)value metadataIdentifiers:(NSArray*)metadataIdentifiers compoundTypeHint:(UIDCompoundTypeHint)compoundTypeHint diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.m index e4c6eb3bc10..ed5c9e287bc 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDAttributeEditor.m @@ -89,7 +89,7 @@ + (instancetype)attributeEditorWithDescriptorRegister: initWithDescriptorRegister:descriptorRegister]; } -- (void)editNodeWithId:(NSNumber*)nodeId +- (void)editNodeWithId:(NSString*)nodeId value:(id)value metadataIdentifiers:(NSArray*)metadataIdentifiers compoundTypeHint:(UIDCompoundTypeHint)compoundTypeHint @@ -106,8 +106,7 @@ - (void)editNodeWithId:(NSNumber*)nodeId return; } - id node = [traversal findWithId:[nodeId unsignedIntegerValue] - inHierarchyWithRoot:root]; + id node = [traversal findWithId:nodeId inHierarchyWithRoot:root]; if (!node) { reportResult( [NSError UID_errorWithType:AttributeEditorErrorTypeNodeNotFound]); diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDUpdate.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDUpdate.h index 95db9c372a4..b8aa298f92d 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDUpdate.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Core/UIDUpdate.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN @interface UIDFrameUpdate : NSObject @property(nonatomic) NSString* observerType; -@property(nonatomic) NSUInteger rootId; +@property(nonatomic) NSString* rootId; @property(nonatomic) NSArray* nodes; @property(nonatomic) NSTimeInterval timestamp; @property(nonatomic) long traversalMS; diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDDescriptor.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDDescriptor.h index daee977fe0c..c6dab52832e 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDDescriptor.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDDescriptor.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN /** A globally unique ID used to identify a node in the hierarchy. */ -- (NSUInteger)UID_identifier; +- (NSString*)UID_identifier; /** The name used to identify this node in the inspector. Does not need to be diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.h index c5374975c00..829288d3053 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN /** A globally unique ID used to identify a node in the hierarchy. */ -- (NSUInteger)identifierForNode:(T)node; +- (NSString*)identifierForNode:(T)node; /** The name used to identify this node in the inspector. Does not need to be diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.m index 3b576ce45cc..57cbea75d91 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIDNodeDescriptor.m @@ -11,8 +11,8 @@ @implementation UIDNodeDescriptor -- (NSUInteger)identifierForNode:(id)node { - return [node hash]; +- (NSString*)identifierForNode:(id)node { + return [NSString stringWithFormat:@"%ld", [node hash]]; } - (NSString*)nameForNode:(id)node { diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIView+UIDDescriptor.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIView+UIDDescriptor.m index 4ecfaff9d68..189f6ec1116 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIView+UIDDescriptor.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Descriptors/UIView+UIDDescriptor.m @@ -73,8 +73,8 @@ FB_LINKABLE(UIView_UIDDescriptor) @implementation UIView (UIDDescriptor) -- (NSUInteger)UID_identifier { - return [self hash]; +- (NSString*)UID_identifier { + return [NSString stringWithFormat:@"%lu", [self hash]]; } - (nonnull NSString*)UID_name { diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDFrameScanEvent.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDFrameScanEvent.h index 058fc3af7c2..40ef64f6b55 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDFrameScanEvent.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDFrameScanEvent.h @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN @interface UIDSnapshotInfo : NSObject -@property(nonatomic) NSUInteger nodeId; +@property(nonatomic) NSString* nodeId; @property(nonatomic, strong) UIImage* image; @end diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDInitEvent.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDInitEvent.h index 423b9f82abb..f4095c9da8a 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDInitEvent.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Events/UIDInitEvent.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @interface UIDInitEvent : NSObject -@property(nonatomic) NSUInteger rootId; +@property(nonatomic) NSString* rootId; @property(nonatomic) UIDTraversalMode currentTraversalMode; @property(nonatomic, strong) NSArray* frameworkEventMetadata; diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDFrameworkEvent.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDFrameworkEvent.h index 33bf447c3ea..44397022785 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDFrameworkEvent.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDFrameworkEvent.h @@ -16,7 +16,7 @@ typedef NSArray* UIDStacktrace; @interface UIDFrameworkEvent : NSObject -@property(nonatomic) NSUInteger nodeIdentifier; +@property(nonatomic) NSString* nodeIdentifier; @property(nonatomic, strong) NSString* type; @property(nonatomic, strong) NSDate* timestamp; @property(nonatomic, strong) UIDEventPayload payload; diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.h index 6f37ac35c64..da4a34e0da2 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @interface UIDNode : NSObject -@property(nonatomic) NSUInteger identifier; +@property(nonatomic) NSString* identifier; @property(nonatomic, strong) NSString* qualifiedName; @property(nonatomic, strong) NSString* name; @property(nonatomic, strong) UIDBounds* bounds; @@ -24,11 +24,11 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong) UIDAttributes* attributes; @property(nonatomic, strong) UIDInlineAttributes* inlineAttributes; @property(nonatomic, strong) UIDGenericAttributes* hiddenAttributes; -@property(nonatomic, nullable) NSNumber* parent; +@property(nonatomic, nullable) NSString* parent; @property(nonatomic, strong) NSArray* children; -@property(nonatomic) NSNumber* activeChild; +@property(nonatomic) NSString* activeChild; -- (instancetype)initWithIdentifier:(NSUInteger)identifier +- (instancetype)initWithIdentifier:(NSString*)identifier qualifiedName:(NSString*)qualifiedName name:(NSString*)name bounds:(UIDBounds*)bounds diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.mm b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.mm index 51c99373c37..9c3e39d2968 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.mm +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Model/UIDNode.mm @@ -11,7 +11,7 @@ @implementation UIDNode -- (instancetype)initWithIdentifier:(NSUInteger)identifier +- (instancetype)initWithIdentifier:(NSString*)identifier qualifiedName:(NSString*)qualifiedName name:(NSString*)name bounds:(UIDBounds*)bounds diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Observer/UIDTreeObserverManager.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Observer/UIDTreeObserverManager.m index 0937c1f6827..d46397aea1f 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Observer/UIDTreeObserverManager.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Observer/UIDTreeObserverManager.m @@ -116,7 +116,7 @@ - (void)startWithContext:(UIDContext*)context { [_context.connection receive:@"editAttribute" withBlock:^(NSDictionary* data, id responder) { - NSNumber* nodeId = [data[@"nodeId"] isKindOfClass:NSNumber.class] + NSString* nodeId = [data[@"nodeId"] isKindOfClass:NSString.class] ? data[@"nodeId"] : nil; if (nodeId == nil) { diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameScanEvent+Foundation.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameScanEvent+Foundation.m index aae4a409363..99e7b154fae 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameScanEvent+Foundation.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameScanEvent+Foundation.m @@ -16,7 +16,7 @@ @implementation UIDSnapshotInfo (Foundation) - (id)toFoundation { return @{ - @"nodeId" : [NSNumber numberWithInteger:self.nodeId], + @"nodeId" : self.nodeId, @"data" : self.image ? [self.image toFoundation] : @"", }; } diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameworkEvent+Foundation.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameworkEvent+Foundation.m index cf23f7fdefd..bdd92380fd8 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameworkEvent+Foundation.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDFrameworkEvent+Foundation.m @@ -14,7 +14,7 @@ @implementation UIDFrameworkEvent (Foundation) - (id)toFoundation { NSMutableDictionary* data = [NSMutableDictionary dictionaryWithDictionary:@{ - @"nodeId" : [NSNumber numberWithUnsignedInteger:self.nodeIdentifier], + @"nodeId" : self.nodeIdentifier, @"type" : self.type, @"timestamp" : [NSNumber numberWithDouble:self.timestamp.timeIntervalSince1970], diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDInitEvent+Foundation.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDInitEvent+Foundation.m index 18afb9658e3..1c06f3d877b 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDInitEvent+Foundation.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDInitEvent+Foundation.m @@ -17,7 +17,7 @@ @implementation UIDInitEvent (Foundation) - (id)toFoundation { return @{ - @"rootId" : [NSNumber numberWithUnsignedInteger:self.rootId], + @"rootId" : self.rootId, @"frameworkEventMetadata" : self.frameworkEventMetadata ? [self.frameworkEventMetadata toFoundation] : @[], diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDNode+Foundation.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDNode+Foundation.m index 90e0f1cdeaf..fe33f09fdb4 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDNode+Foundation.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Serializers/UIDNode+Foundation.m @@ -16,7 +16,7 @@ @implementation UIDNode (Foundation) - (id)toFoundation { NSMutableDictionary* data = [NSMutableDictionary dictionaryWithDictionary:@{ - @"id" : [NSNumber numberWithUnsignedInteger:self.identifier], + @"id" : self.identifier, @"qualifiedName" : self.qualifiedName ?: @"", @"name" : self.name, @"bounds" : [self.bounds toFoundation], diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDAllyTraversal.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDAllyTraversal.m index 65cafc9726b..3bec7d6fa8b 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDAllyTraversal.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDAllyTraversal.m @@ -71,16 +71,15 @@ - (instancetype)initWithDescriptorRegister: _accessibilityLeafDescendantsWithOptions:options] mutableCopy]; UIDNode* rootNode = [self _uidNodeForNode:root]; - NSInteger rootIdentifier = rootNode.identifier; + NSString* rootIdentifier = rootNode.identifier; NSMutableArray* nodes = [NSMutableArray new]; NSMutableArray* childrenIds = [NSMutableArray new]; for (NSObject* node in allyNodes) { UIDNode* uidNode = [self _uidNodeForNode:node]; - uidNode.parent = @(rootIdentifier); + uidNode.parent = rootIdentifier; [nodes addObject:uidNode]; - [childrenIds - addObject:[NSNumber numberWithUnsignedInteger:uidNode.identifier]]; + [childrenIds addObject:uidNode.identifier]; } rootNode.children = childrenIds; [nodes insertObject:rootNode atIndex:0]; @@ -90,7 +89,7 @@ - (instancetype)initWithDescriptorRegister: - (UIDNode*)_uidNodeForNode:(NSObject*)node { UIDNodeDescriptor* descriptor = [_descriptorRegister descriptorForClass:[node class]]; - NSUInteger nodeIdentifier = [descriptor identifierForNode:node]; + NSString* nodeIdentifier = [descriptor identifierForNode:node]; UIDNode* uidNode = [[UIDNode alloc] initWithIdentifier:nodeIdentifier qualifiedName:[descriptor nameForNode:node] diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.h b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.h index 9ef12854d85..7e25b9feb94 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.h +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.h @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSArray*)traverse:(id)root; -- (id)findWithId:(NSUInteger)nodeId inHierarchyWithRoot:(id)root; +- (id)findWithId:(NSString*)nodeId inHierarchyWithRoot:(id)root; @end diff --git a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.m b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.m index 034294328ac..2a1cd359c7f 100644 --- a/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.m +++ b/iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Traversal/UIDHierarchyTraversal.m @@ -13,11 +13,11 @@ @interface UIDTransientNode : NSObject @property(nonatomic) id node; -@property(nonatomic, nullable) NSNumber* parent; +@property(nonatomic, nullable) NSString* parent; @property(nonatomic) BOOL shallow; - (instancetype)initWithNode:(id)node; -- (instancetype)initWithNode:(id)node parent:(NSNumber*)parent; +- (instancetype)initWithNode:(id)node parent:(NSString*)parent; @end @@ -27,7 +27,7 @@ - (instancetype)initWithNode:(id)node { return [self initWithNode:node parent:nil]; } -- (instancetype)initWithNode:(id)node parent:(NSNumber*)parent { +- (instancetype)initWithNode:(id)node parent:(NSString*)parent { if (self = [super init]) { _node = node; _parent = parent; @@ -74,7 +74,7 @@ + (instancetype)createWithDescriptorRegister: UIDNodeDescriptor* descriptor = [self.descriptorRegister descriptorForClass:[node class]]; - NSUInteger nodeIdentifier = [descriptor identifierForNode:node]; + NSString* nodeIdentifier = [descriptor identifierForNode:node]; UIDNode* uidNode = [[UIDNode alloc] initWithIdentifier:nodeIdentifier @@ -96,13 +96,11 @@ + (instancetype)createWithDescriptorRegister: NSArray* children = [descriptor childrenOfNode:node]; id activeChild = [descriptor activeChildForNode:node]; - NSNumber* activeChildId = nil; + NSString* activeChildId = nil; if (activeChild != nil) { UIDNodeDescriptor* activeChildDescriptor = [self.descriptorRegister descriptorForClass:[activeChild class]]; - NSUInteger childId = - [activeChildDescriptor identifierForNode:activeChild]; - activeChildId = [NSNumber numberWithUnsignedInteger:childId]; + activeChildId = [activeChildDescriptor identifierForNode:activeChild]; } NSMutableArray* childrenIds = [NSMutableArray new]; @@ -110,13 +108,10 @@ + (instancetype)createWithDescriptorRegister: UIDNodeDescriptor* childDescriptor = [self.descriptorRegister descriptorForClass:[child class]]; assert(childDescriptor != nil); - [childrenIds - addObject:[NSNumber numberWithUnsignedInteger: - [childDescriptor identifierForNode:child]]]; + [childrenIds addObject:[childDescriptor identifierForNode:child]]; - UIDTransientNode* transientChildNode = [[UIDTransientNode alloc] - initWithNode:child - parent:[NSNumber numberWithUnsignedInteger:nodeIdentifier]]; + UIDTransientNode* transientChildNode = + [[UIDTransientNode alloc] initWithNode:child parent:nodeIdentifier]; // This is a child which is not active, so mark it as to not // traverse its children. @@ -136,7 +131,7 @@ + (instancetype)createWithDescriptorRegister: return nodes; } -- (id)findWithId:(NSUInteger)nodeId inHierarchyWithRoot:(id)root { +- (id)findWithId:(NSString*)nodeId inHierarchyWithRoot:(id)root { if (root == nil) { return nil; } @@ -151,9 +146,9 @@ + (instancetype)createWithDescriptorRegister: UIDNodeDescriptor* descriptor = [self.descriptorRegister descriptorForClass:[node class]]; - NSUInteger nodeIdentifier = [descriptor identifierForNode:node]; + NSString* nodeIdentifier = [descriptor identifierForNode:node]; - if (nodeIdentifier == nodeId) { + if ([nodeIdentifier isEqualToString:nodeId]) { return node; }