[go: nahoru, domu]

Deprecate onPreCommit, change onCommit behavior

onCommit's post-later behavior leads to things running later than
expected and onPreCommit is no longer as "risky," since composition
lifecycle callbacks run separately in the apply step as of a different
earlier change. Collapse these into one concept with the better name.

Relnote: "onPreCommit is deprecated; onCommit now has onPreCommit's
behavior.

onCommit and onActive now run in the same choreographer frame that
the composition changes committed in rather than at the beginning
of the next choreographer frame."
Test: EffectsTests.kt

Change-Id: I70403eea442a7a003f08e7b1d19e44e0134ea077
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
index de2905f..56dc4f5 100644
--- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
+++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
@@ -27,7 +27,7 @@
 import androidx.compose.runtime.Stable
 import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.onPreCommit
+import androidx.compose.runtime.onCommit
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.setValue
 import androidx.compose.ui.platform.AnimationClockAmbient
@@ -90,7 +90,7 @@
         // TODO(b/150674848): Should be onCommit, but that posts to the Choreographer. Until that
         //  callback is executed, nothing is aware that the animation is kicked off, so if
         //  Espresso checks for idleness between now and then, it will think all is idle.
-        onPreCommit(model, toState) {
+        onCommit(model, toState) {
             model.anim.toState(toState)
         }
         return model
diff --git a/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt b/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt
index 7fc3617..363eaa4 100644
--- a/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt
+++ b/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt
@@ -19,7 +19,7 @@
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.State
 import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.onPreCommit
+import androidx.compose.runtime.onCommit
 import androidx.compose.runtime.remember
 import androidx.compose.ui.platform.LifecycleOwnerAmbient
 import androidx.lifecycle.Lifecycle
@@ -55,7 +55,7 @@
 fun <R, T : R> LiveData<T>.observeAsState(initial: R): State<R> {
     val lifecycleOwner = LifecycleOwnerAmbient.current
     val state = remember { mutableStateOf(initial) }
-    onPreCommit(this, lifecycleOwner) {
+    onCommit(this, lifecycleOwner) {
         val observer = Observer<T> { state.value = it }
         observe(lifecycleOwner, observer)
         onDispose { removeObserver(observer) }
diff --git a/compose/runtime/runtime-rxjava2/src/main/java/androidx/compose/runtime/rxjava2/RxJava2Adapter.kt b/compose/runtime/runtime-rxjava2/src/main/java/androidx/compose/runtime/rxjava2/RxJava2Adapter.kt
index bfd5c19..28c259b 100644
--- a/compose/runtime/runtime-rxjava2/src/main/java/androidx/compose/runtime/rxjava2/RxJava2Adapter.kt
+++ b/compose/runtime/runtime-rxjava2/src/main/java/androidx/compose/runtime/rxjava2/RxJava2Adapter.kt
@@ -19,7 +19,7 @@
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.State
 import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.onPreCommit
+import androidx.compose.runtime.onCommit
 import androidx.compose.runtime.remember
 import io.reactivex.Completable
 import io.reactivex.Flowable
@@ -212,7 +212,7 @@
     crossinline subscribe: S.((T) -> Unit) -> Disposable
 ): State<T> {
     val state = remember { mutableStateOf(initial) }
-    onPreCommit(this) {
+    onCommit(this) {
         val disposable = subscribe {
             state.value = it
         }
diff --git a/compose/runtime/runtime-saved-instance-state/src/commonMain/kotlin/androidx/compose/runtime/savedinstancestate/RememberSavedInstanceState.kt b/compose/runtime/runtime-saved-instance-state/src/commonMain/kotlin/androidx/compose/runtime/savedinstancestate/RememberSavedInstanceState.kt
index 0cb1e05..342af48 100644
--- a/compose/runtime/runtime-saved-instance-state/src/commonMain/kotlin/androidx/compose/runtime/savedinstancestate/RememberSavedInstanceState.kt
+++ b/compose/runtime/runtime-saved-instance-state/src/commonMain/kotlin/androidx/compose/runtime/savedinstancestate/RememberSavedInstanceState.kt
@@ -21,7 +21,7 @@
 import androidx.compose.runtime.MutableState
 import androidx.compose.runtime.currentComposer
 import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.onPreCommit
+import androidx.compose.runtime.onCommit
 import androidx.compose.runtime.remember
 
 /**
@@ -85,7 +85,7 @@
     saverHolder.value = saver
 
     // re-register if the registry or key has been changed
-    onPreCommit(registry, finalKey) {
+    onCommit(registry, finalKey) {
         if (registry != null) {
             val valueProvider = {
                 with(saverHolder.value) { SaverScopeImpl(registry::canBeSaved).save(value) }
diff --git a/compose/runtime/runtime/api/current.txt b/compose/runtime/runtime/api/current.txt
index 9f3d5da..0b832e0 100644
--- a/compose/runtime/runtime/api/current.txt
+++ b/compose/runtime/runtime/api/current.txt
@@ -198,10 +198,10 @@
     method @androidx.compose.runtime.Composable public static <V1, V2> void onCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
     method @androidx.compose.runtime.Composable public static void onCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
     method @androidx.compose.runtime.Composable public static void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static inline void onPreCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static <V1> void onPreCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static <V1, V2> void onPreCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static void onPreCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static inline void onPreCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static <V1> void onPreCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static <V1, V2> void onPreCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static void onPreCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
   }
 
   public interface EmbeddingContext {
diff --git a/compose/runtime/runtime/api/public_plus_experimental_current.txt b/compose/runtime/runtime/api/public_plus_experimental_current.txt
index 9f3d5da..0b832e0 100644
--- a/compose/runtime/runtime/api/public_plus_experimental_current.txt
+++ b/compose/runtime/runtime/api/public_plus_experimental_current.txt
@@ -198,10 +198,10 @@
     method @androidx.compose.runtime.Composable public static <V1, V2> void onCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
     method @androidx.compose.runtime.Composable public static void onCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
     method @androidx.compose.runtime.Composable public static void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static inline void onPreCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static <V1> void onPreCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static <V1, V2> void onPreCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static void onPreCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static inline void onPreCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static <V1> void onPreCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static <V1, V2> void onPreCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static void onPreCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
   }
 
   public interface EmbeddingContext {
diff --git a/compose/runtime/runtime/api/restricted_current.txt b/compose/runtime/runtime/api/restricted_current.txt
index bb35e2b..5f7b005 100644
--- a/compose/runtime/runtime/api/restricted_current.txt
+++ b/compose/runtime/runtime/api/restricted_current.txt
@@ -217,10 +217,10 @@
     method @androidx.compose.runtime.Composable public static <V1, V2> void onCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
     method @androidx.compose.runtime.Composable public static void onCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
     method @androidx.compose.runtime.Composable public static void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static inline void onPreCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static <V1> void onPreCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static <V1, V2> void onPreCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
-    method @androidx.compose.runtime.Composable public static void onPreCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static inline void onPreCommit(kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static <V1> void onPreCommit(V1? v1, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static <V1, V2> void onPreCommit(V1? v1, V2? v2, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
+    method @Deprecated @androidx.compose.runtime.Composable public static void onPreCommit(Object![]? inputs, kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> callback);
   }
 
   public interface EmbeddingContext {
@@ -328,12 +328,6 @@
     method public void removeValue(V value);
   }
 
-  @kotlin.PublishedApi internal final class PostCommitScopeImpl implements android.view.Choreographer.FrameCallback androidx.compose.runtime.CommitScope androidx.compose.runtime.CompositionLifecycleObserver {
-    ctor public PostCommitScopeImpl(internal kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> onCommit, androidx.compose.runtime.EmbeddingContext embeddingContext);
-    method public void doFrame(long frameTimeNanos);
-    method public void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
-  }
-
   @kotlin.PublishedApi internal final class PreCommitScopeImpl implements androidx.compose.runtime.CommitScope androidx.compose.runtime.CompositionLifecycleObserver {
     ctor public PreCommitScopeImpl(internal kotlin.jvm.functions.Function1<? super androidx.compose.runtime.CommitScope,kotlin.Unit> onCommit);
     method public void onDispose(kotlin.jvm.functions.Function0<kotlin.Unit> callback);
diff --git a/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/DisposeTests.kt b/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/DisposeTests.kt
index 608b75b..c3da861 100644
--- a/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/DisposeTests.kt
+++ b/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/DisposeTests.kt
@@ -41,10 +41,10 @@
 
         @OptIn(ExperimentalComposeApi::class)
         val composable = @Composable @ComposableContract(tracked = false) {
-            onPreCommit {
-                log.add("onPreCommit")
+            onCommit {
+                log.add("onCommit")
                 onDispose {
-                    log.add("onPreCommitDispose")
+                    log.add("onCommitDispose")
                 }
             }
             onActive {
@@ -63,24 +63,24 @@
 
         var composition: Composition? = null
 
-        assertLog("onPreCommit, onActive") {
+        assertLog("onCommit, onActive") {
             composition = activity.show(composable)
             activity.waitForAFrame()
         }
 
-        assertLog("onPreCommitDispose, onPreCommit") {
+        assertLog("onCommitDispose, onCommit") {
             activity.show(composable)
             activity.waitForAFrame()
         }
 
-        assertLog("onActiveDispose, onPreCommitDispose") {
+        assertLog("onActiveDispose, onCommitDispose") {
             activity.uiThread {
                 composition?.dispose()
             }
             activity.waitForAFrame()
         }
 
-        assertLog("onPreCommit, onActive") {
+        assertLog("onCommit, onActive") {
             activity.show(composable)
             activity.waitForAFrame()
         }
diff --git a/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/EffectsTests.kt b/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/EffectsTests.kt
index 78f96f3..d819da7 100644
--- a/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/EffectsTests.kt
+++ b/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/EffectsTests.kt
@@ -175,7 +175,7 @@
     }
 
     @Test
-    fun testPreCommit1() {
+    fun testCommit1() {
         var mount by mutableStateOf(true)
 
         val logHistory = mutableListOf<String>()
@@ -184,8 +184,8 @@
         @Composable
         fun Unmountable() {
             log("Unmountable:start")
-            onPreCommit {
-                log("onPreCommit")
+            onCommit {
+                log("onCommit")
                 onDispose {
                     log("onDispose")
                 }
@@ -206,7 +206,7 @@
                     "Unmountable:start",
                     "Unmountable:end",
                     "compose:end",
-                    "onPreCommit"
+                    "onCommit"
                 ),
                 logHistory
             )
@@ -218,7 +218,7 @@
                     "Unmountable:start",
                     "Unmountable:end",
                     "compose:end",
-                    "onPreCommit",
+                    "onCommit",
                     "compose:start",
                     "compose:end",
                     "onDispose"
@@ -229,7 +229,7 @@
     }
 
     @Test
-    fun testPreCommit2() {
+    fun testCommit2() {
         var mount by mutableStateOf(true)
 
         val logHistory = mutableListOf<String>()
@@ -237,14 +237,14 @@
 
         @Composable
         fun Unmountable() {
-            onPreCommit {
-                log("onPreCommit:a2")
+            onCommit {
+                log("onCommit:a2")
                 onDispose {
                     log("onDispose:a2")
                 }
             }
-            onPreCommit {
-                log("onPreCommit:b2")
+            onCommit {
+                log("onCommit:b2")
                 onDispose {
                     log("onDispose:b2")
                 }
@@ -252,8 +252,8 @@
         }
 
         compose {
-            onPreCommit {
-                log("onPreCommit:a1")
+            onCommit {
+                log("onCommit:a1")
                 onDispose {
                     log("onDispose:a1")
                 }
@@ -261,8 +261,8 @@
             if (mount) {
                 Unmountable()
             }
-            onPreCommit {
-                log("onPreCommit:b1")
+            onCommit {
+                log("onCommit:b1")
                 onDispose {
                     log("onDispose:b1")
                 }
@@ -270,10 +270,10 @@
         }.then { _ ->
             assertArrayEquals(
                 listOf(
-                    "onPreCommit:a1",
-                    "onPreCommit:a2",
-                    "onPreCommit:b2",
-                    "onPreCommit:b1"
+                    "onCommit:a1",
+                    "onCommit:a2",
+                    "onCommit:b2",
+                    "onCommit:b1"
                 ),
                 logHistory
             )
@@ -282,17 +282,17 @@
         }.then { _ ->
             assertArrayEquals(
                 listOf(
-                    "onPreCommit:a1",
-                    "onPreCommit:a2",
-                    "onPreCommit:b2",
-                    "onPreCommit:b1",
+                    "onCommit:a1",
+                    "onCommit:a2",
+                    "onCommit:b2",
+                    "onCommit:b1",
                     "recompose",
                     "onDispose:b2",
                     "onDispose:a2",
                     "onDispose:b1",
                     "onDispose:a1",
-                    "onPreCommit:a1",
-                    "onPreCommit:b1"
+                    "onCommit:a1",
+                    "onCommit:b1"
                 ),
                 logHistory
             )
@@ -300,7 +300,7 @@
     }
 
     @Test
-    fun testPreCommit3() {
+    fun testCommit3() {
         var x = 0
         val trigger = Trigger()
 
@@ -309,9 +309,9 @@
 
         compose {
             trigger.subscribe()
-            onPreCommit {
+            onCommit {
                 val y = x++
-                log("onPreCommit:$y")
+                log("onCommit:$y")
                 onDispose {
                     log("dispose:$y")
                 }
@@ -322,10 +322,10 @@
         }.then { _ ->
             assertArrayEquals(
                 listOf(
-                    "onPreCommit:0",
+                    "onCommit:0",
                     "recompose",
                     "dispose:0",
-                    "onPreCommit:1"
+                    "onCommit:1"
                 ),
                 logHistory
             )
@@ -333,7 +333,7 @@
     }
 
     @Test
-    fun testPreCommit31() {
+    fun testCommit31() {
         var a = 0
         var b = 0
         val trigger = Trigger()
@@ -343,16 +343,16 @@
 
         compose {
             trigger.subscribe()
-            onPreCommit {
+            onCommit {
                 val y = a++
-                log("onPreCommit a:$y")
+                log("onCommit a:$y")
                 onDispose {
                     log("dispose a:$y")
                 }
             }
-            onPreCommit {
+            onCommit {
                 val y = b++
-                log("onPreCommit b:$y")
+                log("onCommit b:$y")
                 onDispose {
                     log("dispose b:$y")
                 }
@@ -363,13 +363,13 @@
         }.then { _ ->
             assertArrayEquals(
                 listOf(
-                    "onPreCommit a:0",
-                    "onPreCommit b:0",
+                    "onCommit a:0",
+                    "onCommit b:0",
                     "recompose",
                     "dispose b:0",
                     "dispose a:0",
-                    "onPreCommit a:1",
-                    "onPreCommit b:1"
+                    "onCommit a:1",
+                    "onCommit b:1"
                 ),
                 logHistory
             )
@@ -377,7 +377,7 @@
     }
 
     @Test
-    fun testPreCommit4() {
+    fun testCommit4() {
         var x = 0
         var key = 123
         val trigger = Trigger()
@@ -387,9 +387,9 @@
 
         compose {
             trigger.subscribe()
-            onPreCommit(key) {
+            onCommit(key) {
                 val y = x++
-                log("onPreCommit:$y")
+                log("onCommit:$y")
                 onDispose {
                     log("dispose:$y")
                 }
@@ -400,7 +400,7 @@
         }.then { _ ->
             assertArrayEquals(
                 listOf(
-                    "onPreCommit:0",
+                    "onCommit:0",
                     "recompose"
                 ),
                 logHistory
@@ -411,11 +411,11 @@
         }.then { _ ->
             assertArrayEquals(
                 listOf(
-                    "onPreCommit:0",
+                    "onCommit:0",
                     "recompose",
                     "recompose (key -> 345)",
                     "dispose:0",
-                    "onPreCommit:1"
+                    "onCommit:1"
                 ),
                 logHistory
             )
@@ -423,7 +423,7 @@
     }
 
     @Test
-    fun testPreCommit5() {
+    fun testCommit5() {
         var a = 0
         var b = 0
         var c = 0
@@ -435,9 +435,9 @@
         @Composable
         fun Sub() {
             trigger.subscribe()
-            onPreCommit {
+            onCommit {
                 val y = c++
-                log("onPreCommit c:$y")
+                log("onCommit c:$y")
                 onDispose {
                     log("dispose c:$y")
                 }
@@ -446,17 +446,17 @@
 
         compose {
             trigger.subscribe()
-            onPreCommit {
+            onCommit {
                 val y = a++
-                log("onPreCommit a:$y")
+                log("onCommit a:$y")
                 onDispose {
                     log("dispose a:$y")
                 }
             }
 
-            onPreCommit {
+            onCommit {
                 val y = b++
-                log("onPreCommit b:$y")
+                log("onCommit b:$y")
                 onDispose {
                     log("dispose b:$y")
                 }
@@ -469,16 +469,16 @@
         }.then { _ ->
             assertArrayEquals(
                 listOf(
-                    "onPreCommit a:0",
-                    "onPreCommit b:0",
-                    "onPreCommit c:0",
+                    "onCommit a:0",
+                    "onCommit b:0",
+                    "onCommit c:0",
                     "recompose",
                     "dispose c:0",
                     "dispose b:0",
                     "dispose a:0",
-                    "onPreCommit a:1",
-                    "onPreCommit b:1",
-                    "onPreCommit c:1"
+                    "onCommit a:1",
+                    "onCommit b:1",
+                    "onCommit c:1"
                 ),
                 logHistory
             )
@@ -486,20 +486,20 @@
     }
 
     @Test
-    fun testPreCommit6() {
+    fun testCommit6() {
         var readValue = 0
 
         @Composable
-        fun UpdateStateInPreCommit() {
+        fun UpdateStateInCommit() {
             var value by remember { mutableStateOf(1) }
             readValue = value
-            onPreCommit {
+            onCommit {
                 value = 2
             }
         }
 
         compose {
-            UpdateStateInPreCommit()
+            UpdateStateInCommit()
         }.then { _ ->
             assertEquals(2, readValue)
         }
@@ -538,78 +538,6 @@
     }
 
     @Test
-    fun testOnCommit1() {
-        var mount by mutableStateOf(true)
-
-        val logHistory = mutableListOf<String>()
-        fun log(x: String) = logHistory.add(x)
-
-        @Composable
-        fun Unmountable() {
-            log("Unmountable:start")
-            onCommit {
-                log("onCommit 1")
-                onDispose {
-                    log("onDispose 1")
-                }
-            }
-            onPreCommit {
-                log("onPreCommit 2")
-                onDispose {
-                    log("onDispose 2")
-                }
-            }
-            onCommit {
-                log("onCommit 3")
-                onDispose {
-                    log("onDispose 3")
-                }
-            }
-            log("Unmountable:end")
-        }
-
-        compose {
-                log("compose:start")
-                if (mount) {
-                    Unmountable()
-                }
-                log("compose:end")
-        }.then { _ ->
-            assertArrayEquals(
-                listOf(
-                    "compose:start",
-                    "Unmountable:start",
-                    "Unmountable:end",
-                    "compose:end",
-                    "onPreCommit 2",
-                    "onCommit 1",
-                    "onCommit 3"
-                ),
-                logHistory
-            )
-            mount = false
-        }.then { _ ->
-            assertArrayEquals(
-                listOf(
-                    "compose:start",
-                    "Unmountable:start",
-                    "Unmountable:end",
-                    "compose:end",
-                    "onPreCommit 2",
-                    "onCommit 1",
-                    "onCommit 3",
-                    "compose:start",
-                    "compose:end",
-                    "onDispose 3",
-                    "onDispose 2",
-                    "onDispose 1"
-                ),
-                logHistory
-            )
-        }
-    }
-
-    @Test
     fun testAmbient1() {
         val tv1Id = 100
 
diff --git a/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/SuspendingEffectsTests.kt b/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/SuspendingEffectsTests.kt
index 84b49a7..e6f60a8 100644
--- a/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/SuspendingEffectsTests.kt
+++ b/compose/runtime/runtime/src/androidAndroidTest/kotlin/androidx/compose/runtime/SuspendingEffectsTests.kt
@@ -77,7 +77,7 @@
                     awaitFrameTime = it
                 }
             }
-            onPreCommit(true) {
+            onCommit(true) {
                 Recomposer.current().embeddingContext
                     .postFrameCallback(object : ChoreographerFrameCallback {
                     override fun doFrame(frameTimeNanos: Long) {
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
index b32f511..cdefe5e 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Effects.kt
@@ -60,42 +60,6 @@
     }
 }
 
-@PublishedApi
-internal class PostCommitScopeImpl(
-    internal val onCommit: CommitScope.() -> Unit,
-    private val embeddingContext: EmbeddingContext = Recomposer.current().embeddingContext
-) : CommitScope, CompositionLifecycleObserver, ChoreographerFrameCallback {
-
-    private var disposeCallback = emptyDispose
-    private var hasRun = false
-
-    override fun onDispose(callback: () -> Unit) {
-        require(disposeCallback === emptyDispose) {
-            "onDispose(...) should only be called once"
-        }
-        disposeCallback = callback
-    }
-
-    override fun doFrame(frameTimeNanos: Long) {
-        hasRun = true
-        onCommit(this)
-    }
-
-    override fun onEnter() {
-        embeddingContext.postFrameCallback(this)
-    }
-
-    override fun onLeave() {
-        // If `onCommit` hasn't executed yet, we should not call `onDispose`. We should document
-        // somewhere the invariants we intend to have around call order for these.
-        if (hasRun) {
-            disposeCallback()
-        } else {
-            embeddingContext.cancelFrameCallback(this)
-        }
-    }
-}
-
 /**
  * An effect used to observe the lifecycle of the composition. The [callback] will execute once initially after the first composition
  * is applied, and then will not fire again. The [callback] will get executed with a receiver scope that has an
@@ -107,12 +71,11 @@
  * @param callback The lambda to execute when the composition commits for the first time and becomes active.
  *
  * @see [onCommit]
- * @see [onPreCommit]
  * @see [onDispose]
  */
 @Composable
 fun onActive(callback: CommitScope.() -> Unit) {
-    remember { PostCommitScopeImpl(callback) }
+    remember { PreCommitScopeImpl(callback) }
 }
 
 /**
@@ -123,7 +86,6 @@
  * @param callback The lambda to be executed when the effect leaves the composition.
  *
  * @see [onCommit]
- * @see [onPreCommit]
  * @see [onActive]
  */
 @Composable
@@ -140,14 +102,13 @@
  * @param callback The lambda to be executed when the effect is committed to the composition.
  *
  * @see [onDispose]
- * @see [onPreCommit]
  * @see [onActive]
  */
 @Suppress("NOTHING_TO_INLINE")
 @OptIn(ComposeCompilerApi::class)
 @Composable
 inline fun onCommit(noinline callback: CommitScope.() -> Unit) {
-    currentComposer.changed(PostCommitScopeImpl(callback))
+    currentComposer.changed(PreCommitScopeImpl(callback))
 }
 
 /**
@@ -160,7 +121,6 @@
  * @param callback The lambda to be executed when the effect is committed to the composition.
  *
  * @see [onDispose]
- * @see [onPreCommit]
  * @see [onActive]
  */
 @Composable
@@ -169,7 +129,7 @@
     /*noinline*/
     callback: CommitScope.() -> Unit
 ) {
-    remember(v1) { PostCommitScopeImpl(callback) }
+    remember(v1) { PreCommitScopeImpl(callback) }
 }
 
 /**
@@ -183,7 +143,6 @@
  * @param callback The lambda to be executed when the effect is committed to the composition.
  *
  * @see [onDispose]
- * @see [onPreCommit]
  * @see [onActive]
  */
 @Composable
@@ -193,7 +152,7 @@
     /*noinline*/
     callback: CommitScope.() -> Unit
 ) {
-    remember(v1, v2) { PostCommitScopeImpl(callback) }
+    remember(v1, v2) { PreCommitScopeImpl(callback) }
 }
 
 /**
@@ -206,12 +165,11 @@
  * @param callback The lambda to be executed when the effect is committed to the composition.
  *
  * @see [onDispose]
- * @see [onPreCommit]
  * @see [onActive]
  */
 @Composable
 fun onCommit(vararg inputs: Any?, callback: CommitScope.() -> Unit) {
-    remember(*inputs) { PostCommitScopeImpl(callback) }
+    remember(*inputs) { PreCommitScopeImpl(callback) }
 }
 
 /**
@@ -225,15 +183,13 @@
  * @param callback The lambda to be executed when the effect is committed to the composition.
  *
  * @see [onDispose]
- * @see [onPreCommit]
  * @see [onActive]
  */
 @Suppress("NOTHING_TO_INLINE")
 @OptIn(ComposeCompilerApi::class)
 @Composable
-inline fun onPreCommit(noinline callback: CommitScope.() -> Unit) {
-    currentComposer.changed(PreCommitScopeImpl(callback))
-}
+@Deprecated("onCommit now has onPreCommit's behavior", ReplaceWith("onCommit(callback)"))
+inline fun onPreCommit(noinline callback: CommitScope.() -> Unit) = onCommit(callback)
 
 /**
  * The onPreCommit effect is a lifecycle effect that will execute [callback] every time the inputs to the
@@ -251,13 +207,12 @@
  * @see [onActive]
  */
 @Composable
+@Deprecated("onCommit now has onPreCommit's behavior", ReplaceWith("onCommit(v1, callback)"))
 /*inline*/ fun </*reified*/ V1> onPreCommit(
     v1: V1,
     /*noinline*/
     callback: CommitScope.() -> Unit
-) {
-    remember(v1) { PreCommitScopeImpl(callback) }
-}
+) = onCommit(v1, callback)
 
 /**
  * The onPreCommit effect is a lifecycle effect that will execute [callback] every time the inputs to the
@@ -276,14 +231,13 @@
  * @see [onActive]
  */
 @Composable
+@Deprecated("onCommit now has onPreCommit's behavior", ReplaceWith("onCommit(v1, v2, callback)"))
 /*inline*/ fun </*reified*/ V1, /*reified*/ V2> onPreCommit(
     v1: V1,
     v2: V2,
     /*noinline*/
     callback: CommitScope.() -> Unit
-) {
-    remember(v1, v2) { PreCommitScopeImpl(callback) }
-}
+) = onCommit(v1, v2, callback)
 
 /**
  * The onPreCommit effect is a lifecycle effect that will execute [callback] every time the inputs to the
@@ -301,9 +255,12 @@
  * @see [onActive]
  */
 @Composable
-fun onPreCommit(vararg inputs: Any?, callback: CommitScope.() -> Unit) {
-    remember(*inputs) { PreCommitScopeImpl(callback) }
-}
+@Deprecated(
+    "onCommit now has onPreCommit's behavior",
+    ReplaceWith("onCommit(*inputs, callback = callback)")
+)
+fun onPreCommit(vararg inputs: Any?, callback: CommitScope.() -> Unit) =
+    onCommit(*inputs, callback = callback)
 
 /**
  * The model effect is an alias to the `memo` effect, but the semantics behind how it is used are different from
diff --git a/compose/test-utils/src/androidAndroidTest/kotlin/androidx/ui/test/AndroidComposeTestCaseRunnerTest.kt b/compose/test-utils/src/androidAndroidTest/kotlin/androidx/ui/test/AndroidComposeTestCaseRunnerTest.kt
index bc78761..70c47ab 100644
--- a/compose/test-utils/src/androidAndroidTest/kotlin/androidx/ui/test/AndroidComposeTestCaseRunnerTest.kt
+++ b/compose/test-utils/src/androidAndroidTest/kotlin/androidx/ui/test/AndroidComposeTestCaseRunnerTest.kt
@@ -21,7 +21,7 @@
 import androidx.compose.foundation.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.onPreCommit
+import androidx.compose.runtime.onCommit
 import androidx.compose.runtime.remember
 import androidx.test.filters.SmallTest
 import androidx.ui.test.android.AndroidComposeTestRule
@@ -87,7 +87,7 @@
         composeTestRule.forGivenContent {
             val state = remember { mutableStateOf(0) }
             Text("Hello ${state.value}")
-            onPreCommit {
+            onCommit {
                 state.value++
             }
         }.performTestWithEventsControl {