Sound system can pass NaN to WebAudio

So I have been seeing this error quite a bit - and it’s getting to be a bit of a problem.

We load a bunch of assets, with sound components attached and then instantiate them as required in game (we are using the offline engine).

It seems that frequently - we see errors thrown from PlayCanvas, where it attempts to call the WebAudio API - setPosition, with data either position, or rotation, that contains NaN values. How this is possible in the first place is a mystery - but I am guessing there is some race condition here. The reason I say it is a mystery is that every object should have positional and rotational data at all points during their lifecycle. I am guessing (although I haven not being able to verify this) - that the issue occurs when cloning the asset. I caught a crash recently where the Euler angles on the entity were set, but the localRotation values where NaN - and I believe it is this value that is used by the audio system.

Similarly - if you have an AudioListener component attached while cloning the asset, it causes a hard crash.

(This is the error as caused by a Sound Component being updated while the parent entity has NaN for it’s transform and localRotation values)

This is a snip of the entity for the object that is causing the problem - you can see localRotation has NaN values:


Would it be possible to create a small reproducible project in PlayCanvas please? That will help the developers to look at a fix.

I cannot reproduce it yet in PlayCanvas itself. I will continue trying… but yeah.

Ah, so it’s only when you use the engine directly? Could you create a simple engine only version and paste the code here?

(Yes - it’s in the engine directly). I’ll see what I can do. :wink: It may take a couple of hours, and I’m in the middle of crunch as we approach an important milestone. I really want to get something together (I understand it will make it easier) - I’m just in that catch 22 of no time, but the repro would make it more likely to get fixed. :confused: