Skip to content

[Bug]: Premature finish() in LocationPickerActivity cancels async location removal #6872

Description

@Roniscend

Summary

Within the LocationPickerActivity.kt file, when a user tries to delete a location for an image, the removeLocationFromImage() function makes a network call asynchronously via RxJava. Nevertheless, it instantly invokes setResult(RESULT_OK) and finish(), which destroy the activity and hence nullify the compositeDisposable object, cancelling the ongoing network call. Consequently, the deletion operation silently fails, leading to the UI returning back to the previous activity as if the operation was successful, while in reality, no coordinates were ever deleted.

Steps to reproduce

  1. Navigate to an existing uploaded image that already has location/GPS coordinates attached to it.
  2. Tap the edit location option to open the map view
  3. Tap the option to Remove Location
  4. the map screen closes instantly and returns to the previous screen without any loading state.
    5.Update the image information or visit the image at the Wikimedia Commons website the location information is still there since the API request was terminated.

Expected behaviour

LocationPickerActivity should wait for the makeCoordinatesEdit stream from RxJava until it completes before ending its operation by displaying a loader to prevent UI from updating while making a network call.

Actual behaviour

finish() is called immediately after starting the RxJava chain, destroying LocationPickerActivity, clearing compositeDisposable, and dropping the network request.

Device name

Pixel 9

Android version

Android 16

Commons app version

6.5.0-debug

Device logs

No response

Screenshots

Image

Would you like to work on the issue?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions