Feature/zpf (#564)

* iOS: fix memory leak of blur effect

* js: fix callback cause memory leak
This commit is contained in:
osborn
2022-12-20 15:06:46 +08:00
committed by GitHub
parent c60754c53d
commit be4fb05f91
13 changed files with 77 additions and 22 deletions

View File

@@ -29,10 +29,12 @@ @interface DoricBlurEffectView : UIVisualEffectView
@implementation DoricBlurEffectView
- (instancetype)initWithEffect:(UIVisualEffect *)effect {
if (self = [super initWithEffect:effect]) {
__weak typeof(self) weakSelf = self;
_animator = [[UIViewPropertyAnimator alloc]
initWithDuration:1
curve:UIViewAnimationCurveLinear
animations:^{
__strong typeof(weakSelf) self = weakSelf;
self.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
}];
_animator.fractionComplete = MIN(1, MAX(0, 15.0f / 200));
@@ -52,9 +54,6 @@ - (void)setRadius:(NSUInteger)radius {
self.animator.fractionComplete = MIN(1, MAX(0, (radius / 200.f)));
}
- (void)dealloc {
[self.animator stopAnimation:YES];
}
@end
@interface DoricBlurEffectViewNode ()
@@ -90,4 +89,8 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
[super blendView:view forPropName:name propValue:prop];
}
}
- (void)dealloc {
[self.visualEffectView.animator stopAnimation:YES];
};
@end