Status Update
Comments
fe...@aspire.se <fe...@aspire.se> #2
Related to
fe...@aspire.se <fe...@aspire.se> #3
Project: platform/frameworks/support
Branch: androidx-main
Author: Marcello Galhardo <
Link:
Add MutableStateSerializer
for serializing MutableState
Expand for full commit details
Add `MutableStateSerializer` for serializing `MutableState`
- Introduced an inline `MutableStateSerializer` function to infer and retrieve the appropriate `KSerializer` for `MutableState` of a serializable type.
- Added an overload of `MutableStateSerializer` that accepts an explicit `KSerializer` for the wrapped type, allowing for customizing the `KSerializer`.
- Implemented `MutableStateSerializerImpl`, a private class that handles the serialization and deserialization logic for `MutableState`, delegating inner value processing to the provided `KSerializer`.
- Only `KSerializer<MutableState<T>>` is exposed; the `MutableStateSerializerImpl` remains private.
RelNote: "Add `MutableStateSerializer` for serializing `androidx.compose.runtime.MutableState`."
Test: MutableStateSerializerTest
Bug: 378895074
Change-Id: Idfc489d9313461bddd0046052d0f6a41644e7712
Files:
- M
lifecycle/lifecycle-viewmodel-compose/api/current.txt
- M
lifecycle/lifecycle-viewmodel-compose/api/restricted_current.txt
- M
lifecycle/lifecycle-viewmodel-compose/build.gradle
- A
lifecycle/lifecycle-viewmodel-compose/src/androidInstrumentedTest/kotlin/androidx/lifecycle/viewmodel/compose/serialization/serializers/MutableStateSerializerTest.android.kt
- A
lifecycle/lifecycle-viewmodel-compose/src/commonMain/kotlin/androidx/lifecycle/viewmodel/compose/serialization/serializers/MutableStateSerializer.kt
Hash: d628386123647d7f90b6efb2ddde93621c7cc7db
Date: Fri Jan 17 11:18:40 2025
an...@google.com <an...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
Author: Marcello Galhardo <
Link:
Move KMP compatible test dependencies to commonTest
Expand for full commit details
Move KMP compatible test dependencies to `commonTest`
Test: N/A
Bug: 378895074
Change-Id: I77d03d1da41808e03d5e2978b768dc3ef6649211
Files:
- M
lifecycle/lifecycle-viewmodel-compose/build.gradle
Hash: e266fa197c54fe55955b2de9acc1c1d9894e6376
Date: Fri Jan 17 14:25:48 2025
al...@google.com <al...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
Author: Marcello Galhardo <
Link:
Move MutableStateSerializer
to savedstate-compose
Expand for full commit details
Move `MutableStateSerializer` to `savedstate-compose`
- This change moves `MutableStateSerializer` from `lifecycle-viewmodel-compose` to `savedstate-compose`. This corrects its previous misplacement and aligns with the design outlined in go/savedstate-compose, which specifies that all `savedstate-compose` related APIs should reside within the `savedstate-compose` module.
RelNote: "Move `MutableStateSerializer` to `savedstate-compose`."
Test: MutableStateSerializerTest
Bug: 378895074
Change-Id: I4f690e41dc5619d185784409170943abeb0f0550
Files:
- M
lifecycle/lifecycle-viewmodel-compose/api/current.txt
- M
lifecycle/lifecycle-viewmodel-compose/api/restricted_current.txt
- M
savedstate/savedstate-compose/api/current.txt
- M
savedstate/savedstate-compose/api/restricted_current.txt
- M
savedstate/savedstate-compose/src/androidInstrumentedTest/kotlin/androidx/savedstate/compose/serialization/serializers/MutableStateSerializerTest.android.kt
- M
savedstate/savedstate-compose/src/commonMain/kotlin/androidx/savedstate/compose/serialization/serializers/MutableStateSerializer.kt
Hash: f845eabb6c5e3b138059839e59f383f70304d792
Date: Wed Jan 29 11:31:04 2025
bu...@google.com <bu...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.lifecycle:lifecycle-viewmodel-compose:2.9.0-alpha10
androidx.lifecycle:lifecycle-viewmodel-compose-android:2.9.0-alpha10
androidx.lifecycle:lifecycle-viewmodel-compose-desktop:2.9.0-alpha10
androidx.savedstate:savedstate-compose:1.3.0-alpha08
androidx.savedstate:savedstate-compose-android:1.3.0-alpha08
androidx.savedstate:savedstate-compose-jvmstubs:1.3.0-alpha08
androidx.savedstate:savedstate-compose-linuxx64stubs:1.3.0-alpha08
fe...@aspire.se <fe...@aspire.se> #7
This took me about an hour to extract but it reproduces the issue for me.
@file:SuppressLint("UnusedMaterialScaffoldPaddingParameter")
package com.example
import android.annotation.SuppressLint
import android.app.Application
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import kotlinx.coroutines.delay
class MyApp : Application()
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
// Scaffold is required!
Scaffold { _ ->
val a = remember { mutableStateOf(true) }
val b = remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
a.value = false
delay(50)
b.value = false
}
AnimatedVisibility(visible = a.value) { Text("Hello World") }
if (!b.value) {
TODO()
}
}
}
}
}
}
al...@google.com <al...@google.com>
an...@google.com <an...@google.com> #8
Thank you! I was able to reproduce locally. Will look into this. We may eventually dedupe to
One thing to note is that this is definitely related to a race condition. Device speed matters, and a slower device seems more likely to trigger this exception — My aging Pixel XL from 2016 reproduces this very consistently, unlike my local emulator which doesn't demonstrate this issue at all. We had suspected that coroutines were coming into play here, so a lot of pieces are starting to come together.
an...@google.com <an...@google.com> #9
Correction: The emulator I was using had animations disabled. This seems to reproduce very consistently across devices.
It looks like our exception handling logic is try/catching Exception
instead of Throwable
. TODO() is breaking things because it throws a NotImplementedError
, which isn't caught by our error handler and doesn't cancel pending recompositions. We'll update our code to include Errors and generic Throwable classes. It's not immediately obvious if this will fix other occurrences of this exception since we don't have other reproduction cases.
ap...@google.com <ap...@google.com> #10
Project: platform/frameworks/support
Branch: androidx-main
Author: Andrew Bailey <
Link:
Fix Throwables causing unapplied composition error
Expand for full commit details
Fix Throwables causing unapplied composition error
The error handling logic in the Recomposer was set up to catch
throwables that extended from Exception, which excluded Errors (like
NotImplementedError, error(""), StackOverflowError, etc.) and
user-defined exceptions that extend directly from Throwable. This CL
updates the relevant pathways to switch over all Throwables.
This resolves at least one pathway that leads to a "Pending composition
has not been applied." runtime error. It's not immediately clear if this
accounts for all of the reports since we only have one known
reproduction case right now.
Test: Manually run repro case in the linked bug
Fixes: b/382094412
Relnote: """
Fixes an issue where raising a throwable during composition that
does not extend from Exception may lead to a 'Pending composition
has not been applied' error.
"""
Change-Id: I356be5d99df41138be790275807544b2d717050c
Files:
- M
compose/runtime/runtime/api/current.txt
- M
compose/runtime/runtime/api/restricted_current.txt
- M
compose/runtime/runtime/integration-tests/src/androidInstrumentedTest/kotlin/androidx/compose/runtime/LiveEditApiTests.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/HotReloader.kt
- M
compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Recomposer.kt
- M
compose/runtime/runtime/src/nonEmulatorJvmTest/kotlin/androidx/compose/runtime/LiveEditTests.kt
Hash: 120c3f0cfa04436bd9afabea415a478e12458316
Date: Wed Jan 08 15:38:34 2025
Description
Jetpack Compose version:
BOM
2023.10.01
,2024.11.00
Jetpack Compose component(s) used:
androidx.activity:activity-compose
androidx.compose.material:material
androidx.compose.material:material-icons-extended
androidx.compose.ui:ui
androidx.compose.ui:ui-graphics
androidx.navigation:navigation-compose
androidx.constraintlayout:constraintlayout-compose
Android Studio Build:
Kotlin version:
1.9.22
Steps to Reproduce or Code Sample to Reproduce:
I don't really have a reproduction available at this time. The following is an untested simplification where I'd start writing a new repro from. Also, be aware that this code is executing from a dynamic feature module.
Stack trace (if applicable):