I just finished debugging an issue where I used load to read a music file from disk and play it.
I also kept all the Music values I loaded in a Map.
I ran into all kinds of strange bugs, music jumping forward at a specific place,
trying to play music I already played wouldn't do anything after playing something else, music starting from the middle of the file, etc.
Then I thought that maybe the ByteString content of the file was garbage collected and/or overwritten or something. So instead of keeping a Map of Music I kept a Map of ByteString which is the result of readFile and I played music using playMusic Forever <=< decode. This fixed the issues I had.
Am I correct in my assumptions? Maybe the load API is problematic and should be removed?
I just wanted to share this so it might help others if they trip on these kind of bugs.
sorry for the generic title.
I just finished debugging an issue where I used
load
to read a music file from disk and play it. I also kept all theMusic
values I loaded in a Map. I ran into all kinds of strange bugs, music jumping forward at a specific place, trying to play music I already played wouldn't do anything after playing something else, music starting from the middle of the file, etc.Then I thought that maybe the
ByteString
content of the file was garbage collected and/or overwritten or something. So instead of keeping a Map ofMusic
I kept a Map ofByteString
which is the result ofreadFile
and I played music usingplayMusic Forever <=< decode
. This fixed the issues I had.Am I correct in my assumptions? Maybe the
load
API is problematic and should be removed?I just wanted to share this so it might help others if they trip on these kind of bugs.
Thanks!