r/android_devs • u/[deleted] • Jul 18 '20
Discussion Realtime blurring in Android
I am currently in a project where some design elements should have blurred background that updates as the user scrolls on a background with multiple images. I know Android generally doesn't play well with blurring and that its OK for static content but I expected it do be in a better state today as the phones itself are more than capable to handle it.
The implementation was done with some random library I found on GitHub, and it uses the classic Renderscript to make it work. The effect even worked very well on my OnePlus and the designer was very happy that we could be as close to the design as the iOS counterpart.
However, I took another phone one day to test stuff (Samsung Galaxy S8+) and the performance was horrible. Scrolling was laggy and choppy and we had to use fallback graphics because the user experience was really bad. I was really surprised that a device that was the flagship 2-3 years ago can't handle realtime blur.
I'm guessing the issue lies within Android since the device itself should be able to handle it. The developer of the lib did benchmarks on Nexus 5 and it could maintain 60 fps without issues.
My question is, is there a specific reason why Android still doesn't have native blur support (like imageView.blur(radius, sampling)? I guess it should be done in C or C++ since its a lot of calculations, but I can't imagine Google not having the capacity to find a way... Can anyone share their experiences with blurring? Maybe some hacks/libs that worked really well?
2
u/[deleted] Jul 20 '20
All libraries I have been using needed renderscript properties set in build.gradle to work, so I guess they did use it in the background. Still, its hard to explain why an iPhone can have realtime blur and Android can't. One library even had the option to calculate blur only once (for static content) but it still lagged when the entire page (blur + bg) was scrolling. Without the blur everything is super smooth so the problem should not be in the rest of the design or that something might be hogging the main thread.