Huawei has massively cranked up the battery optimization to a degree much greater than what Google does. I listen music in the background all the time on my Pixel with zero issues. If I pause the music for ten minutes or so it gets killed. Google can always improve memory management but this one is definitely more on Huawei.