如何解决CAEAGLLayer 添加到自定义 UIWindow 导致 iOS13
我正在做一个视频项目,使用 openGL 进行绘制。 我想在视频全屏时将视频的视图添加到一个新的水平UIWindow,然后在返回半屏时返回到原始UIWindow。
UIViewController *landscapeVC = [[UIViewController alloc] init];
UIWindow *landscapeWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
landscapeWindow.windowLevel = 1000;
landscapeWindow.hidden = NO;
landscapeWindow.rootViewController = landscapeVC;
[landscapeWindow addSubview: _playerView];
[UIView animateWithDuration:[CATransaction animationDuration] animations:^{
self.playerView.frame = landscapeWindow.bounds;
}];
但是这个时候我发现每次旋转,内存都会上升,不会回落。
我使用 XCode 工具进行内存调试,但 Allocations 显示视频每次返回半屏时都会回退。
我尝试让App回到后台,内存也会被释放。
我排除了代码的内存泄漏。还发现 CAEAGLLayer 对象似乎与 UIWindow 有某种关系。
@interface CAEAGLLayer : CALayer <EAGLDrawable>
{
@private
struct _CAEAGLNativeWindow *_win;
}
以及IOSurface在创建时调用的native_window_begin_iosurface()函数。
有谁知道这个原理。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。