Status Update
Comments
mk...@google.com <mk...@google.com>
mk...@google.com <mk...@google.com> #2
Yigit, I haven't had time to try reproducing yet, but they have a github link which is nice. What's weird though is I don't think anything has changed recently at all, but maybe you're aware? Although, looking at the callstack, it may be an AGP issue? If it looks like that to you too, bounce it back to me.
OP: Was this a regression? And just to make sure, when you say "run ./gradlew help
", you're seeing this from the command line? Or from within Studio?
ap...@google.com <ap...@google.com> #3
I'm seeing this from command line.
Yes this seems to be a regression starting from 7.0.0-alpha10.
Note that the project I linked doesn't use databinding at all, enabling the build config flag is all that's needed to reproduce this.
ap...@google.com <ap...@google.com> #4
Thanks for the quick reply. I have a short open window right now so I'll try to repro and see if I can figure out which component this is best for.
mk...@google.com <mk...@google.com> #5
I can repro what OP is seeing. It may be tempting to move this to the data binding component but this seems more like an AGP change. I don't believe the data binding compiler has been changed recently, around the time AGP 7.0.0-alpha10 went out.
mk...@google.com <mk...@google.com>
js...@gmail.com <js...@gmail.com> #6
Also, slightly more direct steps (although it amounts to the same thing as what's in
- Sync the github project somewhere (
git clone https://github.com/ReactiveCircus/streamlined.git
) - Double check everything's working as expected (
./gradlew help
should work) - Edit
app/build.gradle.kts
: Search forbuildFeatures
and adddataBinding = true
as the first entry, abovebuildConfig
- Now, things are expected to break (
./gradlew help
should throw an exception) - Edit
buildSrc/src/main/kotlin/io/github/reactivecircus/streamlined/Dependencies.kt
: change the AGP version to7.0.0-alpha09
- Now, things are expected to work again(
./gradle help
should work)
Description
I was working on the app with coroutines as base for domain layer and started to get strange StackOverflowError exceptions in crash reports from Crashlytics after publishing the app as alpha version. Crashes appear only in release build (with R8 in full mode and "proguard-android-optimize.txt" rules set). But as stacktraces pointed to coroutine classes, I decided to open an issue in kotlinx.coroutines repository first. They advised me to create an issue here.
I created a simple repository as example to show the issue -
In short, there is a view model class which collects flow in init block:
init {
viewModelScope.launch {
flow {
val list = arrayListOf<Int>()
for (i in 0..100) {
list.add(Random(100).nextInt())
}
emit(list)
}.flowOn(Dispatchers.Default)
.distinctUntilChanged()
.collect { list ->
Log.e("Collect list", list.toString())
}
}
}
flowOn(Dispatchers.Default) and distinctUntilChanged() methods are placed here just to match the behavior of the production app, where crashes basically occurred. Also I emulated release mode by setting the following in build.gradle:
debug {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
And android.enableR8.fullMode=true in gradle.properties.
Actual issue is in that app crashes with these parameters, but everything works fine with another variations. I've got the following results. Crash doesn't appear if:
1. Set debuggable to true
2. Using proguard-android.txt instead of proguard-android-optimize.txt
3. Removing android.enableR8.fullMode=true. Works for both proguard-android.txt and proguard-android-optimize.txt
4. Removing .flowOn(Dispatchers.Default) from chain
5. Using the same dispatchers for .flowOn() and viewModelScope.launch()
Deobfuscated stacktrace (using ReTrace from ProGuard) for example app is also attached.