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

Issue 710745 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Long OOO (go/where-is-mgiuca)
Closed: Apr 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android
Pri: 1
Type: Bug



Sign in to add a comment

getInstalledRelatedApps blocks UI thread while doing its work

Project Member Reported by mgiuca@chromium.org, Apr 12 2017

Issue description

Steps to reproduce:

1. Have an Android APK with a 200,000 related apps in it (or, really, just hack the code in InstalledAppProviderImpl.java to execute that for loop 200,000 times).
2. Point your manifest at that APK.
3. Call navigator.getInstalledRelatedApps().

This will take seconds to check whether each app is installed and related, blocking the UI thread until it is complete. In reality, there won't be 200,000 apps (likely to be at most 1, though there could be outliers or attackers), which will take ~2-10 ms. However, we still don't want to block the UI thread while doing this sort of computation on an arbitrarily large user-supplied input.

Move it onto a background thread using an AsyncTask.
 
Project Member

Comment 2 by bugdroid1@chromium.org, Apr 13 2017

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

commit ad0f03580fa8c308ee7f63f62489f7c322df1ac9
Author: mgiuca <mgiuca@chromium.org>
Date: Thu Apr 13 02:07:45 2017

getInstalledRelatedApps: Avoid blocking the UI thread doing computation.

Performs the computation on a background thread, so the UI is responsive
while a result from this API is pending.

BUG= 710745 

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

[modify] https://crrev.com/ad0f03580fa8c308ee7f63f62489f7c322df1ac9/content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderImpl.java
[modify] https://crrev.com/ad0f03580fa8c308ee7f63f62489f7c322df1ac9/content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java

Comment 3 by mgiuca@chromium.org, Apr 13 2017

Status: Fixed (was: Started)
Project Member

Comment 4 by bugdroid1@chromium.org, May 11 2017

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

commit 25a9390dce3a08a787c852a3d381322767dace3c
Author: mgiuca <mgiuca@chromium.org>
Date: Thu May 11 02:59:27 2017

InstalledAppProviderImpl: Assert that code is run off the UI thread.

Adds methods to ThreadUtils to support this: a new
assertOnBackgroundThread to complement assertOnUiThread, as well as a
way to disable these checks for testing (since the tests are
single-threaded).

BUG= 710745 

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

[modify] https://crrev.com/25a9390dce3a08a787c852a3d381322767dace3c/base/android/java/src/org/chromium/base/ThreadUtils.java
[modify] https://crrev.com/25a9390dce3a08a787c852a3d381322767dace3c/content/public/android/java/src/org/chromium/content/browser/installedapp/InstalledAppProviderImpl.java
[modify] https://crrev.com/25a9390dce3a08a787c852a3d381322767dace3c/content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java

Sign in to add a comment