New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 702998 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Incorrect webapp behavior on Kitkat when reusing old WebappActivity

Project Member Reported by pkotw...@chromium.org, Mar 19 2017

Issue description

Repro steps:
1) Add 11 PWA shortcuts to the homescreen (not WebAPKs). I added shortcuts for everything in https://pwa.rocks
2) Open all 11 PWA shortcuts

Expected:
11th shortcut uses one of the already existing activities and navigates it to the webapp's start URL
Actual:
WebappActivity's WebappInfo is replaced. However, the WebappActivity is not navigated to the new URL
 
Cc: dominickn@chromium.org pkotw...@chromium.org
Components: Content>WebApps Mobile>WebAPKs
Labels: OS-Android
Owner: hanxi@chromium.org
Status: Assigned (was: Untriaged)
Xi, can you please take a look at this bug? There is similar badness in WebApkActivity. For instance, we will not create a new WebApkUpdateManager

Comment 2 by hanxi@chromium.org, Mar 20 2017

Sure, will take a look.

Comment 3 by hanxi@chromium.org, Mar 29 2017

Cc: dfalcant...@chromium.org
In WebappActivity#initilizeUI(), it only loads URL when the tab doesn't load a URL yet. See https://cs.chromium.org/chromium/src/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java?rcl=9312812efaf6c85af28e79ce156af00e754d4b0e&l=128.

I removed the "if (TextUtils.isEmpty(getActivityTab().getUrl()))" check, the new URL will be loaded, but since loading takes some time, users will see the previous Web apps brought to foreground first, and then the screen changes to the new URL without splash screen.

Is this the designed behavior? I guess it depends on how much we want to change the behavior. When ActivityAssigner assign an WebApkAcitivity{i} to the 11th Web app, do we want to check the Chrome's activity list and close the previous one first? The transition might looks natural than refocusing the activity via onNewIntent?

+dfalcantara.
Yeah I'm guessing that onNewIntent has been broken since data was added to the WebappInfo, but Android has never been able to keep 11 of our tabs open so we didn't notice (whoops).

Your proposal sounds fine... it's worth killing the old one before reassigning it so that the old web app contents doesn't show up at all.  That might allow the new web app's splash screen to show up, too.

I'm confused about how this is specifically being hit though.  initializeUI should have already been called by that point, so it shouldn't go through there again.  Looks like a race condition where you smack all the launcher icons at once before the WebappActivity can finish loading.  You'd likely have to account for the other case where the WebappActivity is already initialized and the WebappInfo IDs don't match (so a combination of conditions two and three in WebappActivity#onNewIntent.
Dan, this is how the scenario gets hit:

You open 10 webapps. WebappActivity#initializeUI() is called for all 10 webapps. Tab#getUrl() is non empty for all 10 webapps

You open an 11th webapp.
WebappActivity#onNewIntent() calls WebappActivity#initializeUI().
WebappActivity#initializeUI() does nothing because Tab#getUrl() is non-empty
That's what I'm confused about: onNewIntent shouldn't be able to call initializeUI again.  mIsInitialized should have been set by finishInitialization, unless that gets called because the WebappActivity died and finishNativeInitialization() hadn't been called when it restarted.
Dan: onNewIntent() calls initializeUI() only if mIsInitialized is true
Ah, I'm great at reading.  Rest of the comment still stands, though.  That conditional should probably be revisited.
Project Member

Comment 9 by bugdroid1@chromium.org, Apr 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/50b74d197d3c435b1b3d1dd590239b7f40ba90ee

commit 50b74d197d3c435b1b3d1dd590239b7f40ba90ee
Author: hanxi <hanxi@chromium.org>
Date: Wed Apr 05 16:50:31 2017

Fix Incorrect webapp behavior on Kitkat when reusing old WebappActivity.

If we creates 11 PWA shortcuts and open them all, the last one uses one of
the already existing activities but isn't navigated to the new URL. To fix this,
we finish the existing activity if it is still running, and therefore, a new
WebappActivity will be created and splash screen will show up too.

BUG= 702998 

Review-Url: https://codereview.chromium.org/2791383002
Cr-Commit-Position: refs/heads/master@{#462115}

[modify] https://crrev.com/50b74d197d3c435b1b3d1dd590239b7f40ba90ee/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java
[modify] https://crrev.com/50b74d197d3c435b1b3d1dd590239b7f40ba90ee/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappLauncherActivity.java

Status: Fixed (was: Assigned)

Sign in to add a comment