Commit 5c05acad authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

[Instant start] Fix a crash with GTS enable_launch_polish

crrev.com/c/2402302 assumes TabModelSelector is always initialized
which is no longer true with Instant start enabled. This CL fixes the
wrong assumption by checking the TabModelSelector initialization state
before accessing the TabModelSelector.

Because of Instant start, we should always use the cached flag/value.
We need to get the thumbnail aspect ratio from the
TabUiFeatureUtilities#THUMBNAIL_ASPECT_RATIO instead of
ChromeFeatureList#getFieldTrialParamByFeatureAsDouble which requires
native initialization. We update all the usages to use the cached value
in crrev.com/c/2427149.

This CL is verified to be behind the gating function
TabUiFeatureUtilities#isLaunchPolishEnabled by formal equivalence
checking tool here: http://crrev.com/c/1934235.

Change-Id: Ib4e72d9535328034a3914adec44ea744826d92cb
Bug: 1131441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427345
Commit-Queue: Mei Liang <meiliang@chromium.org>
Reviewed-by: default avatarXi Han <hanxi@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810379}
parent de325737
......@@ -308,10 +308,13 @@ public class InstantStartTest {
@Restriction({UiRestriction.RESTRICTION_TYPE_PHONE})
// clang-format off
@EnableFeatures({ChromeFeatureList.TAB_SWITCHER_ON_RETURN + "<Study,",
ChromeFeatureList.START_SURFACE_ANDROID + "<Study"})
ChromeFeatureList.START_SURFACE_ANDROID + "<Study",
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID + "<Study",
ChromeFeatureList.TAB_GROUPS_ANDROID,
ChromeFeatureList.TAB_GROUPS_CONTINUATION_ANDROID})
@CommandLineFlags.Add({ChromeSwitches.DISABLE_NATIVE_INITIALIZATION,
"force-fieldtrials=Study/Group",
IMMEDIATE_RETURN_PARAMS + "/start_surface_variation/single"})
IMMEDIATE_RETURN_PARAMS + "/start_surface_variation/single/enable_launch_polish/true"})
public void startSurfaceSinglePanePreNativeAndWithNativeTest() {
// clang-format on
startMainActivityFromLauncher();
......
......@@ -274,9 +274,7 @@ public class TabListCoordinator implements Destroyable {
private static void setThumbnailViewAspectRatio(View view) {
float mExpectedThumbnailAspectRatio =
(float) ChromeFeatureList.getFieldTrialParamByFeatureAsDouble(
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID,
TabUiFeatureUtilities.THUMBNAIL_ASPECT_RATIO_PARAM, 1.0);
(float) TabUiFeatureUtilities.THUMBNAIL_ASPECT_RATIO.getValue();
mExpectedThumbnailAspectRatio = MathUtils.clamp(mExpectedThumbnailAspectRatio, 0.5f, 2.0f);
TabGridThumbnailView thumbnailView =
(TabGridThumbnailView) view.findViewById(R.id.tab_thumbnail);
......
......@@ -180,6 +180,8 @@ public class TabSwitcherCoordinator
@Override
public void finishedShowing() {
if (!mTabModelSelector.isTabStateInitialized()) return;
int selectedIndex = mTabModelSelector.getTabModelFilterProvider()
.getCurrentTabModelFilter()
.index();
......
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