Status Update
Comments
ri...@google.com <ri...@google.com>
ch...@google.com <ch...@google.com> #2
In order to diagnose this I think we will need more information.
Can you clarify if this happens for a new Native C++ project without any changes to it? Would it be possible for you to share an Android Studio project where you see this issue?
Can you please also share the log files as requested in the instructions in
yu...@bytedance.com <yu...@bytedance.com> #3
ch...@google.com <ch...@google.com> #4
In order to diagnose this we would probably need to be able to reproduce this issue.
Would it be possible for you to share a compiler dump file that contains the inputs to R8 (i.e., the Java class files and the keep rules going into R8)? That way we should be able to reproduce the build. You can generate this as below and could share this privately with
./gradlew assembleRelease --no-daemon -Dcom.android.tools.r8.dumpinputtodirectory=/path/to/dumps
Do you know if the class ViewEventSinkImpl
is instantiated using reflection? If so, do you know if there is a corresponding keep rule for the class?
Can you try if the following rule "fixes" the issue:
-keep,allowobfuscation,allowshrinking class org.chromium.content.browser.ViewEventSinkImpl
When this rule is present, R8 should account for the fact that ViewEventSinkImpl
may be instantiated by reflection, which I suspect may fix the issue you are seeing.
to...@xperi.com <to...@xperi.com> #5
Hi! I have also encountered a problem with r8 in --classfile mode incorrectly removing a null check, and curiously enough it also happened in and around ViewEventSinkImpl. I tried with the R8 version in Chromium and also with latest main branch local build from the repo which was be29229a110ce06989f6f3a63b0a83015ed3fefe.
The issue I'm seeing is from code which effectively does
public final class ViewEventSinkImpl ... {
private @Nullable Boolean mHasViewFocus; // not written to anywhere else
public void onViewFocusChanged(boolean gainFocus) {
if (mHasViewFocus != null && mHasViewFocus == gainFocus) return;
mHasViewFocus = gainFocus;
....
}
}
and after r8 with --classfile, the null check gets removed and the code is guaranteed to crash. Without --classfile, the null check remains in the dex. Note: for me, the code (with or without the check) was inlined at the only callsite to onViewFocusChanged.
Adding
-keep,allowobfuscation,allowshrinking class org.chromium.content.browser.ViewEventSinkImpl
works around the issue for me. I believe there is some reflection going on as one part of the code that affects that bug is the presence of
public static ViewEventSinkImpl from(WebContents webContents) {
ViewEventSinkImpl ret =
((WebContentsImpl) webContents)
.getOrSetUserData(
ViewEventSinkImpl.class, UserDataFactoryLazyHolder.INSTANCE);
return ret;
}
I hope the advice to send the repro case directly is still valid, I should have it down to a manageable size soon.
ch...@google.com <ch...@google.com> #6
Thanks, it would be great if you would be able to share a reproduction for this.
to...@xperi.com <to...@xperi.com> #7
I have sent the repro over by email. Can you confirm if the mail has gotten thru spam filters, etc.?
ap...@google.com <ap...@google.com> #8
Project: r8
Branch: main
Author: Christoffer Adamsen <
Link:
Reproduce inadequate value propagation in presence of T::new expressions
Expand for full commit details
Reproduce inadequate value propagation in presence of T::new expressions
Bug: b/397737234
Change-Id: Ia6cbb0ef3366125420afbdfcf3a8f0d228cc2004
Files:
- A
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 0e40b2543f171f14c4727e9673cfbe1581bfb804
Date: Thu Mar 06 08:47:46 2025
ap...@google.com <ap...@google.com> #9
Project: r8
Branch: main
Author: Christoffer Adamsen <
Link:
Account for T::new expressions in default field value joiner
Expand for full commit details
Account for T::new expressions in default field value joiner
Bug: b/397737234
Change-Id: Iea344f54fa5a8ac40739a51da5d7e6679d5964b8
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/DefaultFieldValueJoiner.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: faeee0fe013067ef2c1b015822a00ebd999c19c9
Date: Thu Mar 06 09:51:41 2025
ap...@google.com <ap...@google.com> #10
Project: r8
Branch: main
Author: Christoffer Adamsen <
Link:
Fix BootstrapMethodError from invalid class merging
Expand for full commit details
Fix BootstrapMethodError from invalid class merging
Bug: b/397737234
Change-Id: Icacf51f06017c50b3448610e8493a225c225c40d
Files:
- M
src/main/java/com/android/tools/r8/horizontalclassmerging/PolicyScheduler.java
- A
src/main/java/com/android/tools/r8/horizontalclassmerging/policies/NoMethodHandleFromLambda.java
- M
src/main/java/com/android/tools/r8/shaking/Enqueuer.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 2d3816adfcece78053fbab0a70196dcb9c0b94dc
Date: Thu Mar 06 09:33:32 2025
to...@xperi.com <to...@xperi.com> #11
I checked faeee0fe013067ef2c1b015822a00ebd999c19c9 from r8's main (containing all the fixes above) and it also fixes my original issue on the real code I had. The null check is no longer removed and I go the code to start up correctly.
Thanks a lot!
ap...@google.com <ap...@google.com> #12
Project: r8
Branch: 8.9
Author: Christoffer Adamsen <
Link:
Fix BootstrapMethodError from invalid class merging
Expand for full commit details
Fix BootstrapMethodError from invalid class merging
Bug: b/397737234
Change-Id: Icacf51f06017c50b3448610e8493a225c225c40d
Files:
- M
src/main/java/com/android/tools/r8/horizontalclassmerging/PolicyScheduler.java
- A
src/main/java/com/android/tools/r8/horizontalclassmerging/policies/NoMethodHandleFromLambda.java
- M
src/main/java/com/android/tools/r8/shaking/Enqueuer.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 5cc2d659e1fd08cecbc8f7cfcbfc404d0bc95fa6
Date: Thu Mar 06 12:12:03 2025
ap...@google.com <ap...@google.com> #13
Project: r8
Branch: 8.9
Author: Christoffer Adamsen <
Link:
Version 8.9.29
Expand for full commit details
Version 8.9.29
Bug: b/397737234
Change-Id: I23a0b0f52df1ab2db0b175055ebd78115d407dbc
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: 3d1fcaa2ff1c9b42f0079ae236c48bff520d64c6
Date: Thu Mar 06 12:12:19 2025
ap...@google.com <ap...@google.com> #14
Project: r8
Branch: 8.9
Author: Christoffer Adamsen <
Link:
Reproduce inadequate value propagation in presence of T::new expressions
Expand for full commit details
Reproduce inadequate value propagation in presence of T::new expressions
Bug: b/397737234
Change-Id: Ia6cbb0ef3366125420afbdfcf3a8f0d228cc2004
Files:
- A
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 7e08f18c401f4d2503ab37f8dbe59f6714ffa7a2
Date: Thu Mar 06 12:11:55 2025
ap...@google.com <ap...@google.com> #15
Project: r8
Branch: 8.9
Author: Christoffer Adamsen <
Link:
Account for T::new expressions in default field value joiner
Expand for full commit details
Account for T::new expressions in default field value joiner
Bug: b/397737234
Change-Id: Iea344f54fa5a8ac40739a51da5d7e6679d5964b8
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/DefaultFieldValueJoiner.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: db5ecfb23c380c97fdf9e8562ec7541a9c94ddc7
Date: Thu Mar 06 12:12:10 2025
ap...@google.com <ap...@google.com> #16
Project: r8
Branch: 8.8
Author: Christoffer Adamsen <
Link:
Reproduce inadequate value propagation in presence of T::new expressions
Expand for full commit details
Reproduce inadequate value propagation in presence of T::new expressions
Bug: b/397737234
Change-Id: Ia6cbb0ef3366125420afbdfcf3a8f0d228cc2004
Files:
- A
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 674a5456a7f32132fb20c00e543e5a82456a08f3
Date: Thu Mar 06 12:12:45 2025
ap...@google.com <ap...@google.com> #17
Project: r8
Branch: 8.8
Author: Christoffer Adamsen <
Link:
Account for T::new expressions in default field value joiner
Expand for full commit details
Account for T::new expressions in default field value joiner
Bug: b/397737234
Change-Id: Iea344f54fa5a8ac40739a51da5d7e6679d5964b8
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/DefaultFieldValueJoiner.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: dff84c28b3884cecf7d816ccb7b7afe862c0f78f
Date: Thu Mar 06 12:37:41 2025
ap...@google.com <ap...@google.com> #18
Project: r8
Branch: 8.8
Author: Christoffer Adamsen <
Link:
Fix BootstrapMethodError from invalid class merging
Expand for full commit details
Fix BootstrapMethodError from invalid class merging
Bug: b/397737234
Change-Id: Icacf51f06017c50b3448610e8493a225c225c40d
Files:
- M
src/main/java/com/android/tools/r8/horizontalclassmerging/PolicyScheduler.java
- A
src/main/java/com/android/tools/r8/horizontalclassmerging/policies/NoMethodHandleFromLambda.java
- M
src/main/java/com/android/tools/r8/shaking/Enqueuer.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 54f1b29c6d4be82cfb1cf2cbd0483093fc583114
Date: Thu Mar 06 12:12:53 2025
ap...@google.com <ap...@google.com> #19
Project: r8
Branch: 8.8
Author: Christoffer Adamsen <
Link:
Version 8.8.37
Expand for full commit details
Version 8.8.37
Bug: b/397737234
Change-Id: Ibc71b252bb1283074ba65ce92bac26cb0396558c
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: bc26ca739f0297c4c132feb78d8090b44b6a8b5e
Date: Thu Mar 06 12:38:38 2025
ap...@google.com <ap...@google.com> #20
Project: r8
Branch: 8.9
Author: Christoffer Adamsen <
Link:
Fix BootstrapMethodError from invalid class merging
Expand for full commit details
Fix BootstrapMethodError from invalid class merging
Bug: b/397737234
Change-Id: Icacf51f06017c50b3448610e8493a225c225c40d
Files:
- M
src/main/java/com/android/tools/r8/horizontalclassmerging/PolicyScheduler.java
- A
src/main/java/com/android/tools/r8/horizontalclassmerging/policies/NoMethodHandleFromLambda.java
- M
src/main/java/com/android/tools/r8/shaking/Enqueuer.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 5cc2d659e1fd08cecbc8f7cfcbfc404d0bc95fa6
Date: Thu Mar 06 12:12:03 2025
ap...@google.com <ap...@google.com> #21
Project: r8
Branch: 8.9
Author: Christoffer Adamsen <
Link:
Reproduce inadequate value propagation in presence of T::new expressions
Expand for full commit details
Reproduce inadequate value propagation in presence of T::new expressions
Bug: b/397737234
Change-Id: Ia6cbb0ef3366125420afbdfcf3a8f0d228cc2004
Files:
- A
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 7e08f18c401f4d2503ab37f8dbe59f6714ffa7a2
Date: Thu Mar 06 12:11:55 2025
ap...@google.com <ap...@google.com> #22
Project: r8
Branch: 8.9
Author: Christoffer Adamsen <
Link:
Account for T::new expressions in default field value joiner
Expand for full commit details
Account for T::new expressions in default field value joiner
Bug: b/397737234
Change-Id: Iea344f54fa5a8ac40739a51da5d7e6679d5964b8
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/DefaultFieldValueJoiner.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: db5ecfb23c380c97fdf9e8562ec7541a9c94ddc7
Date: Thu Mar 06 12:12:10 2025
ch...@google.com <ch...@google.com> #23
Thanks for the confirmation and for taking the time to create a reproduction. This should be fixed in R8 versions 8.7.37, 8.8.37, 8.9.29 and 8.10.
ap...@google.com <ap...@google.com> #24
Project: r8
Branch: 8.7
Author: Christoffer Adamsen <
Link:
Account for T::new expressions in default field value joiner
Expand for full commit details
Account for T::new expressions in default field value joiner
Bug: b/397737234
Change-Id: Iea344f54fa5a8ac40739a51da5d7e6679d5964b8
Files:
- M
src/main/java/com/android/tools/r8/optimize/argumentpropagation/propagation/DefaultFieldValueJoiner.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: facb83cda9b23e96d13acfb6e61edfe77b754c56
Date: Thu Mar 06 12:47:29 2025
ap...@google.com <ap...@google.com> #25
Project: r8
Branch: 8.7
Author: Christoffer Adamsen <
Link:
Fix BootstrapMethodError from invalid class merging
Expand for full commit details
Fix BootstrapMethodError from invalid class merging
Bug: b/397737234
Change-Id: Icacf51f06017c50b3448610e8493a225c225c40d
Files:
- M
src/main/java/com/android/tools/r8/horizontalclassmerging/PolicyScheduler.java
- A
src/main/java/com/android/tools/r8/horizontalclassmerging/policies/NoMethodHandleFromLambda.java
- M
src/main/java/com/android/tools/r8/shaking/Enqueuer.java
- M
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: f84fe96b65408bc0b38dbed81b95ef3cc8f998af
Date: Thu Mar 06 12:45:35 2025
ap...@google.com <ap...@google.com> #26
Project: r8
Branch: 8.7
Author: Christoffer Adamsen <
Link:
Reproduce inadequate value propagation in presence of T::new expressions
Expand for full commit details
Reproduce inadequate value propagation in presence of T::new expressions
Bug: b/397737234
Change-Id: Ia6cbb0ef3366125420afbdfcf3a8f0d228cc2004
Files:
- A
src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/DefaultFieldValueJoinerWithLambdaAllocationTest.java
Hash: 2c63d92a87eafc74b45cba8a5a8f3a013130c653
Date: Thu Mar 06 12:45:27 2025
ap...@google.com <ap...@google.com> #27
Project: r8
Branch: 8.7
Author: Christoffer Adamsen <
Link:
Version 8.7.37
Expand for full commit details
Version 8.7.37
Bug: b/397737234
Change-Id: If19c362aff21345ea0eba68ee01174265aefae4e
Files:
- M
src/main/java/com/android/tools/r8/Version.java
Hash: 9dd430e92787edf015ce4dbfe5ddb309999758f5
Date: Thu Mar 06 12:47:39 2025
Description
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
at BI.a(chromium-TTWebView.apk-default-694900001:14)
at org.chromium.android_webview.s.a(chromium-WebView.apk-default-694900001:7)
at org.chromium.android_webview.AwContents.onContainerViewChanged(chromium-WebView.apk-default-694900001:35)
at org.chromium.android_webview.AwContents.<init>(chromium-WebView.apk-default-694900001:5171)
at com.android.webview.chromium.WebViewChromium.b(chromium-WebView.apk-default-694900001:28)
at com.android.webview.chromium.E.run(chromium-WebView.apk-default-694900001:1)
at DJ.a(chromium-WebView.apk-default-694900001:37)
source code:(
public void onViewFocusChanged(boolean gainFocus) {
if (mHasViewFocus != null && mHasViewFocus == gainFocus) return;
mHasViewFocus = gainFocus;
onFocusChanged();
// Stylus Writing
if (mWebContents.getStylusWritingHandler() != null) {
mWebContents.getStylusWritingHandler().onFocusChanged(gainFocus);
}
}
check classfile and find ''"mHasViewFocus != null" is removed. But dex is normal. Then binary-search r8 commit and find the root cause is this commit: