Currently whenever the scene code uses getMutable() / getMutableOrNull() some CRDT message is being sent regardless of actually changing anything.
So in the following example there's an unneeded CRDT message being sent every frame that the system runs, while the real mutable manipulation only happens when the global input key press is detected...
// Cameras Changing System
engine.addSystem(() => {
const mainCamera = MainCamera.getMutableOrNull(engine.CameraEntity)
if (!mainCamera) return
if (inputSystem.isTriggered(InputAction.IA_PRIMARY, PointerEventType.PET_DOWN)) {
// actually change 'mainCamera' mutable...
}
})
A further problem with this is that the Explorer flags that PB component as 'dirty' on every frame, even though nothing is changed on that component.
And many systems dedicated to process the different components rely on the IsDirty flag and of course don't check manually that every property on every component was actually changed or not...
So I'd say this is a potential performance degradator, since it would not only affect the current scene but also nearby scenes, since every CRDT message would be processed even though the mutable is not changed at all.
Of course creators could use getMutable only when they are 100% sure they will be changing the mutable, but that's another extra responsibility falling on creators and affecting their code design.
Ideally the SDK Runtime should be somehow checking if any value was actually changed and if not, avoid sending any CRDT message at all.
Currently whenever the scene code uses
getMutable()
/getMutableOrNull()
some CRDT message is being sent regardless of actually changing anything.So in the following example there's an unneeded CRDT message being sent every frame that the system runs, while the real mutable manipulation only happens when the global input key press is detected...
A further problem with this is that the Explorer flags that PB component as 'dirty' on every frame, even though nothing is changed on that component. And many systems dedicated to process the different components rely on the
IsDirty
flag and of course don't check manually that every property on every component was actually changed or not...So I'd say this is a potential performance degradator, since it would not only affect the current scene but also nearby scenes, since every CRDT message would be processed even though the mutable is not changed at all.
Of course creators could use
getMutable
only when they are 100% sure they will be changing the mutable, but that's another extra responsibility falling on creators and affecting their code design.Ideally the SDK Runtime should be somehow checking if any value was actually changed and if not, avoid sending any CRDT message at all.