AnimationLibraryDefination memory leak Realitykit ARKit

Viewed 25

So I have a ARView using realitykit. I am reusing the ARView. I have a Entity that has animations (stored in .usdz file). I play the animation with the following line of code.

hummingbird = try! Entity.load(named: "bird")
for animation in hummingbird.availableAnimations {
            hummingbird.playAnimation(animation.repeat(duration: 120.0))
}

However, I noticed there is a memory leak. using Instruments I found it was at the playAnimation line. I have no clue how to fix this. At the end of the ARView I do this:

hummingbird.stopAllAnimations(recursive: true)
hummingbird = nil

I thought that should be enough. But it isn't. In the image, there are 2 instances. That from running the same arview 2 times.

Memory Image

Basically, my setup is startVC->ARView->backToStartVC->backToSameARView (with new configuration). And so on. Any idea would be great. And if you have any questions or need clarification. Please ask.

0 Answers
Related