BUG: Shuffle on PS3

I’ve noticed the PS3 app seems to have a particularly annoying bug in its shuffle behavior. The first ~2 tracks always seem to repeat. It seems to manifest with both audio (music) and video (TV/Movie). For example:

  1. Pull up TV Shows
  2. Pull Up “Spongebob Squarepants” (show)
  3. Select the Shuffle button (crossed arrows)
  4. First episode plays
  5. Second episode plays
  6. First episode plays
  7. Second episode plays

Sometimes after the first couple episodes repeat it will break out and start playing new things, but the first couple always seem to repeat.

It’s not just “random is random” because this same pattern manifests more or less every time. The same will also occur for example selecting an Artist in the music library.

I have exactly the same problem: when starting a music playlist on shuffle, the first two tracks always get played twice.

The “Shuffle isn’t random” bug is very annoying. We play kids TV shows for our children by putting an entire show on shuffle. There’s definitely about 6 episodes that always make it into the first couple episodes played. If I enable debug logging even in verbose mode, the random sequence generated isn’t captured. Regardless, the reason for the repeated patterns is usually caused by using poor random number generators. I’d bet $100 that’s the case here.

Plex devs, please go back to your code and use a cryptographically derived random number or bytes to use as a seed value. If you use something simplistic like RAND or a cruddy seed value that some programmer though would be clever, that’s exactly how you end up with these repeating patterns. This is a very well known phenomenon in software, especially those experienced with secure coding practices. In .NET, use RNGCryptoServiceProvider. For everything else, go straight to the BCryptGenRandom function in Bcrypt.dll. That’s the underlying function used by RNGCryptoServiceProvider in .NET. In OS X, you can get cryptographically secure pseudorandom numbers by reading bytes from the /dev/random device file.