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

Fatal Exception: java.util.ConcurrentModificationException #222

Open
1 task done
tintil opened this issue Aug 19, 2024 · 0 comments
Open
1 task done

Fatal Exception: java.util.ConcurrentModificationException #222

tintil opened this issue Aug 19, 2024 · 0 comments

Comments

@tintil
Copy link

tintil commented Aug 19, 2024

New Issue Checklist

  • I have searched for a similar issue in the project and found none

Issue Info

Info Value
Device Info Xiaomi Redmi Note9, Samsung Galaxy A7, etc..
System Version 8.0-14.0
APNG4Android Library Version 2.28.0
Repro rate sometimes
Repro with our demo project -
Demo project link -

Issue Description and Steps

We get the following exception in our project from time to time. It seems to happen when stop and unregisterAnimationCallback are called close to one another.

My guess is that https://github.com/penfeizhou/APNG4Android/blob/master/frameanimation/src/main/java/com/github/penfeizhou/animation/FrameAnimationDrawable.java#L60 is still not safe since copying over a set to an array most likely involves an iteration. Which can cause an exception if the set is modified at the same time.

I can try to write a demo project which reproduces the exception if necessary.

       Fatal Exception: java.util.ConcurrentModificationException:
       at java.util.HashMap$HashIterator.nextNode(HashMap.java:1441)
       at java.util.HashMap$KeyIterator.next(HashMap.java:1465)
       at java.util.AbstractCollection.finishToArray(AbstractCollection.java:232)
       at java.util.AbstractCollection.toArray(AbstractCollection.java:143)
       at java.util.ArrayList.<init>(ArrayList.java:191)
       at com.github.penfeizhou.animation.FrameAnimationDrawable$1.handleMessage(FrameAnimationDrawable.java:60)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7366)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
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

No branches or pull requests

1 participant