Edit not applied to failed upload
Using the app's "Edit image" button, I blurred a picture, saved, then submitted it for upload.
Network was not good and the upload failed.
The app then retried, but unfortunately the picture that was uploaded was not the blurred one.
This happened for two pictures.
@nicolas-raoul I have tried to reproduce this issue in android studio's emulator device Pixel 5 api 33-ext5. Steps taken to reproduce this issue
- Selected an image(using camera,gallery,custom selector)
- Edited (blurred using in app blur )
- Queued image for upload
- Switched off internet access for the emulator.
- Upload failed.
- After enabling internet access to device retried to upload.
- Then checked the uploaded image,its blurred. Is there any steps you want exactly to follow for reproducing...
@nicolas-raoul any updates : )
I am willing to solve this @nicolas-raoul
@Lemeri123 Are you able to reproduce the issue?
Let me try it out now
@nicolas-raoul
While trying to reproduce the issue, this is how blurred images show up for me. Is it normal ? The selected area is hidden by a grey overlay instead of an actual blue
Before blur:
After blur:
I wish to know if this is how the blur result is or not, so I can know if to open a new issue about the blur
@benndip yes thats how its supposed to appear
Okay. I thought it will actually be blur. This looks more like putting an overlay on the selected region. @nicolas-raoul please don't you think the blur funtionality doesn't actually work and it's an issue that needs a fix ? because I think the blurred area should still be seen, but not just clear. Maybe accompanied by a blur radius slider as well
@RitikaPahwa4444 what do you think ?
@benndip We blur so much that it is completely single-color. We do this for fear of blurs being unblurred by AI in some edge cases. This was implemented last month, we may identify safe scenarios where lighter blurring is OK, it was just not the priority when developing this feature. :-)
@benndip Feel free to create a Feature issue about blurring "radius size" or pixelization "pixel size". Thanks!
Alright @nicolas-raoul, I am creating an issue on that now
Hi @nicolas-raoul, I'd like to work on this. I could reproduce it on current main, and the edit is already lost before the upload starts, so the failed upload and retry don't seem to be the cause.
Steps
- Share a JPEG to the app and tap Edit Image.
- Blur a region and tap Apply.
- While the editor is still open, make Android recreate the upload screen behind it. Switching dark mode does it, and so would the system freeing memory or "Don't keep activities".
- Tap Save. The upload screen shows the blurred preview.
- Tap Edit Image again. The editor opens the original, unblurred photo, and that is the file that gets uploaded.
Without step 3, the blur is kept as expected.
Cause
UploadMediaDetailFragment keeps the item being edited in editableUploadItem, which isn't saved when the screen is recreated. The edit result then reaches the new fragment, where that field is null. onEditActivityResult() updates the preview first, then editableUploadItem!!.setContentAndMediaUri(editedUri) throws, and the catch (e: Exception) only logs it:
E UploadMediaDetailFragment: java.lang.NullPointerException
at fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.onEditActivityResult(UploadMediaDetailFragment.kt:801)
So the screen shows the blurred image while the upload still uses the original.
Plan
- When the result arrives, get the upload item from the fragment's index instead of relying on
editableUploadItem. - Only update the preview once the item has actually been updated.
- Add a unit test for the recreated-fragment case.
- The location picker result (
onCameraPosition()) uses the same field without a try/catch, so I'll check that path too.
Do you remember whether anything restarted the screen while you were editing, like a theme change or switching to another app?
Assigned to you, @yuvarajvodiboina! Thanks for the thorough investigation and reproduction steps!
Thanks @nicolas-raoul! The fix is in #7252. While testing I found the location picker had the same problem, except there it crashed the app, so the PR fixes that too.