apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Edit not applied to failed upload

Open nicolas-raoul opened this issue 2 months ago • 14 comments

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 avatar Sep 19 '26 14:09 nicolas-raoul

@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

  1. Selected an image(using camera,gallery,custom selector)
  2. Edited (blurred using in app blur )
  3. Queued image for upload
  4. Switched off internet access for the emulator.
  5. Upload failed.
  6. After enabling internet access to device retried to upload.
  7. Then checked the uploaded image,its blurred. Is there any steps you want exactly to follow for reproducing...

devendrachoudharycodes avatar Sep 29 '26 11:09 devendrachoudharycodes

@nicolas-raoul any updates : )

devendrachoudharycodes avatar Oct 14 '26 06:10 devendrachoudharycodes

I am willing to solve this @nicolas-raoul

Lemeri123 avatar Oct 14 '26 08:10 Lemeri123

@Lemeri123 Are you able to reproduce the issue?

nicolas-raoul avatar Oct 14 '26 13:10 nicolas-raoul

Let me try it out now

Lemeri123 avatar Oct 14 '26 13:10 Lemeri123

@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: Image

After blur: Image

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 avatar Oct 14 '26 18:10 benndip

@benndip yes thats how its supposed to appear

Lemeri123 avatar Oct 14 '26 20:10 Lemeri123

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 avatar Oct 14 '26 21:10 benndip

@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. :-)

nicolas-raoul avatar Oct 15 '26 06:10 nicolas-raoul

@benndip Feel free to create a Feature issue about blurring "radius size" or pixelization "pixel size". Thanks!

nicolas-raoul avatar Oct 15 '26 06:10 nicolas-raoul

Alright @nicolas-raoul, I am creating an issue on that now

benndip avatar Oct 15 '26 06:10 benndip

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

  1. Share a JPEG to the app and tap Edit Image.
  2. Blur a region and tap Apply.
  3. 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".
  4. Tap Save. The upload screen shows the blurred preview.
  5. 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?

yuvarajvodiboina avatar Nov 05 '26 15:11 yuvarajvodiboina

Assigned to you, @yuvarajvodiboina! Thanks for the thorough investigation and reproduction steps!

nicolas-raoul avatar Nov 05 '26 22:11 nicolas-raoul

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.

yuvarajvodiboina avatar Nov 06 '26 06:11 yuvarajvodiboina