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

feat: Retry failed media uploads when re-establishing network connection #19803

Merged
merged 6 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
24.0
-----
* [*] Filter media types when sharing files to the editor [https://github.com/wordpress-mobile/WordPress-Android/pull/19754]
* [**] The block editor now automatically retries failed media uploads when network connectivity is re-established. [https://github.com/wordpress-mobile/WordPress-Android/pull/19803]

23.9
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3300,7 +3300,7 @@ public void onRequestDragAndDropPermissions(DragEvent dragEvent) {
}

@Override
public void onMediaRetryAllClicked(Set<String> failedMediaIds) {
public void onMediaRetryAll(Set<String> failedMediaIds) {
UploadService.cancelFinalNotification(this, mEditPostRepository.getPost());
UploadService.cancelFinalNotificationForMedia(this, mSite);
ArrayList<Integer> localMediaIds = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public interface EditorFragmentListener extends DialogVisibilityProvider {
void onAddDeviceMediaClicked(boolean allowMultipleSelection);
void onCaptureVideoClicked();
boolean onMediaRetryClicked(String mediaId);
void onMediaRetryAllClicked(Set<String> mediaIdSet);
void onMediaRetryAll(Set<String> mediaIdSet);
void onMediaUploadCancelClicked(String mediaId);
void onMediaDeleted(String mediaId);
void onUndoMediaCheck(String undoedContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ private void showRetryMediaUploadDialog(final int mediaId) {
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
mEditorFragmentListener.onMediaRetryAllClicked(mFailedMediaIds);
mEditorFragmentListener.onMediaRetryAll(mFailedMediaIds);
}
});

Expand Down Expand Up @@ -1583,5 +1583,9 @@ public void onGutenbergDialogNegativeClicked(@NonNull String instanceTag) {
@Override
public void onConnectionStatusChange(boolean isConnected) {
getGutenbergContainerFragment().onConnectionStatusChange(isConnected);
if (hasFailedMediaUploads()) {
mEditorFragmentListener.onMediaRetryAll(mFailedMediaIds);
mFailedMediaIds.clear();
Copy link
Member Author

@dcalhoun dcalhoun Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure clearing this is necessary, it does not appear to be done elsewhere, e.g., showRetryMediaUploadDialog. This clear was added in an attempt to fix erroneously displayed errors after saving or publishing a post, but it does not appear to work.

Error screenshot

Unexpected failed media upload error after closing editor

Steps to reproduce
  1. Use the prototype build on this PR.
  2. Disable network connectivity.
  3. Add an Image block and attach media.
  4. Enable network connectivity.
  5. Allow the automatic retry of media upload to finish successfully.
  6. Save and close the post.
  7. Note the failed media upload notification.

It appears as though a lingering error state/message is in place, but I am unable to find where that is or how to clear it. I expected onMediaRetryAll to clear it, but it doesn't appear to be doing so.

👋🏻 @antonis. Randomly pinging you for Android expertise and help. 😄 Would you be willing to help me debug why I might see this error when the media attached to the post actually successfully uploads with the new retry logic?

Copy link
Member Author

@dcalhoun dcalhoun Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing the existing functionality of retrying failing media uploads via the dialog presented when tapping a failed image, it appears the lingering error message is a preexisting issue. Semi-related issues are reported in #11039, #15897, and #13427.

Steps to reproduce
  1. Use the latest Play Store app version.
  2. Disable network connectivity.
  3. Add an Image block and attach media.
  4. Enable network connectivity.
  5. Tap the Image block with a failed upload.
  6. Tap "Retry."
  7. After the media finishes uploading successfully, save and close the post.
  8. Note the failed media upload notification.

Therefore, I do not consider this issue blocking. It'd be nice to resolve, but could be done so in a separate PR later.

@antonis please do not feel like it is a priority to help debug this. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure clearing this is necessary

Removing the clearing with c114528 and the reasoning for it sounds good 👍

Therefore, I do not consider this issue blocking. It'd be nice to resolve, but could be done so in a separate PR later.

I was able to reproduce this issue and tried to figure out why this happens. My understanding is that there is a limitation on how the SnackbarSequencer works were this kind of internal notifications are not really canceled once issued. I agree that this can be investigated further and handled in a follow up PR 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for investigating and sharing your insights and perspective. Very helpful! 🙇🏻‍♂️

}
}
}
Loading