SceneKit帧率不一致 [英] Inconsistent SceneKit framerate

查看:153
本文介绍了SceneKit帧率不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SceneKit入门项目中看到非常不一致的帧速率.有时,它以60 fps的速度持续运行(12ms渲染,6ms的金属刷新),有时它以40 fps的速度持续运行(20ms渲染,6ms的金属刷新),不多也不少.

I'm seeing very inconsistent frame rates in the SceneKit starter project. Sometimes it runs constantly at 60 fps (12ms rendering, 6ms metal flush), and sometimes it runs constantly at 40 fps (20ms rendering, 6ms metal flush), no more, no less.

当我重新打开应用程序时,帧速率会随机变化,并且将保持该帧速率直到下一次重新打开.我尝试切换到OpenGL ES,虽然似乎可以在入门项目中修复它,但在我的实际应用中仍然可以看到这些下降.

The frame rate changes randomly when I reopen the app, and will stay at that frame rate until the next reopen. I tried switching to OpenGL ES, and while it seems to fix it in the starter project, I still see those drops in my real app.

入门项目未经修改(正在轮换使用),我正在Xcode 7.0和运行iOS 9.0.1的iPad Mini 4上对其进行测试.我不确定是什么原因导致了此问题,原因是SceneKit,iOS或我的设备.

The starter project is unmodified (rotating ship), and I'm testing it on Xcode 7.0 and iPad Mini 4 running iOS 9.0.1. I'm not sure what is causing the problem, SceneKit, iOS or my device.

这是一个金属系统跟踪,第一部分以60 fps的速度运行,第二部分按主屏幕按钮并重新打开应用程序,它以40 fps的速度运行.看起来在第二部分中有很多颜色加载/存储.

Here is a metal system trace, the first part it was running at 60fps, the second part I press the home button and reopen the app, and it runs at 40fps. It looks like there are a lot of color load/stores in the second part.

推荐答案

不幸的是,它看起来像SceneKit(和SpriteKit)处于开发的进化阶段,以牺牲使用它们为代价.

Unfortunately it looks like SceneKit (and SpriteKit) are in evolutionary stages of development, at the expense of those using them.

这个问题肯定存在于我所知道的所有设备和以下框架上:

This problem is definitely on all devices, and the following frameworks, that I know of:

  • SceneKit
  • SpriteKit
  • 金属

即使在游戏框架中使用OpenGL而不是Metal,该问题仍然存在,并且一致性也不少.

Even using OpenGL instead of Metal in the game frameworks the problem still exists, with no less consistency.

如果iOS确定存在保持60fps稳定的问题,iOS似乎试图将帧速率固定为40fps.

It looks to be an attempt by iOS to fix the frame rate at 40fps if iOS determines there's an issue maintaining a steady 60fps.

我认为下降到40fps的原因是iOS无法很好地解释问题",并且在应用程序启动不稳定的某个时间段内,在太短的时间内进行了性能采样,原因是存在许多对问题的误报一旦iOS本身真正安定下来并让应用程序/游戏运行不受阻碍,就不会出现了.

I think the cause of the drop to 40fps is iOS not being very good at interpreting "problems", and doing performance sampling over too short of a period at an unstable point in the app's launch, given many false positives for problems that aren't there once iOS itself has actually settled down and let the app/game run without hindrance.

jetFighter的默认模板永远不会以60fps的速度运行.因此,只有在发布时过早(过短的时间)内由iOS进行轮询以确定何时将游戏循环的上限设置为40fps的情况下,该帧率上限的功能"才有效.这意味着游戏前几帧的任何中断都会导致iOS将其上限设置为40fps,并先发制人地认为游戏无法/无法保持60fps.

The default template with the jetFighter shouldn't ever have trouble running at 60fps. So it only makes sense that this framerate cap "feature" would become active if the polling by iOS to determine when to cap the game loop at 40fps is done too early in the launch, for too short of a time. This means any interruption in the first few frames of the game causes iOS to cap it at 40fps, pre-emptively thinking the game won't/can't maintain 60fps.

具有讽刺意味的是,iOS可能是它在游戏启动时检测到打h的原因,导致其随后认为该应用无法维持稳定的60fps.

Ironically, iOS is probably the cause of the hiccups it's detecting at the launch of the game that cause it to then consider the app unable to maintain a stable 60fps.

但我正在调试!

这是基于观察,而不是此事的任何已知事实.但这与我所看到的正在发生的事情以及到目前为止我唯一合理的解释是一致的.

This is based on observation, not any known facts on the matter. But it's consistent with what I'm seeing happening and the only reasonable explanation I have so far.

好消息"是iOS不会只采样一次,而是将其保留.它会间歇性地对游戏进行采样,并在出现中断(例如跳到主屏幕并返回到应用程序)后进行采样.

The "good news" is iOS is not sampling only once and leaving it. It samples the game spasmodically, and after interruptions like jumping out to the home screen and back into the app.

例如:可以在连接设备的同时启动Quicktime screenCapture,从而导致iOS对帧速率进行重新采样,并使帧速率从40跳到60,或者从60跳到40.显然,此操作(以及其他一些操作)将导致iOS再次测试正在运行的应用的帧速率一致性,然后iOS再次根据其发现进行调整.

For example: it's possible to cause a resampling of the framerate by iOS, and cause it to jump from 40 to 60, or 60 to 40, simply by starting Quicktime screenCapture whilst your device is connected. Apparently this (and a few other actions) will cause iOS to test the running app for its framerate consistency, again, then iOS adjusts according to its findings, again.

然后,经过一段任意时间后,它将再次扫描.如果让JetFighter模板运行一段时间,您还将看到iOS最终会对帧速率一致性进行了另一项测试,并且通常确定它现在已经足够稳定在60fps上,可以将其恢复到60fps,尽管最初已经决定了.应该只能以40fps运行.

And, after an arbitrary amount of time, it scans again. If you leave the JetFighter template running for a while, you'll also see that eventually iOS does another test of the framerate consistency, and often determines that it's now stable enough at 60fps to put it back up to 60fps, despite having initially decided it should only run at 40fps.

之所以说所有这些,是因为我在设备的统计信息中观看了一个名为渲染器"的事件,故意在每个游戏循环中占用正确的额外时间来强制40fps,即使没有足够的其他东西继续使它变得必要.

I say all of this because I've watched a thing called "renderer" in the stats on the device deliberately taking up exactly the right amount of extra time in each gameloop to force 40fps, even when there's nowhere near enough other things going on to make that necessary.

在我看来,苹果公司正在根据其关于iPad Pro和iOS支持的功能的可变帧速率技术开展工作,这些功能似乎已经在屏幕技术发布之前(貌似)实现了.奇怪地测试正在运行的应用程序,以确定何时将其强制降低到较低的帧速率.

It occurs to me that Apple is working on variable frame rate technology as per their statements about the iPad Pro, and the iOS features to support that have been (seemingly) implemented ahead of the release of the screen technology, and badly and oddly testing running apps to determine when to forcibly roll them down to slower frame rates.

鉴于40fps是一个奇数,不能以60fps的刷新率平均划分当前设备的默认刷新率,因此,如果iPad Pro对40fps感兴趣的话,很可能能够进行120Hz的屏幕刷新.

Given that 40fps is an odd number not equally dividing into the default refresh rate of current devices at their 60fps refresh rate, it's likely the iPad Pro is capable of 120Hz screen refresh if they're so interested in 40fps.

从当前的iPad拍摄时,如果iOS将其帧率锁定为40fps,我会看到2:1:2:1:2:1的帧序列,这就是您如何在60Hz刷新设备上达到40fps的方式.

When capturing from current iPads, if it's framerate locked at 40fps by iOS I'm seeing a 2:1:2:1:2:1 frame sequence that's how you'd make 40fps on a 60Hz refreshing device.

这绝对不是理想的.您永远不会希望在60Hz的屏幕上看到它,因为即使在眼睛不敏感的人看来,它在视觉上也很烦人.

Which is in no way ideal. You wouldn't ever want to see this on a 60Hz screen because it's annoying, visually, even for people with insensitive eyes.

我不知道,这种可变帧率技术可能会在新iPhone上实现真正的40fps.尚未看到任何测试,但现在看来,只有iPad Pro才有可能真正在所有事情上引起此问题,这似乎很奇怪.

Possibly this variable framerate technology permits true 40fps on the new iPhones, I don't know. Haven't seen anything tested yet, but it does seem odd that something likely only truly possible on the iPad Pro is causing this issue on everything at the moment.

这篇关于SceneKit帧率不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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