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

Fix blank card issue in Grid Tab Switcher

In getTabThumbnailWithCallback() with forceUpdate == true,
cacheTabThumbnail() should be called after the callback of
nativeGetTabThumbnailWithCallback(). Otherwise there is no guarantee
the callback of cacheTabThumbnail() would be run after the callback
of nativeGetTabThumbnailWithCallback().

Bug: 965891
Change-Id: Ia8cf42f4942d569e4b646820063460a297160d9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1629808Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664364}
parent 9f5048d1
......@@ -263,11 +263,15 @@ public class TabContentManager {
Tab tab, Callback<Bitmap> callback, boolean forceUpdate) {
if (mNativeTabContentManager == 0 || !mSnapshotsEnabled) return;
if (!forceUpdate) {
nativeGetTabThumbnailWithCallback(mNativeTabContentManager, tab.getId(), callback);
return;
}
// Reading thumbnail from disk is faster than taking screenshot from live Tab, so fetch
// that first even if |forceUpdate|.
nativeGetTabThumbnailWithCallback(mNativeTabContentManager, tab.getId(), callback);
if (forceUpdate) {
nativeGetTabThumbnailWithCallback(mNativeTabContentManager, tab.getId(), (diskBitmap) -> {
callback.onResult(diskBitmap);
cacheTabThumbnail(tab, (bitmap) -> {
// Null check to avoid having a Bitmap from nativeGetTabThumbnailWithCallback() but
// cleared here.
......@@ -277,7 +281,7 @@ public class TabContentManager {
callback.onResult(bitmap);
}
});
}
});
}
/**
......
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