CPU creeps up over time?


I’m building a little 2D demo to try out the engine, and I’ve hit a weird stumbling block in this scene: PlayCanvas | HTML5 Game Engine

I have a few dozen sprites, and a couple of simple scripts. Nothing has an update function yet. When I load it, it’s nice and fast, but pretty rapidly it slows down. Over the course of a few minutes, the Update Time entry in the profiler goes from 0.5ms on my desktop to 3ms. On mobile it’s much worse, rapidly climbing up to 20ms. This seems like a bug, but I can’t work out what else I can do to debug where!

Thanks for any help.

Hi @Chris_Subagio and welcome! It seems that your project is private or no longer exists.

It is private. Is there no easy way to share one of those with the devs for debugging?

You can add users to your project who are be able to help.

Thanks for the info. Do you have anyone in mind?

I can take a look, but I’m not a developer.

@Chris_Subagio Just a thought since we can not see the code. Please do a search for objects being created but not destroyed. Some place or keywords would be like .clone or instantiate. You may be able to have a look into the browser inspector to capture it. How are the sprites being created?

1 Like

No cloning, no instantiation, no update functions in scripts. Even for the few functions written (a camera control script), I’m recycling a handful of Vec3s, rather than newing them in the events. Literally just a scene with a few sprites in it, from two texture atlases. I think I have sorting disabled for the layers, no camera culling. It’s baffling!

The scene itself is growing now, as I have to finish this evaluation quickly, but I’d appreciate it if folks could tell me if they’ve had any similar experiences?

@Chris_Subagio I agree with @Albertos. I am really sorry we don’t have a good answer currently. The developers should have a look to see if maybe there is a deeper issue.

No worries then, I’ll wait to see if a dev chimes in. Thanks all!

1 Like

Found it! For some reason I thought I needed an AudioListener to hear anything, so I had one sitting in the scene, under a 2D Screen. I don’t know what the mechanism was, but its update was the one growing over time. I don’t know if the faulty mechanism applies to any other entities or components (somewhat concerningly the labels that showed up in Chrome performance tab were I think update position and update orientation), but so far I’ve removed the listener and then added a few dozen other things in the scene with update functions, and I haven’t seen the same degradation over time.

Does anyone else have any experience with the AudioListener and or any other components or combination of components that cause runaway CPU usage like this?

I’ve not heard reports about this before at the same time, it’s a not a commonly used component as well :thinking:

Can you reproduce the bug in a new blank project and post a report on our engine repo please: Issues · playcanvas/engine · GitHub

Our team can investigate it from there

I thought the same, so I’m suprised to see that’s not the case. Probably it’s only needed when you use positional sounds.

1 Like