Status Update
Comments
to...@gmail.com <to...@gmail.com> #2
Ok so the test was quick this is a regression from 2.0.73.
In 2.0.73 the load2 function is properly kept and used:
$$ServiceLoaderMethods -> a:
java.util.Iterator $load1() -> a
java.util.Iterator $load2() -> b
.class public abstract synthetic La;
.super Ljava/lang/Object;
.source "ServiceLoader"
# direct methods
.method public static a()Ljava/util/Iterator;
.registers 3
const/4 v0, 0x1
:try_start_1
new-array v0, v0, [Lkotlinx/coroutines/CoroutineExceptionHandler;
const/4 v1, 0x0
new-instance v2, Lkotlinx/coroutines/android/AndroidExceptionPreHandler;
invoke-direct {v2}, Lkotlinx/coroutines/android/AndroidExceptionPreHandler;-><init>()V
aput-object v2, v0, v1
invoke-static {v0}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
move-result-object v0
invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
:try_end_13
.catchall {:try_start_1 .. :try_end_13} :catchall_14
return-object v0
:catchall_14
move-exception v0
new-instance v1, Ljava/util/ServiceConfigurationError;
invoke-virtual {v0}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2, v0}, Ljava/util/ServiceConfigurationError;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
.end method
.method public static b()Ljava/util/Iterator;
.registers 3
const/4 v0, 0x1
:try_start_1
new-array v0, v0, [Lkotlinx/coroutines/android/AndroidDispatcherFactory;
const/4 v1, 0x0
new-instance v2, Lkotlinx/coroutines/android/AndroidDispatcherFactory;
invoke-direct {v2}, Lkotlinx/coroutines/android/AndroidDispatcherFactory;-><init>()V
aput-object v2, v0, v1
invoke-static {v0}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
move-result-object v0
invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
:try_end_13
.catchall {:try_start_1 .. :try_end_13} :catchall_14
return-object v0
:catchall_14
move-exception v0
new-instance v1, Ljava/util/ServiceConfigurationError;
invoke-virtual {v0}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2, v0}, Ljava/util/ServiceConfigurationError;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
.end method
js...@google.com <js...@google.com>
mk...@google.com <mk...@google.com> #3
Thank you for reporting the issue. Without being certain, this may to be because the code did not synchronize on adding the methods. Can I ask you to try out the d6056e52d2fb56d9379d53b3995ea1e0ca865b90 build from here
buildscript {
repositories {
maven {
url "https://storage.googleapis.com/r8-releases/raw/master"
}
}
dependencies {
classpath 'com.android.tools:r8:d6056e52d2fb56d9379d53b3995ea1e0ca865b90' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:X.Y.Z' // Your current AGP version.
}
}
The change from 2.0.73 to 2.0.74 should not have any impact on the serviceloader rewriting. As such, because this seem to be a concurrency issue, if I could ask you to do a few builds from, and clean a few times, just to have a bit more test surface.
to...@gmail.com <to...@gmail.com> #4
I'll try tomorrow but I made dozens if not hundreds of 2.0.73 build without issues, and all 3 attempts on 2.0.74 did trigger this and the revert instantly fixed it too.
to...@gmail.com <to...@gmail.com> #5
Ok so after 4 builds no reproduction of the issue with that one.
And after full gradle clean / reboot everything no more reproduced on 2.0.74 either.
Previously had faced
ap...@google.com <ap...@google.com> #6
Branch: 2.0
commit fca7b1c8ffe433ae8f8a231301ba9a11159c5e8b
Author: Morten Krogh-Jespersen <mkroghj@google.com>
Date: Wed May 27 19:40:39 2020
Version 2.0.75
Cherry pick: Workaround for non-determinism in service loader rewriter
CL:
Cherry pick: Update synthesized $load method names
CL:
Cherry pick: Unique ServiceLoaderRewriting for each context
CL:
Bug: 157430860
Bug: 156054499
Bug: 157223339
Change-Id: Ie2b96546adfbaf9ad3717e60eb1e1eb011005f45
M src/main/java/com/android/tools/r8/Version.java
M src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
A src/main/java/com/android/tools/r8/utils/IntBox.java
A src/test/java/com/android/tools/r8/rewrite/ServiceLoaderMultipleCallsTest.java
mk...@google.com <mk...@google.com>
to...@gmail.com <to...@gmail.com> #7
Thanks, I see that 2.1 is now branched, does it contains this so I can play with it?
mk...@google.com <mk...@google.com> #8
The fix is a bit different but should still work the same, so yes, go right ahead.
Description
Currently doing some researches about the issue being a regression or a coroutines 1.3.7 change but R8 2.0.74 generate wrong bytecode that leads to crash
Effectively the byte code for that file contains a try to call the load2 from $$ServiceLoaderMethods:
But mapping only shows :
And bycode of ServiceLoaderMethods effectively only contains the load1 method, so load2 is missing and the crash is normal :