For the last few months, I've been working on a music player app that uses the Opusfile library to handle decoding .opus audio files, instead of using the system's MP3 decoding API. The app is fairly fleshed out at this point, and while it works great in the Simulator on both macOS and Windows, it crashes immediately at launch on actual Playdate hardware.
I've spent a while trying to isolate the problem, but so far, I haven't been successful. My debug logging indicated that the crash was occurring upon attempting to load a .opus file with Opusfile. I haven't yet received hardware myself, but I've gotten crash logs from several people. However, I haven't been able to use gdb to get line information as described in this thread, as gdb simply tells me that no line number information is available for the addresses from the crash logs. Opusfile and its dependencies are designed to be usable in embedded environments, so I'm not sure what's going on here. The only other thing I can think of is littering the affected Opusfile functions with debug print statements, but that's a time-consuming process both for myself, and for the others who have offered to help me test my app on hardware.
I threw together an example project using Opusfile with the bare minimum amount of code complexity required to reproduce the issue. It simply copies a .opus file into memory, then passes the buffer to Opusfile's op_open_memory function. That function call crashes on hardware, but on the Simulator, the example continues running. It queries the number of samples in the audio file and draws that number to the screen.
I'm hoping someone here is able to identify the problem, perhaps by using a hardware debugger. I've posted the bare minimum example to GitHub. The repository includes everything you need to compile it yourself, but I've included a build here: playdate-opusfile-test.pdx.zip (283.3 KB)
I unfortunately don't have a crash log from the example project, but I have a couple older logs from the full music player:
(Please note: each test is a different build of my music player.)
--- crash at 2023/09/18 05:48:00--- build:1fd086bf5715-2.0.3-release.158184-buildbot r0:00000000 r1:00000000 r2:00030cb0 r3: 00000000 r12:006d3000 lr:080353ef pc:080350fa psr: 61000000 cfsr:00010000 hfsr:40000000 mmfar:00000000 bfar: 00000000 rcccsr:00000000 heap allocated: 2639040 Lua totalbytes=391600 GCdebt=-154260 GCestimate=195813 stacksize=80
--- crash at 2023/09/29 06:01:38--- build:1fd086bf5715-2.0.3-release.158184-buildbot r0:30019b68 r1:00000000 r2:00001000 r3: 00000400 r12:00000009 lr:24031703 pc:240324ac psr: 81000200 cfsr:00010000 hfsr:40000000 mmfar:00000000 bfar: 00000000 rcccsr:00000000 heap allocated: 2639104 Lua totalbytes=391600 GCdebt=-154421 GCestimate=195829 stacksize=80
I'm happy to elaborate on anything, if desired. Thanks for your time.