Commit 75c4ac5e authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Reland "Remoting: Enable Proguard tree-shaking to reduce method count"

This reverts commit 3e5e2582.

Reason for reland: Added proguard_enabled = true to test apk

Original change's description:
> Revert "Remoting: Enable Proguard tree-shaking to reduce method count"
>
> This reverts commit f31ef558.
>
> Reason for revert: compile failure on android-archive-rel: https://ci.chromium.org/p/chromium/builders/ci/android-archive-rel/6720
>
> Original change's description:
> > Remoting: Enable Proguard tree-shaking to reduce method count
> >
> > Bots are failing because remoting_apk is over the single dex method
> > limit.
> >
> > TESTED=Launched app and made sure it didn't crash.
> >
> > NOTRY=true  # Previous patchset passed. Urgent to fix build.
> >
> > Bug: 1026161
> > Change-Id: I2156f84d55ff214eab5cf0d77811baaa3b5f77e8
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925215
> > Commit-Queue: Andrew Grieve <agrieve@chromium.org>
> > Reviewed-by: Eric Stevenson <estevenson@chromium.org>
> > Reviewed-by: Lambros Lambrou <lambroslambrou@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#716776}
>
> TBR=lambroslambrou@chromium.org,agrieve@chromium.org,estevenson@chromium.org
>
> Change-Id: I67d7c775be0d06f04bcf69f9331bceb364642fcc
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1026161
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925513
> Reviewed-by: Tommy Steimel <steimel@chromium.org>
> Commit-Queue: Tommy Steimel <steimel@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#716798}

TBR=lambroslambrou@chromium.org,agrieve@chromium.org,estevenson@chromium.org,steimel@chromium.org

Change-Id: I9e9e301a86c9a75d615df713884777b80bdbba8a
Bug: 1026161
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925786Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716886}
parent 6404bad3
......@@ -64,3 +64,15 @@
# Allowing Proguard to change modifiers. This change shrinks the .dex size by
# ~1%, and reduces the method count by ~4%.
-allowaccessmodification
# Workaround for crbug/1002847. Methods of BaseGmsClient are incorrectly
# removed even though they are required for the derived class GmsClient
# to correctly implement Api$Client.
# TODO: remove once crbug/1002847 resolved.
-keep public class com.google.android.gms.common.internal.BaseGmsClient {
public void disconnect();
public void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]);
public int getMinApkVersion();
public boolean requiresSignIn();
}
......@@ -157,9 +157,9 @@ def _ParseOptions():
action='store_true',
help='Disable the outlining optimization provided by R8.')
parser.add_argument(
'--is-test-only',
'--disable-checkdiscard',
action='store_true',
help='Disables some optimizations that don\'t make sense for tests.')
help='Disable -checkdiscard directives')
options = parser.parse_args(args)
......@@ -435,7 +435,7 @@ def main():
_VerifyNoEmbeddedConfigs(options.input_paths + libraries)
proguard_configs = options.proguard_configs
if options.is_test_only:
if options.disable_checkdiscard:
proguard_configs = _ValidateAndFilterCheckDiscards(proguard_configs)
# ProGuard configs that are derived from flags.
......
......@@ -1024,8 +1024,9 @@ if (enable_java_templates) {
args += [ "--disable-outlining" ]
}
if (defined(testonly) && testonly) {
args += [ "--is-test-only" ]
if (defined(invoker.disable_checkdiscard) &&
invoker.disable_checkdiscard) {
args += [ "--disable-checkdiscard" ]
}
if (defined(invoker.is_static_library) && invoker.is_static_library) {
......@@ -1190,6 +1191,7 @@ if (enable_java_templates) {
forward_variables_from(invoker,
[
"build_config",
"disable_checkdiscard",
"disable_r8_outlining",
"deps",
"failed_proguard_expectation_file",
......
......@@ -2125,6 +2125,8 @@ if (enable_java_templates) {
# (optional).
# product_config_java_packages: Optional list of java packages. If given, a
# ProductConfig.java file will be generated for each package.
# disable_checkdiscard: Turn off -checkdiscard directives in the proguard
# step.
# disable_r8_outlining: Turn off outlining during the proguard step.
# annotation_processor_deps: List of java_annotation_processor targets to
# use when compiling the java_files given to this target (optional).
......@@ -2922,6 +2924,7 @@ if (enable_java_templates) {
dex(_final_dex_target_name) {
forward_variables_from(invoker,
[
"disable_checkdiscard",
"disable_r8_outlining",
"min_sdk_version",
"dexlayout_profile",
......@@ -3408,6 +3411,7 @@ if (enable_java_templates) {
"data_deps",
"deps",
"dexlayout_profile",
"disable_checkdiscard",
"disable_r8_outlining",
"dist_ijar_path",
"enable_chromium_linker_tests",
......@@ -3744,6 +3748,7 @@ if (enable_java_templates) {
proguard_configs = []
}
proguard_configs += [ "//testing/android/proguard_for_test.flags" ]
disable_checkdiscard = true
if (defined(final_apk_path)) {
_final_apk_path = final_apk_path
} else {
......
......@@ -140,6 +140,17 @@
# ~1%, and reduces the method count by ~4%.
-allowaccessmodification
# Workaround for crbug/1002847. Methods of BaseGmsClient are incorrectly
# removed even though they are required for the derived class GmsClient
# to correctly implement Api$Client.
# TODO: remove once crbug/1002847 resolved.
-keep public class com.google.android.gms.common.internal.BaseGmsClient {
public void disconnect();
public void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]);
public int getMinApkVersion();
public boolean requiresSignIn();
}
################################################################################
# ../../base/android/proguard/chromium_code.flags
################################################################################
......@@ -362,17 +373,6 @@
*** build() return null;
}
# Workaround for crbug/1002847. Methods of BaseGmsClient are incorrectly
# removed even though they are required for the derived class GmsClient
# to correctly implement Api$Client.
# TODO: remove once crbug/1002847 resolved.
-keep public class com.google.android.gms.common.internal.BaseGmsClient {
public void disconnect();
public void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]);
public int getMinApkVersion();
public boolean requiresSignIn();
}
################################################################################
# ../../third_party/android_deps/support_mediarouter.flags
################################################################################
......
......@@ -66,14 +66,3 @@
public <clinit>();
*** build() return null;
}
# Workaround for crbug/1002847. Methods of BaseGmsClient are incorrectly
# removed even though they are required for the derived class GmsClient
# to correctly implement Api$Client.
# TODO: remove once crbug/1002847 resolved.
-keep public class com.google.android.gms.common.internal.BaseGmsClient {
public void disconnect();
public void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]);
public int getMinApkVersion();
public boolean requiresSignIn();
}
......@@ -102,4 +102,7 @@ instrumentation_test_apk("remoting_test_apk") {
"//third_party/android_support_test_runner:runner_java",
"//third_party/junit:junit",
]
if (!is_java_debug) {
proguard_enabled = true
}
}
......@@ -5,7 +5,11 @@
package org.chromium.chromoting;
import android.app.Application;
import android.content.Context;
import org.chromium.base.BuildConfig;
import org.chromium.base.ContextUtils;
import org.chromium.base.multidex.ChromiumMultiDexInstaller;
import org.chromium.chromoting.accountswitcher.AccountSwitcherFactory;
import org.chromium.chromoting.help.HelpAndFeedbackBasic;
import org.chromium.chromoting.help.HelpSingleton;
......@@ -14,10 +18,13 @@ import org.chromium.chromoting.jni.JniInterface;
/** Main context for the application. */
public class RemotingApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
JniInterface.loadLibrary(this);
public void attachBaseContext(Context context) {
super.attachBaseContext(context);
ContextUtils.initApplicationContext(this);
if (BuildConfig.IS_MULTIDEX_ENABLED) {
ChromiumMultiDexInstaller.install(this);
}
JniInterface.loadLibrary();
AccountSwitcherFactory.setInstance(new AccountSwitcherFactory());
HelpSingleton.setInstance(new HelpAndFeedbackBasic());
}
......
......@@ -4,9 +4,6 @@
package org.chromium.chromoting.jni;
import android.content.Context;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
......@@ -23,11 +20,8 @@ public class JniInterface {
/**
* To be called once from the Application context singleton. Loads and initializes the native
* code. Called on the UI thread.
* @param context The Application context.
*/
@SuppressWarnings("NoContextGetApplicationContext")
public static void loadLibrary(Context context) {
ContextUtils.initApplicationContext(context.getApplicationContext());
public static void loadLibrary() {
try {
System.loadLibrary(LIBRARY_NAME);
} catch (UnsatisfiedLinkError e) {
......
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Use R8's "shrinking" (unreachable-code removal), but do not enable any
# stack trace mangling steps until ProGuard mapping files are archived.
# TODO(crbug.com/1026161): Enable ProGuard optimizations.
-dontoptimize
-dontobfuscate
......@@ -10,7 +10,19 @@ template("remoting_apk_tmpl") {
android_apk(target_name) {
forward_variables_from(invoker, "*")
enable_multidex = false
if (!is_java_debug) {
proguard_enabled = true
enable_multidex = false
disable_checkdiscard = true
if (!defined(proguard_configs)) {
proguard_configs = []
}
proguard_configs += [
"//remoting/android/proguard.flags",
"//base/android/proguard/chromium_apk.flags",
"//base/android/proguard/chromium_code.flags",
]
}
android_manifest = "$root_gen_dir/remoting/android/AndroidManifest.xml"
android_manifest_dep = "//remoting/android:remoting_apk_manifest"
......
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