Commit 8dd13b61 authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Release thumbnail when TabGridView is recycled

This depends on https://crrev.com/c/1595292 to actually release the
memory of the Bitmap.

On Pixel 2 XL, before this CL, there can be up to 8 (visible or
to-be-visible cards) + 5 (recycled in the view pool) thumbnail Bitmaps
in the memory after GC when GTS is visible. After hiding GTS, there are
still 5 Bitmaps in the recycled views after GC. This CL addresses the
recycled views in the pool.

Bug: 959054
Change-Id: I601417e5d2e67eafd69aee36fe00614beb046aff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1595128
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661105}
parent a99b31e5
...@@ -76,8 +76,7 @@ class TabGridViewBinder { ...@@ -76,8 +76,7 @@ class TabGridViewBinder {
if (fetcher == null) return; if (fetcher == null) return;
Callback<Bitmap> callback = result -> { Callback<Bitmap> callback = result -> {
if (result == null) { if (result == null) {
holder.thumbnail.setImageResource(0); holder.resetThumbnail();
holder.thumbnail.setMinimumHeight(holder.thumbnail.getWidth());
} else { } else {
holder.thumbnail.setImageBitmap(result); holder.thumbnail.setImageBitmap(result);
} }
......
...@@ -71,4 +71,9 @@ class TabGridViewHolder extends RecyclerView.ViewHolder { ...@@ -71,4 +71,9 @@ class TabGridViewHolder extends RecyclerView.ViewHolder {
public int getTabId() { public int getTabId() {
return mTabId; return mTabId;
} }
public void resetThumbnail() {
thumbnail.setImageResource(0);
thumbnail.setMinimumHeight(thumbnail.getWidth());
}
} }
...@@ -83,8 +83,13 @@ public class TabListCoordinator implements Destroyable { ...@@ -83,8 +83,13 @@ public class TabListCoordinator implements Destroyable {
RecyclerViewAdapter adapter; RecyclerViewAdapter adapter;
if (mMode == TabListMode.GRID) { if (mMode == TabListMode.GRID) {
SimpleRecyclerViewMcpBase<PropertyModel, TabGridViewHolder, PropertyKey> mcp = SimpleRecyclerViewMcpBase<PropertyModel, TabGridViewHolder, PropertyKey> mcp =
new SimpleRecyclerViewMcpBase<>( new SimpleRecyclerViewMcpBase<PropertyModel, TabGridViewHolder, PropertyKey>(
null, TabGridViewBinder::onBindViewHolder, tabListModel); null, TabGridViewBinder::onBindViewHolder, tabListModel) {
@Override
public void onViewRecycled(TabGridViewHolder viewHolder) {
viewHolder.resetThumbnail();
}
};
adapter = new RecyclerViewAdapter<>(mcp, TabGridViewHolder::create); adapter = new RecyclerViewAdapter<>(mcp, TabGridViewHolder::create);
mModelChangeProcessor = mcp; mModelChangeProcessor = mcp;
} else if (mMode == TabListMode.STRIP) { } else if (mMode == TabListMode.STRIP) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment