简体   繁体   English

从存档构建时,CADisplayLink会断断续续

[英]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? 有什么输入吗?

EDIT 1: 编辑1:

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.

相关问题 从运行循环中删除CADisplayLink时,游戏有时会崩溃 - Game sometimes crashes when removing CADisplayLink from run loop 滚动时的CollectionView抽动/停顿 - CollectionView Jerks/Stutters When Scrolling 如何防止UIAnimation干扰CADisplayLink - How to prevent UIAnimation from interfering with CADisplayLink 在移动设备上,滚动表单时页面会挂起/结结 - On mobile, page hangs / stutters when scrolling form 执行存档时引用的OBJC类 - OBJC Class referenced from when doing an Archive 确切地说,当控制器消失时,你是否必须使()CADisplayLink无效? - Definitively, do you have to invalidate() a CADisplayLink when the controller disappears? CADisplayLink因为remove(from:forMode :)而不是取消分配视图控制器 - CADisplayLink because of remove(from:forMode:) not deallocating view controller 从远程URL添加图像后,TableView滚动停顿 - TableView scrolling stutters after adding images from remote URL DispatchQueue 中的 CADisplayLink - CADisplayLink in a DispatchQueue 仅“仅构建活动体系结构”时出现“ Cordova链接器错误”“不是为要链接的体系结构构建的用于存档的文件(i386)” - Cordova linker error when Build Active Architecture Only is No “file was built for archive which is not the architecture being linked (i386)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM