fix: disable hardware bitmaps for notification icons to avoid StrictMode violation
Hardware bitmaps cannot be efficiently read for pixels, which is required when parceling notifications. Adding allowHardware(false) to all image requests used for notification bitmaps prevents the slow pixel readback. https://claude.ai/code/session_018y75qshU48REuHXxLH3Tmb
This commit is contained in:
@@ -507,7 +507,12 @@ class CallController(
|
||||
callerUser?.profilePicture()?.let { pictureUrl ->
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val request = ImageRequest.Builder(context).data(pictureUrl).build()
|
||||
val request =
|
||||
ImageRequest
|
||||
.Builder(context)
|
||||
.data(pictureUrl)
|
||||
.allowHardware(false)
|
||||
.build()
|
||||
val result = ImageLoader(context).execute(request)
|
||||
(result.image?.asDrawable(context.resources) as? android.graphics.drawable.BitmapDrawable)?.bitmap
|
||||
} catch (_: Exception) {
|
||||
|
||||
+6
-1
@@ -644,7 +644,12 @@ class EventNotificationConsumer(
|
||||
callerUser?.profilePicture()?.let { pictureUrl ->
|
||||
kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
|
||||
try {
|
||||
val request = ImageRequest.Builder(applicationContext).data(pictureUrl).build()
|
||||
val request =
|
||||
ImageRequest
|
||||
.Builder(applicationContext)
|
||||
.data(pictureUrl)
|
||||
.allowHardware(false)
|
||||
.build()
|
||||
val result = ImageLoader(applicationContext).execute(request)
|
||||
(result.image?.asDrawable(applicationContext.resources) as? BitmapDrawable)?.bitmap
|
||||
} catch (_: Exception) {
|
||||
|
||||
+6
-1
@@ -272,7 +272,12 @@ object NotificationUtils {
|
||||
): Bitmap? =
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val request = ImageRequest.Builder(applicationContext).data(pictureUrl).build()
|
||||
val request =
|
||||
ImageRequest
|
||||
.Builder(applicationContext)
|
||||
.data(pictureUrl)
|
||||
.allowHardware(false)
|
||||
.build()
|
||||
val imageLoader = SingletonImageLoader.get(applicationContext)
|
||||
val result = imageLoader.execute(request)
|
||||
(result.image?.asDrawable(applicationContext.resources) as? BitmapDrawable)?.bitmap
|
||||
|
||||
Reference in New Issue
Block a user