fix: improve fallback bitmap creation in AccountImageModelLoader fix bug...
Closes e/backlog#8834
Problem The app was crashing with IllegalArgumentException: width and height must be > 0 when Glide tried to load account images. This occurred in AccountImageDataFetcher.createFallbackBitmap() when the drawable returned by AccountFallbackImageProvider had zero or negative intrinsic dimensions.
Root Cause The toBitmap() extension function was called without explicit dimensions, causing Android to use the drawable's intrinsic dimensions. When these were invalid (≤ 0), Bitmap.createBitmap() failed with the exception.
Solution Added dimension validation before bitmap creation Implemented fallback to safe default dimensions (168x168) when intrinsic dimensions are invalid Set proper bounds on the drawable before conversion Pass explicit dimensions to toBitmap(width, height) to prevent the crash
Impact Fixes: Eliminates the crash when loading account profile images Maintains: Existing functionality for valid drawables Improves: App stability and user experience No breaking changes: Minimal modification to existing code
Testing The fix handles edge cases where drawables may not have proper intrinsic dimensions, ensuring robust image loading for all account types.
Summary by CodeRabbit
-
Bug Fixes
- Ensures fallback account images render at a consistent, non-zero size, preventing occasional blank or tiny avatars.
- Improves visual consistency of placeholder avatars for accounts without custom icons, resulting in sharper, correctly bounded images.
- Provides more reliable avatar display across devices and screen densities by standardizing how fallback images are sized and drawn.