New issue
Advanced search Search tips

Issue 704483 link

Starred by 1 user

Issue metadata

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



Sign in to add a comment

SharedPreference causing a StrictMode violation in Custom Tabs

Project Member Reported by lizeb@chromium.org, Mar 23 2017

Issue description

From a client stack trace:

03-12 19:09:05.006 D/StrictMode(17301): StrictMode policy violation; ~duration=9 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=4522015 violation=2
03-12 19:09:05.006 D/StrictMode(17301):         at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1415)
03-12 19:09:05.006 D/StrictMode(17301):         at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
03-12 19:09:05.006 D/StrictMode(17301):         at java.io.File.exists(File.java:807)
03-12 19:09:05.006 D/StrictMode(17301):         at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:531)
03-12 19:09:05.006 D/StrictMode(17301):         at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:522)
03-12 19:09:05.006 D/StrictMode(17301):         at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:478)
03-12 19:09:05.006 D/StrictMode(17301):         at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:659)
03-12 19:09:05.006 D/StrictMode(17301):         at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:355)
03-12 19:09:05.006 D/StrictMode(17301):         at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
03-12 19:09:05.006 D/StrictMode(17301):         at org.chromium.chrome.browser.customtabs.RequestThrottler.purgeOldEntries(RequestThrottler.java:214)
03-12 19:09:05.006 D/StrictMode(17301):         at org.chromium.chrome.browser.customtabs.RequestThrottler.getForUid(RequestThrottler.java:131)
03-12 19:09:05.006 D/StrictMode(17301):         at org.chromium.chrome.browser.customtabs.ClientManager.updateStatsAndReturnWhetherAllowed(ClientManager.java:254)
03-12 19:09:05.006 D/StrictMode(17301):         at org.chromium.chrome.browser.customtabs.CustomTabsConnection.mayLaunchUrl(CustomTabsConnection.java:2405)
03-12 19:09:05.006 D/StrictMode(17301):         at org.chromium.chrome.browser.customtabs.CustomTabsConnectionService.mayLaunchUrl(CustomTabsConnectionService.java:64)
03-12 19:09:05.006 D/StrictMode(17301):         at android.support.customtabs.CustomTabsService$1.mayLaunchUrl(CustomTabsService.java:113)
03-12 19:09:05.006 D/StrictMode(17301):         at android.support.customtabs.ICustomTabsService$Stub.onTransact(ICustomTabsService.java:90)
03-12 19:09:05.006 D/StrictMode(17301):         at android.os.Binder.execTransact(Binder.java:618)
03-12 19:09:05.006 D/StrictMode(17301): # via Binder call with stack:
03-12 19:09:05.006 D/StrictMode(17301): android.os.StrictMode$LogStackTrace
03-12 19:09:05.006 D/StrictMode(17301):         at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:2108)
03-12 19:09:05.006 D/StrictMode(17301):         at android.os.Parcel.readExceptionCode(Parcel.java:1884)
03-12 19:09:05.006 D/StrictMode(17301):         at android.os.Parcel.readException(Parcel.java:1853)
03-12 19:09:05.006 D/StrictMode(17301):         at android.support.customtabs.ICustomTabsService$Stub$Proxy.mayLaunchUrl(ICustomTabsService.java:249)
03-12 19:09:05.006 D/StrictMode(17301):         at android.support.customtabs.CustomTabsSession.mayLaunchUrl(CustomTabsSession.java:70)

See internal bug 36182854.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Apr 24 2017

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

commit 6687e9804bcef77c2a9b687d65b9ca65951b352a
Author: lizeb <lizeb@chromium.org>
Date: Mon Apr 24 19:39:27 2017

customtabs: Read the SharedPreferences early to avoid StrictMode violations.

The first access to SharedPreferences causes a StrictMode violation
since it touches the disk. Read the preferences in a background thread
as soon as possible to avoid this.

BUG= 704483 

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

[modify] https://crrev.com/6687e9804bcef77c2a9b687d65b9ca65951b352a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionService.java

Comment 2 by lizeb@chromium.org, Apr 25 2017

Status: Fixed (was: Started)

Sign in to add a comment