Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 988ae15e authored by Omar Miatello's avatar Omar Miatello
Browse files

We might have delta zero when we change segment

This should not produce a WTF log (or a crash in eng-build).

Test: atest MotionValueTest
Bug: 420622452
Flag: com.android.systemui.scene_container
Change-Id: I93748b0d02fb7215874b650bf9bce9212ce4a6ab
parent 972517ab
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -495,7 +495,8 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static

                        val delta = afterBreakpoint - beforeBreakpoint
                        val deltaIsFinite = delta.fastIsFinite()
                        if (deltaIsFinite && delta != 0f) {
                        if (deltaIsFinite) {
                            if (delta != 0f) {
                                // There is a discontinuity on this breakpoint, that needs to be
                                // animated. The delta is pushed to the spring, to consume the
                                // discontinuity over time.
@@ -505,11 +506,12 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static
                                        velocityDelta = initialSpringVelocity,
                                    )

                            // When *first* crossing a discontinuity in a given frame, the static
                            // mapped velocity observed during previous frame is added as initial
                            // velocity to the spring. This is done ot most once per frame, and only
                            // if there is an actual discontinuity.
                                // When *first* crossing a discontinuity in a given frame, the
                                // static mapped velocity observed during previous frame is added as
                                // initial velocity to the spring. This is done ot most once per
                                // frame, and only if there is an actual discontinuity.
                                initialSpringVelocity = 0f
                            }
                        } else {
                            // The before and / or after mapping produced an non-finite number,
                            // which is not allowed. This intentionally crashes eng-builds, since
+82 −0
Original line number Diff line number Diff line
{
  "frame_ids": [
    0,
    16,
    32,
    48
  ],
  "features": [
    {
      "name": "input",
      "type": "float",
      "data_points": [
        0,
        0.5,
        1,
        1
      ]
    },
    {
      "name": "gestureDirection",
      "type": "string",
      "data_points": [
        "Max",
        "Max",
        "Max",
        "Max"
      ]
    },
    {
      "name": "output",
      "type": "float",
      "data_points": [
        0,
        0,
        0,
        0
      ]
    },
    {
      "name": "outputTarget",
      "type": "float",
      "data_points": [
        0,
        0,
        0,
        0
      ]
    },
    {
      "name": "outputSpring",
      "type": "springParameters",
      "data_points": [
        {
          "stiffness": 100000,
          "dampingRatio": 1
        },
        {
          "stiffness": 700,
          "dampingRatio": 0.9
        },
        {
          "stiffness": 700,
          "dampingRatio": 0.9
        },
        {
          "stiffness": 700,
          "dampingRatio": 0.9
        }
      ]
    },
    {
      "name": "isStable",
      "type": "boolean",
      "data_points": [
        true,
        true,
        true,
        true
      ]
    }
  ]
}
 No newline at end of file
+7 −9
Original line number Diff line number Diff line
@@ -111,6 +111,13 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
            awaitStable()
        }

    @Test
    fun segmentChange_inMaxDirection_zeroDelta() =
        motion.goldenTest(spec = specBuilder(Mapping.Zero) { fixedValueFromCurrent(0.5f) }) {
            animateValueTo(1f, changePerFrame = 0.5f)
            awaitStable()
        }

    @Test
    fun segmentChange_inMinDirection_animatedWhenReachingBreakpoint() =
        motion.goldenTest(
@@ -198,9 +205,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
        ) {
            animateValueTo(21f, changePerFrame = 3f)
            awaitStable()

            // TODO(b/420622452) This test should not produce a WTF log.
            wtfLog.removeLoggedFailures()
        }

    @Test
@@ -214,9 +218,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
        ) {
            animateValueTo(30f, changePerFrame = 3f)
            awaitStable()

            // TODO(b/420622452) This test should not produce a WTF log.
            wtfLog.removeLoggedFailures()
        }

    @Test
@@ -248,9 +249,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
            awaitStable()
            animateValueTo(3f)
            awaitStable()

            // TODO(b/420622452) This test should not produce a WTF log.
            wtfLog.removeLoggedFailures()
        }

    @Test