IOS使用异步加载资源时,会阻塞主线程
Open
@kevingpqi123 is already working on this.
Since Jun 23, 2025.
- Dominant language
- HTML
- Stars
- 5.8k
- Forks
- 531
- Avg merge
- 8d 55m
- Merged PRs (30d)
- 17
Description
【版本信息】
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];
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.