diff --git a/iOS/lynx/app/application_info.mm b/iOS/lynx/app/application_info.mm index 2290ae4e..83413c5b 100644 --- a/iOS/lynx/app/application_info.mm +++ b/iOS/lynx/app/application_info.mm @@ -12,7 +12,7 @@ @implementation LynxApplicationInfo - (id) initWithManifest:(NSDictionary*)manifest { self = [super init]; if(self) { - _debugable = [manifest objectForKey:@"debug"]; + _debugable = [[manifest objectForKey:@"debug"] boolValue]; NSDictionary* appInfo = [manifest objectForKey:@"application"]; _packageName = [appInfo objectForKey:@"packageName"]; _mainPage = [[appInfo objectForKey:@"mainPage"] stringByDeletingPathExtension]; diff --git a/iOS/lynx/base/framerate_controller.mm b/iOS/lynx/base/framerate_controller.mm index d91c416b..53786160 100644 --- a/iOS/lynx/base/framerate_controller.mm +++ b/iOS/lynx/base/framerate_controller.mm @@ -2,6 +2,52 @@ #include "base/framerate_controller.h" +@interface LynxWeakProxy : NSProxy + +@property (weak, nonatomic) id target; + ++ (LynxWeakProxy*)weakProxyWithTarget:(id)target; + +@end + +@implementation LynxWeakProxy + ++ (LynxWeakProxy*)weakProxyWithTarget:(id)target +{ + LynxWeakProxy* proxy = [LynxWeakProxy alloc]; + proxy.target = target; + return proxy; +} + +- (BOOL)respondsToSelector:(SEL)sel +{ + return [_target respondsToSelector:sel]; +} + +- (id)forwardingTargetForSelector:(SEL)sel +{ + return _target; +} + +- (void)forwardInvocation:(NSInvocation *)invocation { + [invocation invokeWithTarget:self.target]; +} + +- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { + NSMethodSignature *sig; + sig = [self.target methodSignatureForSelector:aSelector]; + return sig; +} + +@end + + + +@interface LynxFrameRateController () + +@property (nonatomic, strong) LynxWeakProxy * proxyTarget; + +@end @implementation LynxFrameRateController @@ -9,8 +55,10 @@ -(instancetype)initWithVSyncListener:(RenderTreeHostImplBridge *)vsync_listener { self = [super init]; if (self) { - _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onVSync)]; + _proxyTarget = [LynxWeakProxy weakProxyWithTarget:self]; + _displayLink = [CADisplayLink displayLinkWithTarget:_proxyTarget selector:@selector(onVSync)]; _vsync_listener = vsync_listener; + [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } return self; } @@ -18,13 +66,11 @@ -(instancetype)initWithVSyncListener:(RenderTreeHostImplBridge *)vsync_listener -(void)start { _displayLink.paused = NO; - [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } -(void)stop { _displayLink.paused = YES; - [_displayLink removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } -(void)onVSync @@ -34,4 +80,10 @@ -(void)onVSync _displayLink.paused = NO; } +-(void)dealloc +{ + [_displayLink invalidate]; + _displayLink = nil; +} + @end