Skip to content

Commit

Permalink
[TabletGTS] Fix startup NPE crash when attempting to show GTS
Browse files Browse the repository at this point in the history
Fix startup NPE crash when attempting to show GTS.
-Crash occurs because mLayoutManager is null when we call
 isLayoutVisible(). This occurs on startup because we register the
 listener, a new tab is created because there are no open tabs, the
 creation of the first new tab triggers onTabModelSelected, then the NPE
 occurs.
-Speculative fix is to add null check.

(cherry picked from commit 3106964)

Bug: 1329651
Change-Id: Iab1f1caa7d0f928038efdf92e409860cb8d27b64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3668919
Commit-Queue: Neil Coronado <nemco@google.com>
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Reviewed-by: Sirisha Kavuluru <skavuluru@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1009205}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3687360
Commit-Queue: Theresa Sullivan <twellington@chromium.org>
Auto-Submit: Neil Coronado <nemco@google.com>
Cr-Commit-Position: refs/branch-heads/5060@{#499}
Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
  • Loading branch information
Neil Coronado authored and Chromium LUCI CQ committed Jun 2, 2022
1 parent 620042d commit 965e613
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,10 @@ public void multipleTabsPendingClosure(List<Tab> tabs, boolean isAllTabs) {
}

private void openTabletTabSwitcherIfNoTabs() {
if (!isTablet()) return;
if (!isTablet() || mLayoutManager == null
|| !mTabModelOrchestrator.areTabModelsInitialized()) {
return;
}

boolean gridTabSwitcherEnabled = TabUiFeatureUtilities.isTabletGridTabSwitcherEnabled(this);
boolean overviewVisible = mLayoutManager.isLayoutVisible(LayoutType.TAB_SWITCHER);
Expand Down

0 comments on commit 965e613

Please sign in to comment.