[英]CADisplayLink stutters when built from archive
I have project that is rendering video playback and applying CIFilters to it. 我有一个项目,正在渲染视频播放和应用CIFilters。 I know that I can use video composition to get video with filters, but problems is that filters needs to be swipeable (with preview of next filter so we're using mask for 1st imageview and filtering 2nd one with next filter).
我知道我可以使用视频合成来获取带过滤器的视频,但问题是过滤器需要可以刷卡(预览下一个过滤器,因此我们使用第一个图像视图的掩码并使用下一个过滤器过滤第二个)。
func displayLinkDidRefresh(link: CADisplayLink){
let itemTime = videoOutput.itemTime(forHostTime: CACurrentMediaTime())
if videoOutput.hasNewPixelBuffer(forItemTime: itemTime) {
if let pixelBuffer = videoOutput.copyPixelBuffer(forItemTime: itemTime, itemTimeForDisplay: nil){
unfilteredImage = CIImage(cvImageBuffer: pixelBuffer)
displayFilteredImage(unfilteredImage: unfilteredImage)
}
}
}
This is the code used to create AVPlayer instance and CADisplayLink: 这是用于创建AVPlayer实例和CADisplayLink的代码:
player = AVPlayer(playerItem: item)
player.isMuted = true
displayLink = CADisplayLink(target: self, selector: #selector(displayLinkDidRefresh(link:)))
displayLink!.preferredFramesPerSecond = 24
displayLink!.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
NotificationCenter.default.addObserver(self, selector: #selector(self.playerItemDidReachEnd(notification:)), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.player.currentItem)
When running from debugger I experience no stutter (or it is at minimum level), but when running build from archive it is stuttering a lot. 当从调试器运行时,我没有遇到任何口吃(或者它处于最低级别),但是当从归档运行构建时,它很多都是口吃。 What I do to test is deleting app from phone and then instal it on the phone and test, as said debug builds are fine, but archive are creating issues.
我要测试的是从手机中删除应用程序,然后将其安装在手机上并进行测试,因为所述调试版本很好,但存档会产生问题。 Any input on this?
有什么输入吗?
Managed to get it to work better, but still stuttering after attaching video composition to player item when item and player status is readyToPlay. 管理以使其更好地工作,但在项目和玩家状态为readyToPlay时将视频合成附加到玩家项目后仍然是口吃。
After some time playing with this I found the issue, nothing is wrong with the code. 经过一段时间玩这个我发现了问题,代码没有任何问题。 Issue was that we have Appsee analytics inside app and we needed to pause it on these screens in order for them to render properly.
问题是我们在app中有Appsee分析,我们需要在这些屏幕上暂停它以便它们正确呈现。 Reason why we didn't experience these issues in debug mode was the AppDelegate if condition that was preventing Appsee to work in debug environment.
我们在调试模式下没有遇到这些问题的原因是AppDelegate if条件阻止了Appsee在调试环境中工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.