libpag
libpag copied to clipboard
iOS libpag 使用libpag开屏动画,第一次安装系统弹权限弹窗导致开屏动画不播放
问的不是弹不弹窗的问题,而是弹窗之后PAG动画不播放;
系统层级弹窗会使 App ResignActive;导致 GLDevice 返回的是 nullptr;这块儿能否改为监听 UIApplicationDidEnterBackgroundNotification 和 UIApplicationWillEnterForegroundNotification ?
static bool RegisterNotifications() {
[[NSNotificationCenter defaultCenter] addObserver:[PAGAppMonitor class]
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:[PAGAppMonitor class]
selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
return true;
}
std::shared_ptr<GLDevice> GLDevice::Current() {
if (appInBackground) {
return nullptr;
}
return EAGLDevice::Wrap([EAGLContext currentContext], true);
}
std::shared_ptr<GLDevice> GLDevice::Make(void* sharedContext) {
if (appInBackground) {
return nullptr;
}
EAGLContext* eaglContext = nil;
EAGLContext* eaglShareContext = reinterpret_cast<EAGLContext*>(sharedContext);
if (eaglShareContext != nil) {
eaglContext = [[EAGLContext alloc] initWithAPI:[eaglShareContext API]
sharegroup:[eaglShareContext sharegroup]];
} else {
eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
if (eaglContext == nil) {
eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
}
}
if (eaglContext == nil) {
return nullptr;
}
auto device = EAGLDevice::Wrap(eaglContext, false);
[eaglContext release];
return device;
}
Which Version of libpag are you using?
libpag 4.2.88
What Platform are you on?
iOS 12, Android 10, macOS 10.15.3, Chrome 87.0 ...
Expected Behavior
Actual Behavior
Code Example
PAG File
这个没法这么改,因为只有在UIApplicationWillResignActiveNotification时监听才有机会把还没刷新的GL命令提交到GPU,如果UIApplicationDidEnterBackgroundNotification的时候已经来不及了,再执行任何glFinish指令会导致crash。这也是苹果官网推荐的兼容处理方式。