Fileplayer stops playing during performance load (Device only)

I was testing the Audition app made by @matt, which allows you to play audio files and view images on the device. I noticed that as I added more songs, eventually they would start randomly skipping to the next song. Looking at the code for Audition, it seems that the finishCallback set by fileplayer:setFinishCallback() is called early when there is a performance hitch caused by low fps or garbage collection. This issue can be alleviated by increasing the buffer size when creating the fileplayer, so it seems that the buffer size is directly related to this issue. This issue only happens on device, as the simulator runs too quickly to create these performance hitches.

Here is a pdx file with some sample files included. There are two music files (PDA, compressed IMA ADPCM), and a bunch of test images to create a load on the system. If you play the first music file, you will notice that it randomly skips to the next song. Then shortly after that, the second song will also stop. Scrolling up and down the file list while a song is playing seems to make it happen faster.

1 Like

I have found another potential bug related to performance hitches. It seems like the ButtonDown and ButtonUp callbacks may be skipped if there is a lag spike. In the Audition app, it sets a keyRepeatTimer on button down, and then removes the timer on button up. However, sometimes the button up callback is skipped, causing the timer to just run endlessly as if the button was stuck. In the example pdx, you can trigger this by pressing (not holding) up or down very quickly in succession. You can prevent this in code by using if keyTimer then keyTimer:remove() end right before you create a new timer.

I'm also seeing bugs that Audition is very good at showing up.

Also I've gone back through older SDK versions and there is some changed behaviour.

There have been no changes to Audition code since 2021-07-25.

I am seeing:

  • Simulator crashes
  • Display errors

Any thoughts @dave ?

@timhei does this "missing button" press go away when you run the app at higher refresh rate?

OK, I have bisected old SDK versions and I am seeing the following:

  • baseline 0.11.1 (2020-09)
    • all OK, no issues
  • since 1.0.0 (2020-12)
    • certain mp3s will halt on third playback (simulator and device)
  • since 1.1.0 (2021-06)
    • remaining track time is shown as a strange negative amount? (simulator and device)
  • since 1.2.0 (2021-07)
    • audio playback finishes early (device only)
  • only 1.9.3 (2022-03)
    • lock when playing back any mp3 (simulator only)
  • only 1.10.0 (2022-04)
    • playback of certain mp3 crashes (simulator), stall (device)

@dave here is a problematic mp3 test.mp3.zip (4.9 KB)

I'll check it out. Thanks for getting this together!

2 Likes

I tried setting the app to 50 fps, but it will only run up to 30. The problem still happens with the missing button presses at 30 fps. It specifically seems to happens when there is a large garbage spike, which apparently listViews are very good at creating. The buffer underrun problem also happens, but it seems like it happens less often.

1 Like

Thanks! Crazy how this one little thing can show so many bugs.