Commit 0dfe9ba2 authored by feng's avatar feng Committed by Commit bot

[Android] Initialize CommandLine before any usage in Render.

On low-end devices, if Chrome was upgraded from a previous version,
Chrome decides to use normal mode to keep user experience consistent.
This is done by force '--low-end-device-mode=0' on both browser and render
processes.

However, when crazy linker is used, Linker.isUsed() triggers
SysUtils.detectLowEndDevice() call which checks CommandLine first.
Existing code invokes Linker.isUsed() before initilizing CommandLine,
which causes the render process ignores '--low-end-device-mode=0'.

This results the browser in normal mode, but render is in low-end device mode.

BUG=424228

Review URL: https://codereview.chromium.org/665273003

Cr-Commit-Position: refs/heads/master@{#301581}
parent 08114182
......@@ -103,14 +103,13 @@ public class SysUtils {
}
private static boolean detectLowEndDevice() {
if (CommandLine.isInitialized()) {
assert CommandLine.isInitialized();
if (CommandLine.getInstance().hasSwitch(BaseSwitches.LOW_END_DEVICE_MODE)) {
int mode = Integer.parseInt(CommandLine.getInstance().getSwitchValue(
BaseSwitches.LOW_END_DEVICE_MODE));
if (mode == 1) return true;
if (mode == 0) return false;
}
}
if (Build.VERSION.SDK_INT <= ANDROID_LOW_MEMORY_ANDROID_SDK_THRESHOLD) {
return false;
......
......@@ -130,6 +130,14 @@ public class ChildProcessService extends Service {
@Override
public void run() {
try {
// CommandLine must be initialized before others, e.g., Linker.isUsed()
// may check the command line options.
synchronized (mMainThread) {
while (mCommandLineParams == null) {
mMainThread.wait();
}
}
CommandLine.init(mCommandLineParams);
boolean useLinker = Linker.isUsed();
boolean requestedSharedRelro = false;
if (useLinker) {
......@@ -138,7 +146,7 @@ public class ChildProcessService extends Service {
mMainThread.wait();
}
}
if (mLinkerParams != null) {
assert mLinkerParams != null;
if (mLinkerParams.mWaitForSharedRelro) {
requestedSharedRelro = true;
Linker.initServiceProcess(mLinkerParams.mBaseLoadAddress);
......@@ -147,14 +155,7 @@ public class ChildProcessService extends Service {
}
Linker.setTestRunnerClassName(mLinkerParams.mTestRunnerClassName);
}
}
boolean isLoaded = false;
synchronized (mMainThread) {
while (mCommandLineParams == null) {
mMainThread.wait();
}
}
CommandLine.init(mCommandLineParams);
if (CommandLine.getInstance().hasSwitch(
BaseSwitches.RENDERER_WAIT_FOR_JAVA_DEBUGGER)) {
android.os.Debug.waitForDebugger();
......@@ -254,8 +255,8 @@ public class ChildProcessService extends Service {
synchronized (mMainThread) {
mCommandLineParams = intent.getStringArrayExtra(
ChildProcessConnection.EXTRA_COMMAND_LINE);
mLinkerParams = null;
if (Linker.isUsed())
// mLinkerParams is never used if Linker.isUsed() returns false.
// See onCreate().
mLinkerParams = new ChromiumLinkerParams(intent);
mIsBound = true;
mMainThread.notifyAll();
......
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