Commit b7b17e91 authored by lizeb's avatar lizeb Committed by Commit bot

android: Allow disk reads for layout inflation.

Layout inflation on the UI thread triggers StrictMode violations on some
devices. Temporarily allow disk reads, as the inflation should happen on
the UI thread, and the reads are inside the framework's code.

BUG=644243

Review-Url: https://codereview.chromium.org/2355263002
Cr-Commit-Position: refs/heads/master@{#420595}
parent 227f0c1f
......@@ -6,6 +6,7 @@ package org.chromium.chrome.browser;
import android.content.Context;
import android.os.AsyncTask;
import android.os.StrictMode;
import android.view.ContextThemeWrapper;
import android.view.InflateException;
import android.view.LayoutInflater;
......@@ -71,6 +72,10 @@ public final class WarmupManager {
*/
public void initializeViewHierarchy(Context baseContext, int toolbarContainerId) {
TraceEvent.begin("WarmupManager.initializeViewHierarchy");
// Inflating the view hierarchy causes StrictMode violations on some
// devices. Since layout inflation should happen on the UI thread, allow
// the disk reads. crbug.com/644243.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
ThreadUtils.assertOnUiThread();
if (mMainView != null && mToolbarContainerId == toolbarContainerId) return;
......@@ -90,6 +95,7 @@ public final class WarmupManager {
Log.e(TAG, "Inflation exception.", e);
mMainView = null;
} finally {
StrictMode.setThreadPolicy(oldPolicy);
TraceEvent.end("WarmupManager.initializeViewHierarchy");
}
}
......
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