Thank you for this. I had just bought the Sony WF-1000XM3 Wireless headphones, and everything appeared great with Spotify, etc, and then I noted I could not pause or change tracks with the headphones (tap on the side, etc). I would then unlock my mobile (S8+) and I had control with the "tap". Your "put app to sleep" was the issue. Again thank you, I searched high and low for help. Decided to put this up in case others have the same issue with the Sony WF
So I was having this problem and I think I've solved it.
Go to apps, click on spotify, then battery, and click allow background battery.
Working relatively seamlessly for me now
Allowing background activity for Spotify on its own did not work for me. I had to amend Power mode to High Performance. The combined actions worked. Also if Spotify is not in offline mode with saved music then you will obviously lose the track you are listening to when the phone loses connection, apparently this is the case even if the playlist is one of your saved lists.