When reparenting the parent of an AudioEmitter to nil, it produces a spike in frame time.
Reproduction File: Upon clicking the button, the AudioEmitter is initialized on the client under the AudioSource Part. After which, the part is reparented to nil 0.5 seconds later on the Server. repro_lag.rbxl (58.0 KB)
Hey @fireys – I was not able to reproduce this, but we might be using different hardware – could you provide some system information? Also, is there anything interesting in the microprofiler around the time of the lag spike?
Hi there, revisiting the same repro file posted above; I am still experiencing this issue in Studio.
Here is my microprofiler log from studio: microprofile-20250702-215913.html (2.4 MB)
Having the same issue with the repro file, where “Write Marshalled” causes a massive lag spike.
Microprofiler dump: microprofile-20250703-005410.html (2.6 MB)
Live game still experienced a lag spike when parenting the boombox prop out of workspace.
Microprofiler dump: microprofile-20250703-010029.html (5.6 MB)
Live server video:
Hi @crenbowo – the Sound job is responsible for periodic/per-frame updates like ticking AudioPlayer.TimePosition & tracking the panning changes from Emitters & Listeners – the Write Marshalled times have to do with modifying properties/attributes in the DataModel – I believe these are two separate performance problems.
The Write Marshalled spikes didn’t occur for me when I tried the provided placefile, and @fireys mentioned they only happen in studio
Do the Write Marshalled spikes occur in your live experience too? Or only studio?
At any rate – do you have a link to the place? I can try it out to see if I hit the same performance issues
Sharing what I wrote in DMs in case it’s relevant for others –
After you delete (i.e. reparent-to-nil) a Sound or an AudioPlayer, it causes the audio engine to unload its file/asset. The unloading process can be sort of slow, so we do the cleanup in a background thread (which is the Thread - Background scope in the microprofiler here)
But in @crenbowo’s case, the background cleanup blocks other parts of the audio engine (this is a bug), which is why the Sound scope happening concurrently takes such a long time (it has to wait for the background cleanup to finish)
This appears to be separate from the original report about long Write Marshalled times, and it would not be specific to AudioPlayer (since Sound does the same background-unloading) but nonetheless it’s a legit issue that we’re looking into.
It doesn’t seem to lag when deleting any asset, it mainly affects certain audio files. So if you avoid deleting Sounds or AudioPlayers that have loaded those, it would avoid those frame spikes – that’s not a great solution for keeping memory under control, but it might be the best temporary-workaround until we get this fixed.