Skip to content

Commit

Permalink
fix: iOS memory leak when recreate canvas #42
Browse files Browse the repository at this point in the history
  • Loading branch information
flyskywhy committed May 28, 2022
1 parent 87befe4 commit a65d12a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ios/BridgeModule/GCanvasModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ typedef void (^GCanvasModuleCallback)(id result);
*/
- (NSString*)enable:(NSDictionary *)args;

- (void)disable:(NSString*)componentId;

#pragma mark - Export Method of Context2D
/**
* Export JS method for reset GCanvas component while disappear
Expand Down
8 changes: 8 additions & 0 deletions ios/BridgeModule/GCanvasModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ - (NSString*)enable:(NSDictionary *)args{
return @"true";
}

- (void)disable:(NSString*)componentId{
GCVLOG_METHOD(@"disable:, componentId=%@", componentId);

[[NSNotificationCenter defaultCenter] postNotificationName:kGCanvasDestroyNotification
object:nil
userInfo:@{@"instanceId":[self.deletage gcanvasModuleInstanceId]}];
}

#pragma mark - Need Export Context2D Method
/**
* Export JS method for reset GCanvas component while disappear
Expand Down
1 change: 1 addition & 0 deletions ios/RCTGCanvasModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ - (dispatch_queue_t)methodQueue

RCT_EXPORT_METHOD(disable:(NSString*) componentId)
{
[self.gcanvasModule disable:componentId];
}

//preload image
Expand Down

0 comments on commit a65d12a

Please sign in to comment.