如何在保持UI响应的同时以可接受的性能记录屏幕? [英] How Can I Record the Screen with Acceptable Performance While Keeping the UI Responsive?

查看:67
本文介绍了如何在保持UI响应的同时以可接受的性能记录屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找基于Objective-C的iOS应用中性能问题的帮助。

I'm looking for help with a performance issue in an Objective-C based iOS app.

我有一个iOS应用程序,使用CALayer的renderInContext捕获屏幕内容方法。它尝试捕获足够的屏幕帧以使用AVFoundation创建视频。然后将屏幕记录与其他元素组合以用于可用性的研究目的。在捕获屏幕时,应用程序也可能正在显示UIWebView的内容,通过网络外出以获取数据等...... Web视图的内容不在我的控制之下 - 它是来自的任意内容Web。

I have an iOS application that captures the screen's contents using CALayer's renderInContext method. It attempts to capture enough screen frames to create a video using AVFoundation. The screen recording is then combined with other elements for research purposes on usability. While the screen is being captured, the app may also be displaying the contents of a UIWebView, going out over the network to fetch data, etc... The content of the Web view is not under my control - it is arbitrary content from the Web.

这个设置正在运行,但正如您可能想象的那样,它并非如此流畅。由于图层必须在主线程上呈现,因此UI争用比我想要的多。我想要做的是设置一个设置,其中UI的响应性优先于屏幕捕获。例如,如果用户正在滚动Web视图,我宁愿在录制中删除帧而不是可怕的滚动体验。

This setup is working but as you might imagine, it's not buttery smooth. Since the layer must be rendered on the main thread, there's more UI contention than I'd like. What I'd like to do is to have a setup where the responsiveness of the UI is prioritized over the screen capture. For instance, if the user is scrolling the Web view, I'd rather drop frames on the recording than have a terrible scrolling experience.

我已经尝试了几种技术,从dispatch_source合并到将帧捕获请求作为块提交到主队列到CADisplayLink。到目前为止,他们似乎都表现得差不多。帧捕获当前是在屏幕主视图的drawRect中触发的。

I've experimented with several techniques, from dispatch_source coalescing to submitting the frame capture requests as blocks to the main queue to CADisplayLink. So far they all seem to perform about the same. The frame capture is currently being triggered in the drawRect of the screen's main view.

我在这里问的是:鉴于上述情况,你会建议我尝试哪些技巧实现我的目标?我意识到答案可能是没有很好的答案......但是我想尝试任何事情,不过听起来很古怪。

What I'm asking here is: given the above, what techniques would you suggest I try to achieve my goals? I realize the answer may be that there is no great answer... but I'd like to try anything, however wacky it might sound.

注意:无论需要什么技术成为App Store友好的。不能使用显示记录器使用/使用的CoreSurface hack。

NOTE: Whatever techniques need to be App Store friendly. Can't use something like the CoreSurface hack that Display Recorder used/uses.

感谢您的帮助!

推荐答案

由于图层必须在主线程上呈现这不是真的,只要你不触及UIKit即可。

"Since the layer must be rendered on the main thread" this is not true, as long as you don't touch UIKit.

请参阅 https://stackoverflow.com/a/12844171/136305

这篇关于如何在保持UI响应的同时以可接受的性能记录屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆