未验证 提交 fd9a079a 编写于 作者: W Wu Zhong 提交者: GitHub

[iOS] Fixes DisplayLinkManager leaks (#22194)

上级 5cf3eaed
......@@ -635,7 +635,7 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
}
- (void)initializeDisplays {
double refresh_rate = [[[DisplayLinkManager alloc] init] displayRefreshRate];
double refresh_rate = [DisplayLinkManager displayRefreshRate];
auto display = flutter::Display(refresh_rate);
_shell->OnDisplayUpdates(flutter::DisplayUpdateType::kStartup, {display});
}
......
......@@ -12,8 +12,6 @@
@interface DisplayLinkManager : NSObject
- (instancetype)init;
//------------------------------------------------------------------------------
/// @brief The display refresh rate used for reporting purposes. The engine does not care
/// about this for frame scheduling. It is only used by tools for instrumentation. The
......@@ -23,7 +21,7 @@
///
/// @return The refresh rate in frames per second.
///
- (double)displayRefreshRate;
+ (double)displayRefreshRate;
@end
......
......@@ -91,26 +91,16 @@ void VsyncWaiterIOS::AwaitVSync() {
@end
@implementation DisplayLinkManager {
fml::scoped_nsobject<CADisplayLink> display_link_;
}
- (instancetype)init {
self = [super init];
if (self) {
display_link_ = fml::scoped_nsobject<CADisplayLink> {
[[CADisplayLink displayLinkWithTarget:self selector:@selector(onDisplayLink:)] retain]
};
display_link_.get().paused = YES;
}
@implementation DisplayLinkManager
return self;
}
- (double)displayRefreshRate {
+ (double)displayRefreshRate {
if (@available(iOS 10.3, *)) {
auto preferredFPS = display_link_.get().preferredFramesPerSecond; // iOS 10.0
fml::scoped_nsobject<CADisplayLink> display_link = fml::scoped_nsobject<CADisplayLink> {
[[CADisplayLink displayLinkWithTarget:[[DisplayLinkManager new] autorelease]
selector:@selector(onDisplayLink:)] retain]
};
display_link.get().paused = YES;
auto preferredFPS = display_link.get().preferredFramesPerSecond; // iOS 10.0
// From Docs:
// The default value for preferredFramesPerSecond is 0. When this value is 0, the preferred
......@@ -131,10 +121,4 @@ void VsyncWaiterIOS::AwaitVSync() {
// no-op.
}
- (void)dealloc {
[display_link_.get() invalidate];
[super dealloc];
}
@end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册