The one that got away: A Windows Phone bug that can not be solved
A project I was recently working on ran up against an interesting bug—and, unfortunately, it was a bug we had to ship the app with in the end. My main reason for sharing this is in the hope that if you find this same bug, you know you’re not alone, and maybe it gives you some ideas for what to do.
The Issue
The app itself is an audio streaming app, but it’s not real streaming—it’s actually HTTP progressive downloading and plays the file as it downloads. The problem we had? When it finished playing one file, it wouldn’t load the next one. Part of the pain for us is that this is a pretty hard scenario to identify, as it has these requirements for the bug to reveal itself:
- It’s related to network only. If the file was already on disk, it would work every time.
- It happens only when on battery. Plug the phone in—or use the emulator (which is always “plugged in”)—and the issue won’t appear.
- The screen must be locked and off. Any interaction with the device causes the problem to disappear.
- If it’s playing a file, it will finish that file fine. The issue only happens when skipping to the next file.
- It won’t raise any errors or exceptions—it just silently fails to play the next file.
- This uses background audio, so it’s not that the app is being suspended.
We tried everything as a team and couldn’t solve it, so we escalated to Windows Phone support. This was the first time I dealt with premier Windows Phone dev support—and while they cost a lot, they knew their stuff and could help confirm our understanding while also suggesting workarounds.
Root Cause
The cause is this: when the phone is on battery and there’s no interaction, it lowers the signal strength of the antennas to save power—but this also means HTTP connections could be too slow to work properly, so the audio won’t play.
Workarounds
This doesn’t seem to happen with Windows Phone 8.0 Silverlight apps, which handle background audio differently. However, moving from Universal apps to that may be too costly (it was for us). The other option is to use real streaming, which is less impacted by this issue—and it also lets you do smart server-side optimizations to keep things running smoothly.
Future
This happened on Windows Phone 8.1 and still happens on Windows 10 for phones. The official response is “by design,” though I think it’s more of an unexpected side effect of several design decisions—but it could change. If you think it should, please vote on the User Voice item so the product team knows how many people care about resolving it.