-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix: IndexOutOfBoundsException crash when removing last two images of multiupload #6124
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
Conversation
Looks great, thanks! |
549ca38
to
43eb577
Compare
Done 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting this crash when trying to remove the middle picture, any idea what might be the issue? 🙂
APP_VERSION_NAME=5.1.2-debug-rohit9625-fix-multiupload
ANDROID_VERSION=15
PHONE_MODEL=Pixel 9 Pro
STACK_TRACE=kotlin.UninitializedPropertyAccessException: lateinit property basicKvStoreFactory has not been initialized
at fr.free.nrw.commons.upload.mediaDetails.UploadMediaPresenter.getBasicKvStoreFactory(UploadMediaPresenter.kt:54)
at fr.free.nrw.commons.upload.mediaDetails.UploadMediaPresenter.updateImageQualitiesJSON(UploadMediaPresenter.kt:366)
at fr.free.nrw.commons.upload.UploadPresenter.deletePictureAtIndex(UploadPresenter.kt:162)
at fr.free.nrw.commons.upload.UploadActivity.onThumbnailDeleted(UploadActivity.kt:776)
at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder.bind$lambda$0(ThumbnailsAdapter.kt:72)
at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder.$r8$lambda$h9qbE-GosgolnpmsfOlWqsny9oU(Unknown Source:0)
at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder$$ExternalSyntheticLambda1.onClick(D8$$SyntheticClass:0)
at android.view.View.performClick(View.java:8081)
at android.view.View.performClickInternal(View.java:8058)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:31517)
at android.os.Handler.handleCallback(Handler.java:991)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8934)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
Doesn't happen on my device. What are the exact steps you followed? |
I just tried the latest commit of this branch, I get the same crash: screen-20250119-073306.mp4 |
Did you try uninstalling and then installing again? Please try using a different triplet of images. |
Would you mind solving the conflict? |
Yeah sure :) |
Well, I believe it should not crash for any group of picture, even without reinstalling. :-) |
Yes, you're right. But, the error was about |
Hey @nicolas-raoul, would you mind testing it again? |
) | ||
method.isAccessible = true | ||
method.invoke(activity) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for removing this unit test?
Any idea why the second pic gets removed here? I clicked X only for the last 2 pics. screen-20250308-225937.mp4 |
When we remove the last picture from the row, all of them are getting removed. I asked about this here in the issue |
This branch is solving the crash. 👍 screen-20250313-203751.mp4 |
I couldn't reproduce this on my end. I just tried the repro steps on the main and this branch, and they work perfectly fine. |
Ohh sorry, I misunderstood the repro steps. Yes, I can see the top card on the depicts screen, and I believe that was the reason someone added that condition when removing the last image from thumbnails. Don't worry, I am looking into this and will find a better way to handle that. |
5916d00
to
e15d8b1
Compare
Hey @nicolas-raoul, I fixed the thumbnail-card issue. Now, the top card doesn't hide when removing the last image and also doesn't show up on other fragments while deleting images, as addressed in this comment. Fix_Top_Thumbnail_Card.mp4 |
Can a contributor squash their commits to ensure a clean commit history? I saw that you do this when merging our PRs. |
We usually squash when merging, which is good enough I believe. :-) |
replace deprecated onBackPressed with onBackPressedCallback remove unit test for deprecated onBackPressed method remove if-check before deleting picture to prevent hiding top thumbnail card hide the thumbnail card on fragments other than MediaDetailFragment
3842ba9
to
21ca968
Compare
Well, I squashed all my commits and force-pushed. Next time, if possible, I'll try to squash them before creating a PR. Please check this branch to see if it fixes both issues. |
It is normal to have many commits in a pull request, because most PRs are not perfect at first and thus need more commits. |
Oh, okay got it. I'll keep that in my mind next time and avoid force pushing from now. |
Thanks for your understanding :-) |
✅ Generated APK variants! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to solve the issue.
In the future please perform refactoring in a separate pull request, thanks! :-)
Description (required)
Fixes #6122
What changes did you make and why?
When removing images from
Thumbnails Row
, the uploadableImages property insideThubnailsAdapter
was not updating. It results in the image being removed at an invalid index and sometimesIndexOutOfBoundsException
.So, I added the code to notify the adapter that the image was removed.
Tests performed (required)
Tested ProdDebug on Samsung A14 with API level 34.
Screenshots (for UI changes only)
Screencast after fix
After_Fix.mp4