When a long sound is played for the first time the client seizes up.
This happens with sounds that are about 20+ seconds long.
This happens regardless of the sound having been preloaded, although it only happens the first time it is played.
This may be insignificant for sounds that are played often, but it is very significant when trying to play a soundtrack (the sound clips may easily only be played once per session). It is especially noticeable when the lag-spike causes cross-fading 120 second sound clips to play out of sync
It might occur because the data needs to be prepared for playing, and it may use a very inefficient algorithm.
Repro:
local soundId = "rbxassetid://179034880" -- 120 seconds of pretty music
local ContentProvider = game:GetService("ContentProvider")
ContentProvider:Preload(soundId)
while (ContentProvider.RequestQueueSize > 0) do
wait(0.125)
end
print("Sound is preloaded")
print("Start moving your camera or something so you notice FPS drop")
wait(2)
local sound = Instance.new("Sound", workspace)
sound.SoundId = soundId
print("The client is about to seize up...")
sound:Play()
wait(4)
sound:Stop()
wait(1)
print("Shouldn't lag this time")
sound:Play()
Also, I’d like to be able to upload longer clips because some songs have very soft parts and those chunks are automatically banned for being “too quiet.”
EDIT: It seems this has been fixed, I tried the repro again and I didn’t notice any lag
I’ve tried cutting them into 30 second chunks to make the lag spikes more frequent and less significant but it’s so flipping tedious
Conceptual fix (on roblox’s end):
Make the sound API automatically cut them into smaller chunks as the sounds play, so it isn’t all precalculated right when the song plays.
This is how we are preloading sounds, as the preload service doesn’t work with sounds. It completely removes lag if you play that sound again. But when you FIRST play a 1-2 minute sound it lags getting into the cache. ):
It’s more like:
Play sound
volume 0
Lag spike for 0.5 to 2.0 seconds for 1-2 minute songs
Stop sound
It doesn’t unload unless you re-join the game[/quote]
Yeah it does actually, I’ve found this issue present at my club game. I do agree though, it may be worth considering streaming sounds rather than just downloading them.