12
votes

I'm working on an ARKit project for 4 months now. I noticed that when adding a child to my scene rootNode, there is a FPS drop. The device freezes for less than a second. I did a lot of research and trials, noticed that all Apple's code examples have this FPS drop too when placing an object. It does not matter if the node is added directly (scene.rootNode.addChild(child)) or if it's added in the renderer loop at different phases (didUpdateAtTime, didApplyAnimations etc...). I found that once an object has been added to a scene, the next added object will render immediately. I use a 3D model created in SceneKit editor, clone it to generate my different nodes before adding them as child. I do this loading work before placing the objects.

Instruments shows that the renderer loop is busy for the duration of the freeze.

The only solution that I found is to add my nodes to the scene behind a loading screen before starting the whole experience.

Is that a normal behavior in game programming to render nodes before using them ?

Thanks guys

1
same problem here, did you find any actual solution instead of a simple workaround? I need to add the model after an hitTest: so I cannot preload itClaus
I did not find any other way to fix this at this day... I'm pretty sure Apple has a solution for this that I can't find.Adrien Yvon
Is the object instantiated on the moment you addChild or just before you add it with addChild? Do you have a sample to provide?Oleg G.
@OlegG. In my case the object was already instantiatedClaus
Try to load all your objects you need in this scene before you show up the scene, and then reuse your already instantiate objects.Oleg G.

1 Answers

2
votes

With the release of ARKit 3.0 and its satellite – RealityKit (framework with optimised rendering engine and changed scene's hierarchy, that was written in Swift hence it has no Objective-C binding), a drop-frame, when adding a child, is reduced to an imperceptible value.

And such a predictable behaviour of ARKit3/RealityKit ligament is especially true for devices with processors A12 Bionic and A13 Bionic manufactured on 7 nm process (and, of course, due to the fact they have last-gen neural engines and powerful GPUs).

For devices with a less powerful processors (A9, A10, A11), it is advisable to use 3D models with a total number of polygons of no more than 10K per model, and with usual shaders like .blinn or .phong (not PBR).

I believe it's quite a common practice for games and apps that use game engines, to firstly load (or cache) all the necessary game assets (like 3D models, textures, sound files, etc) into RAM before using them. For further details please read this article and this article.

However, it’s worth saying that AR games, unlike VR games, consume considerably more processing power, therefore they need to be carefully optimised. So, you're absolutely right, rendering nodes before using them and it's a normal behaviour in game programming.