- 
                Notifications
    
You must be signed in to change notification settings  - Fork 68
 
Description
I was struggling with this crash in my Compose-based app upon tapping an icon button that opens a CascadeDropDownMenu, so I built and ran the sample app's ComposeSampleActivity locally, and saw the same problem. The app exits immediately (with no backtrace, and I can't catch it in the debugger) after this error message:
2025-02-09 19:35:03.622 10732-10766 OpenGLRenderer          me.saket.cascade.sample              E  resultIndex is -1, the polygon must be invalid! 
I tried various things including updating the project to the latest SDK, Kotlin version, etc., but those did not help.
Finally, I ran across this excellent post by the PSPDFKit team: How to Fix a Bug, Blindfolded., which mentions:
Our focus was immediately drawn to the initial scale value of the animation, which was 0.0f. [...]
Anyhow, we changed the initial value from 0.0f to 0.01f – and the crash was gone. This was by no means a fix for the crash, but definitely a proper triage.
Which led me to try this:
diff --git a/cascade-compose/src/main/java/me/saket/cascade/internal/AnimateEntryExit.kt b/cascade-compose/src/main/java/me/saket/cascade/internal/AnimateEntryExit.kt
index 4a7e492..c2d7110 100644
--- a/cascade-compose/src/main/java/me/saket/cascade/internal/AnimateEntryExit.kt
+++ b/cascade-compose/src/main/java/me/saket/cascade/internal/AnimateEntryExit.kt
@@ -52,7 +52,7 @@ internal fun AnimateEntryExit(
       tween(if (false isTransitioningTo true) InTransitionDuration else OutTransitionDuration)
     },
     label = "scale",
-    targetValueByState = { if (it) 1f else 0f }
+    targetValueByState = { if (it) 1f else 0.01f }
   )
   val alpha by isExpandedTransition.animateFloat(
     transitionSpec = {
And what do you know—the sample app no longer crashed! 🎉