From a110072a44c58d8d0cdee1d6916539602a66e9eb Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Wed, 15 Jun 2022 22:35:21 +0000 Subject: Proactively unparcel bitmaps in MediaMetadata This ensures that the GC accounts for the underlying allocations Bug: 215820910 Test: Manual Change-Id: I6b1d3f17abdb513b1ac929267b3d386326fa83c4 --- media/java/android/media/MediaMetadata.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/media/java/android/media/MediaMetadata.java b/media/java/android/media/MediaMetadata.java index 9976fa11d177..db5e52a44c8a 100644 --- a/media/java/android/media/MediaMetadata.java +++ b/media/java/android/media/MediaMetadata.java @@ -429,6 +429,15 @@ public final class MediaMetadata implements Parcelable { private MediaMetadata(Parcel in) { mBundle = in.readBundle(); mBitmapDimensionLimit = Math.max(in.readInt(), 1); + + // Proactively read bitmaps from known bitmap keys, to ensure that they're unparceled and + // added to mBundle's internal map. This ensures that the GC accounts for the underlying + // allocations, which it does not do if the bitmaps remain parceled (see b/215820910). + // TODO(b/223225532): Remove this workaround once the underlying allocations are properly + // tracked in NativeAllocationsRegistry. + getBitmap(METADATA_KEY_ART); + getBitmap(METADATA_KEY_ALBUM_ART); + getBitmap(METADATA_KEY_DISPLAY_ICON); } /** -- cgit v1.2.3-59-g8ed1b