Reputation: 111
We’ve noticed that our app in the background behaves differently on different vendors’ devices. Basically, while the app is in the foreground state everything works very well, our processing takes around 15-50ms per frame so the system is very responsive, but very soon after a user moves our application to the background state we are starting to experience a delay in processing, it starts to take significantly more time (up to 600 - 800ms per frame)
So the question is, can we do something to improve performance background performance on Samsungs? Maybe to be prioritized or to be whitelisted, or not be pushed to a low-level CPU.
We have developed a small application to investigate this issue.
Here is the link for them who'd like to try: https://drive.google.com/file/d/1DVJ9F3jDEW5AO8CSA_8znRupiQiBB10M/view
This app has foreground service, wakelock, and a simple “heavy” operation that basically does this:
private var array = DoubleArray(100) { 0.0 }
while (i < 1_000_000) {
array[abs(k % count)] = Random.nextDouble() * i
i++
k++
}
The results that we got after some testing were familiar with what we’ve been having in our app.
On Samsung devices (Samsung S22) with Android 12 time for processing in the foreground was fast and almost constant (160-180ms), but after ~10 seconds when the app is in the background time for processing is drastically going up to 1100-1120ms, compared with Pixel 6 with 180-190ms in foreground and 300-350ms in the background. So time for processing on Samsung increased 5 times in the meantime on Pixel it was ~2 times or even less. In addition to that, we saw that the app was pushed to low-performant CPU-s in the background and returned back to the foreground, but on the Pixel device, the app was never pushed lower 4th CPU. All the tests are made on the devices with no other active applications running in parallel with us.
Below are the sample app' profiler screenshots that show how differently it behaves on Pixel (1 pictire) and Samsung(2 picture):
Upvotes: 3
Views: 192