PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.63k stars 9.02k forks source link

Concurrent Modification Exception #3702

Open eakteam opened 6 years ago

eakteam commented 6 years ago
Fatal Exception: java.util.ConcurrentModificationException
       at java.util.ArrayList$Itr.next(ArrayList.java:831)
       at com.github.mikephil.charting.renderer.LineChartRenderer.drawData(SourceFile:95)
       at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(SourceFile:232)
       at android.view.View.draw(View.java:17185)
       at android.view.View.updateDisplayListIfDirty(View.java:16167)
       at android.view.View.draw(View.java:16951)
       at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
       at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
       at android.support.constraint.ConstraintLayout.dispatchDraw(SourceFile:1606)
       at android.view.View.updateDisplayListIfDirty(View.java:16162)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3711)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3691)
       at android.view.View.updateDisplayListIfDirty(View.java:16130)
       at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:648)
       at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:654)
       at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:762)
       at android.view.ViewRootImpl.draw(ViewRootImpl.java:2800)
       at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2608)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2215)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
       at android.view.Choreographer.doCallbacks(Choreographer.java:686)
       at android.view.Choreographer.doFrame(Choreographer.java:621)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6119)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
penn5 commented 6 years ago

Are you using threads in your application?

eakteam commented 6 years ago

Yes i'm using threads in my App

penn5 commented 6 years ago

Is it possible for two threads to add points simultaneously in your app?

On Wed, 3 Jan 2018, 15:24 Emin Kokalari, notifications@github.com wrote:

Yes i'm using threads in my App

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PhilJay/MPAndroidChart/issues/3702#issuecomment-355038655, or mute the thread https://github.com/notifications/unsubscribe-auth/AFV2wgarszVG4rgOSatZoZb1FzHEqVqLks5tG5uUgaJpZM4RPnIh .

eakteam commented 6 years ago

I depends, i understand what is ConcurrentModificationException but how to fix inside library... Maybe with a CopyOnWriteArrayList<> , but how to make modification on the lib ?

penn5 commented 6 years ago

I don't think you should meddle with the library - you should make a wrapper function and have it synchronise.

On Thu, 4 Jan 2018, 22:17 Emin Kokalari, notifications@github.com wrote:

I depends, i understand what is ConcurrentModificationException but how to fix inside library... Maybe with a CopyOnWriteArrayList<> , but how to make modification on the lib ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PhilJay/MPAndroidChart/issues/3702#issuecomment-355414873, or mute the thread https://github.com/notifications/unsubscribe-auth/AFV2wl1hxl9DzA3w2GG5t-cFPSen75ACks5tHU38gaJpZM4RPnIh .

rangerzhou commented 3 years ago

I also have this issue in version 3.1.0, so it is the lib's bug?