Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a potential crash caused by ConcurrentModificationException #113

Merged

Conversation

YkSix
Copy link
Contributor

@YkSix YkSix commented May 9, 2024

Crash logs

java.util.ConcurrentModificationException
  at java.util.ArrayList$Itr.checkForComodification
  at java.util.ArrayList$Itr.next
  at com.linecorp.apng.ApngDrawable.progressAnimationElapsedTime
  at com.linecorp.apng.ApngDrawable.draw
  at android.widget.ImageView.onDraw

Steps to reproduce

If the client registers an animation callback multiple times—potentially due to timing issues or intentional actions by client apps—and then unregisters themselves during the callback execution (a reasonable approach), it triggers a ConcurrentModificationException.

Sample code

// repeat this action multiple times.
apngDrawable.registerAnimationCallback(object : Animatable2Compat.AnimationCallback() {
    override fun onAnimationEnd(drawable: Drawable?) {
        apngDrawable.unregisterAnimationCallback(this)
    }
})

YkSix added 2 commits May 2, 2024 09:55
Stacktrace:

java.util.ConcurrentModificationException
  at java.util.ArrayList$Itr.checkForComodification
  at java.util.ArrayList$Itr.next
  at com.linecorp.apng.ApngDrawable.progressAnimationElapsedTime
  at com.linecorp.apng.ApngDrawable.draw
  at android.widget.ImageView.onDraw
@CLAassistant
Copy link

CLAassistant commented May 9, 2024

CLA assistant check
All committers have signed the CLA.

@r-ralph r-ralph assigned r-ralph and unassigned r-ralph May 22, 2024
@r-ralph r-ralph self-requested a review May 22, 2024 05:59
Copy link
Member

@r-ralph r-ralph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thank you for wrinting test code too :)

@r-ralph r-ralph merged commit 1fea8da into line:master May 22, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants