diff --git a/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m b/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m index 1c877133..43b2e3b1 100644 --- a/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m +++ b/doric-iOS/Pod/Classes/Performance/DoricPerformanceProfile.m @@ -44,11 +44,23 @@ - (instancetype)initWithName:(NSString *)name { } - (void)addAnchorHook:(id)hook { - [self.hooks addObject:hook]; + __weak typeof(self) _self = self; + dispatch_async(self.anchorQueue, ^{ + __strong typeof(_self) self = _self; + if (!self) return; + + [self.hooks addObject:hook]; + }); } - (void)removeAnchorHook:(id)hook { - [self.hooks removeObject:hook]; + __weak typeof(self) _self = self; + dispatch_async(self.anchorQueue, ^{ + __strong typeof(_self) self = _self; + if (!self) return; + + [self.hooks removeObject:hook]; + }); } - (void)enable:(bool)enable { @@ -95,7 +107,11 @@ - (void)print:(NSString *)anchorName { if (!self.enable) { return; } + __weak typeof(self) _self = self; dispatch_async(self.anchorQueue, ^{ + __strong typeof(_self) self = _self; + if (!self) return; + NSNumber *prepare = self.anchorMap[[self getPrepareAnchor:anchorName]]; NSNumber *start = self.anchorMap[[self getStartAnchor:anchorName]]; NSNumber *end = self.anchorMap[[self getEndAnchor:anchorName]];