Fix/recycler view#128
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR targets RecyclerView lifecycle problems with DotLottieAnimation (crashes during fast scrolling and animations disappearing after recycling) by reworking when the drawable/setup work is (re)triggered across attach/detach, and bumps the module version for release.
Changes:
- Re-initialize the internal coroutine scope when needed and avoid redundant setup calls.
- Trigger drawable setup on
onAttachedToWindow()when the view is (re)attached and size is known (or after layout). - Bump
dotlottiemodule version to0.14.1.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dotlottie/src/main/java/com/lottiefiles/dotlottie/core/widget/DotLottieAnimation.kt | Adds attach-time setup and scope reactivation logic to improve RecyclerView reuse behavior. |
| dotlottie/build.gradle.kts | Version bump to publish the fix. |
Comments suppressed due to low confidence (1)
dotlottie/src/main/java/com/lottiefiles/dotlottie/core/widget/DotLottieAnimation.kt:391
setupConfigJobis cancelled inonDetachedFromWindow(), butDotLottieUtils.getContent(...)is suspension-based (callback) and may still resume after cancellation. Without a guard, this coroutine can still assign a newmLottieDrawableafter the view is detached, racing withrelease()and potentially reproducing the SIGSEGV/crash this PR is trying to fix. Add an early return aftergetContentwhen the coroutine is no longer active or the view is not attached.
runCatching {
val content = DotLottieUtils.getContent(context, config.source)
mLottieDrawable = DotLottieDrawable(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Solves
#45
#85