0

Rollback protobuf lite runtime to 3.0.1

As a temporary fix for android webview regression b/157318961 this cl
rolls back the protobuf lite runtime to 3.0.1 using the codegen plugin.

Binary-Size: This is temporary and there is not really much we could do.
Bug: 1093059, b/157318961
Change-Id: I2bbaf6d3b434221b667901423c4616e26a7550c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2238872
Reviewed-by: Dan H <harringtond@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777495}
This commit is contained in:
Mohamed Heikal
2020-06-11 21:24:18 +00:00
committed by Commit Bot
parent cfc199db2e
commit 8a3e6a2898
13 changed files with 96 additions and 25 deletions
DEPS
base/android/proguard
build
chrome/android
feed
core
java
src
org
chromium
chrome
java
third_party/android_deps

6
DEPS

@ -3328,11 +3328,11 @@ deps = {
'dep_type': 'cipd',
},
'src/third_party/android_deps/libs/com_google_protobuf_protobuf_javalite': {
'src/third_party/android_deps/libs/com_google_protobuf_protobuf_lite': {
'packages': [
{
'package': 'chromium/third_party/android_deps/libs/com_google_protobuf_protobuf_javalite',
'version': 'version:3.12.2-cr0',
'package': 'chromium/third_party/android_deps/libs/com_google_protobuf_protobuf_lite',
'version': 'version:3.0.1-cr0',
},
],
'condition': 'checkout_android',

@ -98,8 +98,3 @@
public int getMinApkVersion();
public boolean requiresSignIn();
}
# Protobuf java lite runtime uses reflection
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
<fields>;
}

@ -4062,6 +4062,7 @@ if (enable_java_templates) {
# Use the regular proto library to generate lite protos.
_protoc_bin = "//third_party/android_protoc/protoc"
_proto_runtime = "//third_party/android_deps:com_google_protobuf_protobuf_javalite_java"
_protoc_javalite_plugin_dir = "//third_party/protoc_javalite/"
}
_proto_path = invoker.proto_path
_template_name = target_name
@ -4105,6 +4106,11 @@ if (enable_java_templates) {
if (_generate_nano) {
args += [ "--nano" ]
} else {
args += [
"--protoc-javalite-plugin-dir",
rebase_path(_protoc_javalite_plugin_dir, root_build_dir),
]
}
}

@ -37,6 +37,8 @@ def main(argv):
parser.add_option("--stamp", help="File to touch on success.")
parser.add_option("--nano",
help="Use to generate nano protos.", action='store_true')
parser.add_option("--protoc-javalite-plugin-dir",
help="Path to protoc java lite plugin directory.")
parser.add_option("--import-dir", action="append", default=[],
help="Extra import directory for protos, can be repeated.")
options, args = parser.parse_args(argv)
@ -57,16 +59,26 @@ def main(argv):
'store_unknown_fields=true']
out_arg = '--javanano_out=' + ','.join(generator_args) + ':' + temp_dir
else:
out_arg = '--java_out=lite:' + temp_dir
out_arg = '--javalite_out=' + temp_dir
custom_env = os.environ.copy()
if options.protoc_javalite_plugin_dir:
# If we are generating lite protos, then the lite plugin needs to be in
# the path when protoc is called. See
# https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md
custom_env['PATH'] = '{}:{}'.format(
os.path.abspath(options.protoc_javalite_plugin_dir),
custom_env['PATH'])
# Generate Java files using protoc.
build_utils.CheckOutput(
[options.protoc] + proto_path_args + [out_arg] + args,
env=custom_env,
# protoc generates superfluous warnings about LITE_RUNTIME deprecation
# even though we are using the new non-deprecated method.
stderr_filter=lambda output:
build_utils.FilterLines(output,
'|'.join([r'optimize_for = LITE_RUNTIME', r'java/lite\.md'])))
stderr_filter=lambda output: build_utils.FilterLines(
output, '|'.join([r'optimize_for = LITE_RUNTIME', r'java/lite\.md'])
))
if options.java_out_dir:
build_utils.DeleteDirectory(options.java_out_dir)

@ -35,8 +35,10 @@ import org.chromium.chrome.browser.xsurface.SurfaceDependencyProvider;
import org.chromium.chrome.browser.xsurface.SurfaceScope;
import org.chromium.components.feed.proto.FeedUiProto.SharedState;
import org.chromium.components.feed.proto.FeedUiProto.Slice;
import org.chromium.components.feed.proto.FeedUiProto.Slice.SliceDataCase;
import org.chromium.components.feed.proto.FeedUiProto.StreamUpdate;
import org.chromium.components.feed.proto.FeedUiProto.StreamUpdate.SliceUpdate;
import org.chromium.components.feed.proto.FeedUiProto.StreamUpdate.SliceUpdate.UpdateCase;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.common.Referrer;
import org.chromium.network.mojom.ReferrerPolicy;
@ -244,7 +246,7 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
new ArrayList<FeedListContentManager.FeedContent>();
HashSet<String> existingIdsInNewContentList = new HashSet<String>();
for (SliceUpdate sliceUpdate : streamUpdate.getUpdatedSlicesList()) {
if (sliceUpdate.hasSlice()) {
if (sliceUpdate.getUpdateCase() == UpdateCase.SLICE) {
newContentList.add(createContentFromSlice(sliceUpdate.getSlice()));
} else {
String existingSliceId = sliceUpdate.getSliceId();
@ -296,7 +298,7 @@ public class FeedStreamSurface implements SurfaceActionsHandler, FeedActionsHand
private FeedListContentManager.FeedContent createContentFromSlice(Slice slice) {
String sliceId = slice.getSliceId();
if (slice.hasXsurfaceSlice()) {
if (slice.getSliceDataCase() == SliceDataCase.XSURFACE_SLICE) {
return new FeedListContentManager.ExternalViewContent(
sliceId, slice.getXsurfaceSlice().getXsurfaceFrame().toByteArray());
} else {

@ -177,11 +177,6 @@
public boolean requiresSignIn();
}
# Protobuf java lite runtime uses reflection
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
<fields>;
}
################################################################################
# ../../base/android/proguard/chromium_code.flags
################################################################################

@ -89,6 +89,12 @@ java_annotation_processor("dagger_processor") {
deps = [ ":com_google_dagger_dagger_compiler_java" ]
}
# Alias new java lite runtime to old javalite runtime name until
# crbug.com/1093059 is fixed and we go back to the latest runtime.
java_group("com_google_protobuf_protobuf_javalite_java") {
deps = [ ":com_google_protobuf_protobuf_lite_java" ]
}
# The section below is generated by running
# `//tools/android/roll/android_deps/fetch_all.py`
@ -1393,10 +1399,9 @@ java_prebuilt("com_google_j2objc_j2objc_annotations_java") {
}
# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
java_prebuilt("com_google_protobuf_protobuf_javalite_java") {
jar_path =
"libs/com_google_protobuf_protobuf_javalite/protobuf-javalite-3.12.2.jar"
output_name = "com_google_protobuf_protobuf_javalite"
java_prebuilt("com_google_protobuf_protobuf_lite_java") {
jar_path = "libs/com_google_protobuf_protobuf_lite/protobuf-lite-3.0.1.jar"
output_name = "com_google_protobuf_protobuf_lite"
supports_android = true
}

@ -159,7 +159,7 @@
"libs/com_google_guava_listenablefuture",
"libs/com_google_j2objc_j2objc_annotations",
"libs/com_google_protobuf_protobuf_java",
"libs/com_google_protobuf_protobuf_javalite",
"libs/com_google_protobuf_protobuf_lite",
"libs/com_googlecode_java_diff_utils_diffutils",
"libs/com_squareup_javapoet",
"libs/com_squareup_javawriter",

@ -123,7 +123,7 @@ dependencies {
compile "com.google.guava:failureaccess:1.0.1"
compile "com.google.guava:listenablefuture:1.0"
compile "com.google.j2objc:j2objc-annotations:1.1"
compile "com.google.protobuf:protobuf-javalite:3.12.2"
compile "com.google.protobuf:protobuf-lite:3.0.1"
compile "javax.annotation:javax.annotation-api:1.3.2"
compile "javax.annotation:jsr250-api:1.0"
compile "javax.inject:javax.inject:1"

@ -0,0 +1,32 @@
Copyright 2008 Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Code generated by the Protocol Buffer compiler is owned by the owner
of the input file used when generating it. This code is not
standalone and requires a support library to be linked with it. This
support library is itself covered by the above license.

@ -0,0 +1 @@
file://third_party/android_deps/OWNERS

@ -0,0 +1,13 @@
Name: Protocol Buffers [Lite]
Short Name: protobuf-lite
URL: https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md
Version: 3.0.1
License: BSD
License File: LICENSE
Security Critical: yes
Description:
A trimmed-down version of the Protocol Buffers library.
Local Modifications:
No modifications.

@ -0,0 +1,10 @@
# Copyright 2018 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd.yaml -tag version:3.0.1-cr0
package: chromium/third_party/android_deps/libs/com_google_protobuf_protobuf_lite
description: "Protocol Buffers [Lite]"
data:
- file: protobuf-lite-3.0.1.jar