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

IndexOutOfBoundsException in HabitCardListCache$RefreshTask.performMove #968

Closed
2 tasks done
iSoron opened this issue Jun 5, 2021 · 3 comments
Closed
2 tasks done
Assignees
Labels
bug Something is not behaving as the developers expected cant-reproduce The developers cannot replicate the issue on their own devices high-severity
Milestone

Comments

@iSoron
Copy link
Owner

iSoron commented Jun 5, 2021

Pre-submission checklist

  • I am submitting a bug report, not a feature request.
  • I have searched for similar issues, but did not find any matches.

Description

From Google Play Console:

java.lang.IndexOutOfBoundsException: 
  at java.util.LinkedList.checkPositionIndex (LinkedList.java:561)
  at java.util.LinkedList.add (LinkedList.java:508)
  at org.isoron.uhabits.core.ui.screens.habits.list.HabitCardListCache$RefreshTask.performMove (HabitCardListCache.kt:319)
  at org.isoron.uhabits.core.ui.screens.habits.list.HabitCardListCache$RefreshTask.processPosition (HabitCardListCache.kt:346)
  at org.isoron.uhabits.core.ui.screens.habits.list.HabitCardListCache$RefreshTask.onProgressUpdate (HabitCardListCache.kt:299)
  at org.isoron.uhabits.tasks.AndroidTaskRunner$CustomAsyncTask.onProgressUpdate (AndroidTaskRunner.kt:86)
  at org.isoron.uhabits.tasks.AndroidTaskRunner$CustomAsyncTask.<init> (AndroidTaskRunner.kt:57)
  at org.isoron.uhabits.tasks.AndroidTaskRunner$CustomAsyncTask.onProgressUpdate (AndroidTaskRunner.kt:57)
  at android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:716)
  at android.os.Handler.dispatchMessage (Handler.java:112)
  at android.os.Looper.loop (Looper.java:216)
  at android.app.ActivityThread.main (ActivityThread.java:7625)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)

Steps to reproduce

Unknown

System information

  • Phone: Multiple (Samsung, Huawei)
  • Phone Operating System: Multiple (Android 9, 11)
  • App version: 2.0.2
@iSoron iSoron added bug Something is not behaving as the developers expected cant-reproduce The developers cannot replicate the issue on their own devices high-severity labels Jun 5, 2021
@iSoron iSoron added this to the Loop 2.0.3 milestone Jun 5, 2021
@hiqua
Copy link
Collaborator

hiqua commented Aug 1, 2021

I don't know the exact origin of this bug, but for now, would it be enough to change toPosition in this statement:

        @Synchronized
        private fun performMove(
            habit: Habit,
            fromPosition: Int,
            toPosition: Int
        ) {
            data.habits.removeAt(fromPosition)
            data.habits.size
            data.habits.add(toPosition, habit)
            listener.onItemMoved(fromPosition, toPosition)
        }

to something like min(toPosition, data.habits.size)? And we could log a warning with the change of indexes.

@iSoron
Copy link
Owner Author

iSoron commented Aug 2, 2021

@hiqua Yes, I think that would be fine.

@hiqua hiqua self-assigned this Aug 3, 2021
hiqua added a commit to hiqua/uhabits that referenced this issue Aug 3, 2021
hiqua added a commit to hiqua/uhabits that referenced this issue Aug 5, 2021
hiqua added a commit to hiqua/uhabits that referenced this issue Aug 6, 2021
hiqua added a commit to hiqua/uhabits that referenced this issue Aug 6, 2021
@iSoron
Copy link
Owner Author

iSoron commented Aug 6, 2021

Fixed in branch hotfix/2.0.3

@iSoron iSoron closed this as completed Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not behaving as the developers expected cant-reproduce The developers cannot replicate the issue on their own devices high-severity
Projects
None yet
Development

No branches or pull requests

2 participants