Skip to content

Commit

Permalink
fix(ios): a rare multithreaded race crash when getting imageProviders
Browse files Browse the repository at this point in the history
only when user use a custom HippyImageViewCustomLoader and do completion callback in subthread
  • Loading branch information
wwwcg committed Feb 28, 2024
1 parent b0fed38 commit c04affe
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ios/sdk/base/HippyBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,16 @@ - (HippyNextAnimationModule *)animationModule {
}

- (NSSet<Class<HippyImageProviderProtocol>> *)imageProviders {
if (!_imageProviders) {
NSMutableSet *set = [NSMutableSet setWithCapacity:8];
for (Class moduleClass in self.moduleClasses) {
if ([moduleClass conformsToProtocol:@protocol(HippyImageProviderProtocol)]) {
[set addObject:moduleClass];
@synchronized (self) {
if (!_imageProviders) {
NSMutableSet *set = [NSMutableSet set];
for (Class moduleClass in self.moduleClasses) {
if ([moduleClass conformsToProtocol:@protocol(HippyImageProviderProtocol)]) {
[set addObject:moduleClass];
}
}
_imageProviders = [NSSet setWithSet:set];
}
_imageProviders = [NSSet setWithSet:set];
}
return _imageProviders;
}
Expand Down

0 comments on commit c04affe

Please sign in to comment.