如何调试重载背板?

时间:2022-05-06 00:12:18

I have a UIView with several instances of a subclassed CAShapeLayer added as sublayers to its layer property.

我有一个UIView,其子类化CAShapeLayer的几个实例被添加为其图层属性的子图层。

I am animating changes to the UIBezierPath for each of these layers, which looks awesome and is performant, but hits ~90% CPU on the backboardd process when I run it through Activity Monitor in Instruments.

我正在为这些层中的每个层设置UIBezierPath的更改动画,这看起来很棒并且性能很好,但是当我通过Instruments中的Activity Monitor运行它时,会在背板进程上达到~90%的CPU。

How can I get more information about what's happening here? backboardd is the behind-the-scenes rendering of Core Graphics / Core Animation stuff on the GPU, right? Is there support for further debugging in Instruments somewhere? Could I do something fancy with GCD to load backboardd less?

如何获得有关此处发生的更多信息? backboardd是GPU上Core Graphics / Core Animation的幕后渲染,对吗?是否支持在某处进行仪器的进一步调试?我可以用GCD做些喜欢加载背板的东西吗?

EDIT: After escalating this to a TSI with Apple, they have confirmed that this is 'expected behavior' for this number of animated CAShapeLayers. Sigh. They did offer a suggestion at this link, which involves continually pausing and unpausing the animation to mimic a lower frame rate. (Since it's the calculations for each DisplayLink-locked animation frame that are slamming backboardd)

编辑:在将这个升级为与苹果公司的TSI后,他们已经确认这是这个动画CAShapeLayers的“预期行为”。叹。他们确实提供了这个链接的建议,其中涉及不断暂停和取消暂停动画以模仿较低的帧速率。 (因为它是每个正在关闭背板的DisplayLink锁定动画帧的计算)

-(void)pauseLayer:(CALayer*)layer {

    CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
    layer.speed = 0.0;
    layer.timeOffset = pausedTime;
}

-(void)resumeLayer:(CALayer*)layer {

    CFTimeInterval pausedTime = [layer timeOffset];
    layer.speed = 1.0;
    layer.timeOffset = 0.0;
    layer.beginTime = 0.0;
    CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
    layer.beginTime = timeSincePause;
}

Finally, the nice Apple tech pointed out that animation framerate control "would make a decent API enhancement request, as an aside" — so I'm making one, and you should, too. :)

最后,漂亮的Apple技术指出动画帧率控制“会提出一个不错的API增强请求,作为一个” - 所以我正在制作一个,你也应该。 :)

1 个解决方案

#1


1  

You need to try and isolate your problem. It sounds like your layer hierarchy isn't scaling well and is becoming too complicated.

您需要尝试隔离您的问题。听起来你的图层层次结构不能很好地扩展,并且变得太复杂了。

Do you see the same CPU activity if you use less instances of the subclassed CAShapeLayer? Or if you try to perform less animations?

如果使用较少的子类CAShapeLayer实例,您是否看到相同的CPU活动?或者,如果您尝试执行较少的动画?

#1


1  

You need to try and isolate your problem. It sounds like your layer hierarchy isn't scaling well and is becoming too complicated.

您需要尝试隔离您的问题。听起来你的图层层次结构不能很好地扩展,并且变得太复杂了。

Do you see the same CPU activity if you use less instances of the subclassed CAShapeLayer? Or if you try to perform less animations?

如果使用较少的子类CAShapeLayer实例,您是否看到相同的CPU活动?或者,如果您尝试执行较少的动画?