libpag icon indicating copy to clipboard operation
libpag copied to clipboard

IOS使用异步加载资源时,会阻塞主线程

Open KitsGithub opened this issue 1 year ago • 1 comments

【版本信息】

4.3.62

【平台信息】

iOS 原生

【预期的表现】

正常无卡顿现象

【实际的情况】

异步加载网络资源的时候,当PAG文件较大时,先报

file open failed! filePath:/var/mobile/Containers/Data/Application/9F952709-DF20-4478-8F39-33A845534F66/Library/Caches/libpag/files/1.bin 

然后阻塞主线程导致卡顿,等待下载完成后,才可以继续往下

【Demo及附件】

在官方demo中,修改PAGImageViewTableViewController.m:29-36行为以下代码

- (void)setFilePath:(NSString *)filePath {
    if ([filePath length] > 0) {
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
            [self.pagImageView setPathAsync:@"https://cybercharge-admin.s3.ap-southeast-1.amazonaws.com/admin/images/pag_path6853e158d4ff6.pag" completionBlock:^(PAGFile * _Nonnull) {
                [self.pagImageView play];
            }];
        });
        
//        [self.pagImageView setPath:filePath];
        [self.pagImageView setCurrentFrame:0];
        [self.pagImageView setRepeatCount:-1];
//        [self.pagImageView play];
    }
}

KitsGithub avatar Jun 23 '25 04:06 KitsGithub

感谢反馈。4.2 / 4.3 版本系列目前已停止维护,仍在维护的是 4.4 和 4.5 版本。建议先升级到最新版本验证问题是否仍存在;如果升级后问题仍然出现,麻烦在最新版本上补充相关信息(复现素材、截图、机型或具体报错等),我们会进一步排查。

CodeJhF avatar Oct 08 '26 08:10 CodeJhF