Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.49k stars 331 forks source link

SizeScalar.isZeroSized does not account for very small heights #142

Closed sfuqua closed 3 years ago

sfuqua commented 3 years ago

Consuming lib version 1.6.4 via React Native, on an Android SDK 30 emulator. Trying to debug a crash that is impacting my customers in production, but I can only repro on an emulator atm.

Given that it's a React Native setup I don't have an XML layout to share, but I'm hopeful I can describe the issue well enough.

I am seeing a crash due to BlockingBlurController.allocateBitmap trying to allocate a height of 0.

When this happens, the unscaled height is 3, which gets scaled to 0. I'm still trying to figure out why my app is trying to render a BlurView with a height of 3, but in the meantime... :)

I noticed that BlockingBlurController.init looks like it intends to handle this case with a SizeScaler.isZeroSized call which is not getting hit in my case. I suspect this is because SizeScalar.downscaleSize has a Math.ceil call inside, so downscaleSize is returning 1 (non-zero), but when the BlurController calls SizeScalar.scale with a height of 3, it gets rounded to 0 and we crash.

I'm not sure what a proper fix would be from the lib's perspective or I'd help with a PR. Maybe:

sfuqua commented 3 years ago

Actually I think 131d3db7cd38bd6b09acedbbe49842913a0fb2c9 (the fix for #125) will mitigate this, apologies for not running the latest. Will update to 1.6.5+