RealityKit: ECS System.update() method not being called every frame on hardware

Hi,

I'm trying to use the ECS System class, and noticing on hardware, that update() is not being called every frame as its described in the Simulator, or as described in the documentation.

To reproduce, simply create a System like so:

class MySystem : System {
    
    var count : Int = 0
    
    required init(scene: Scene) {
    }
    
    func update(context: SceneUpdateContext) {
        count = count + 1
        print("Update \(count)")
    }
}

Then, inside the RealityView, register the System with:

MySystem.registerSystem()

Notice that while it'll reliably be called every frame in Simulator, it'll run for a few seconds on hardware, freeze, then only be called when indirectly doing something like moving a window or performing other visionOS actions that are analogous to those that call "invalidate" to refresh a window in other operating systems.

Thanks in advance,

-Rob.

Hello,

This is actually behaving as expected.

If you would like to do something per-frame when a particular component type is present in your scene, you could set up a system like this:

final class MySystem: System {
    
    var count = 0
    
    static private let query = EntityQuery(where: .has(MyComponent.self))
    
    init(scene: Scene) {}
    
    
    func update(context: SceneUpdateContext) {
        count += 1
        
        let entities = context.entities(matching: MySystem.query, updatingSystemWhen: .rendering)
        
        for entity in entities {
            print(entity.name)
        }
        
        print(count)
    }
}

struct MyComponent: Component {}
RealityKit: ECS System.update() method not being called every frame on hardware
 
 
Q