From 55d75ec73ce2603d0ba337f1a940803b3a92f25e Mon Sep 17 00:00:00 2001 From: Jernej Virag Date: Thu, 15 Jun 2023 14:50:25 +0200 Subject: [PATCH] Don't create copies of Icon bitmaps for Smartspace We're serializing and transporting bitmaps as Icons via IPC. Right now, this creates new copies when deserializing, which can create significant increase in RSS+Anon memory usage in SysUI. This change uses the same approach as Notification.java, where Icons are stored in ashmem before being transported over IPC - this means we ever only deserialize a buffer pointer. Bug:287201133 Bug:275486055 Test: verified drop in RSS with perfetto on cheetah, cycling lockscreen 200 times Change-Id: I6b3a73732e3c49d04e28bdf1bf2e7c9638e61520 --- core/java/android/app/smartspace/SmartspaceAction.java | 4 ++++ core/java/android/app/smartspace/uitemplatedata/Icon.java | 1 + 2 files changed, 5 insertions(+) diff --git a/core/java/android/app/smartspace/SmartspaceAction.java b/core/java/android/app/smartspace/SmartspaceAction.java index f17b044f79968..4475fc56b92d4 100644 --- a/core/java/android/app/smartspace/SmartspaceAction.java +++ b/core/java/android/app/smartspace/SmartspaceAction.java @@ -348,6 +348,10 @@ public final class SmartspaceAction implements Parcelable { */ @NonNull public SmartspaceAction build() { + if (mIcon != null) { + mIcon.convertToAshmem(); + } + return new SmartspaceAction(mId, mIcon, mTitle, mSubtitle, mContentDescription, mPendingIntent, mIntent, mUserHandle, mExtras); } diff --git a/core/java/android/app/smartspace/uitemplatedata/Icon.java b/core/java/android/app/smartspace/uitemplatedata/Icon.java index 6bdc926e7cf38..b9d90bfdb6e4e 100644 --- a/core/java/android/app/smartspace/uitemplatedata/Icon.java +++ b/core/java/android/app/smartspace/uitemplatedata/Icon.java @@ -171,6 +171,7 @@ public final class Icon implements Parcelable { */ @NonNull public Icon build() { + mIcon.convertToAshmem(); return new Icon(mIcon, mContentDescription, mShouldTint); } }