Fixed
Status Update
Comments
an...@google.com <an...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 53805a49b7369999a2eb0f0230a8bbd99e86bbf8
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Mon Mar 28 20:03:53 2022
Introduce Snapshot.withoutReadObservation
Relnote: New function Snapshot.withoutReadObservation { ... } was added. It allows to run the passed lambda without subscribing to the changes of the state values read during this block. You could find it useful in use cases when you want to benefit from the snapshot based thread safe write/reads, but want to be able to read the value without causing unnecessary recomposition or remeasure.
Fixes: 214054486
Test: new tests in SnapshotStateObserverTestsJvm and RecomposerTests, rerun tests in ui module
Change-Id: I9f365d653483310cfda02cfa2c582fdcce8cfe33
M compose/runtime/runtime/src/commonTest/kotlin/androidx/compose/runtime/RecomposerTests.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNodeWrapper.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt
M compose/runtime/runtime/api/current.txt
M compose/runtime/runtime/api/restricted_current.txt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserver.kt
M compose/runtime/runtime/src/commonTest/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserverTestsCommon.kt
M compose/runtime/runtime/api/public_plus_experimental_current.txt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/Snapshot.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/OwnerSnapshotObserver.kt
https://android-review.googlesource.com/2046231
Branch: androidx-main
commit 53805a49b7369999a2eb0f0230a8bbd99e86bbf8
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Mon Mar 28 20:03:53 2022
Introduce Snapshot.withoutReadObservation
Relnote: New function Snapshot.withoutReadObservation { ... } was added. It allows to run the passed lambda without subscribing to the changes of the state values read during this block. You could find it useful in use cases when you want to benefit from the snapshot based thread safe write/reads, but want to be able to read the value without causing unnecessary recomposition or remeasure.
Fixes: 214054486
Test: new tests in SnapshotStateObserverTestsJvm and RecomposerTests, rerun tests in ui module
Change-Id: I9f365d653483310cfda02cfa2c582fdcce8cfe33
M compose/runtime/runtime/src/commonTest/kotlin/androidx/compose/runtime/RecomposerTests.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNodeWrapper.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt
M compose/runtime/runtime/api/current.txt
M compose/runtime/runtime/api/restricted_current.txt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserver.kt
M compose/runtime/runtime/src/commonTest/kotlin/androidx/compose/runtime/snapshots/SnapshotStateObserverTestsCommon.kt
M compose/runtime/runtime/api/public_plus_experimental_current.txt
M compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/snapshots/Snapshot.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/OwnerSnapshotObserver.kt
Description
Sometimes we want to use mutableState() only to be able to safely set values during composition/measure and then have ability to read this value without causing extra remeasure/recomposition. Currently we have to just use regular vars which is not thread-safe and the value will be updated even if the composition is aborted.
We discussed it and though the api could be