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

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Dec 15, 2023

Description

Improve the media upload experience in the post editor by automatically retrying
failed uploads when re-establishing network connectivity.

Fixes wordpress-mobile/gutenberg-mobile#6406.

Testing Instructions

When network connectivity is available

  1. Launch the editor.
  2. Add several media blocks, attaching media to the blocks.
  3. Disconnect your device network connection.
  4. Note the failed state of media uploads.
  5. Connect your device network connection.
  6. Verify the media uploads automatically restart and succeed.

When network connectivity is unavailable

  1. Launch the editor.
  2. Add several media blocks, attaching media to the blocks.
  3. Note the failed state of media uploads.
  4. Connect your device network connection.
  5. Verify the media uploads automatically restart and succeed.

Regression Notes

  1. Potential unintended areas of impact
    Editor media uploads, editor launch, writing flow.
  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Insert and interact with various blocks using the editor.
  3. What automated tests I added (or what prevented me from doing so)
    None, lack of familiarity with the testing stack.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

UI Changes testing checklist:

  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

Improve the media upload UX by automatically retrying failed uploads.
@dcalhoun dcalhoun added [Type] Enhancement Media Gutenberg Editing and display of Gutenberg blocks. labels Dec 15, 2023
@@ -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! 🙇🏻‍♂️

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 15, 2023

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr19803-d459991
Commitd459991
Direct Downloadjetpack-prototype-build-pr19803-d459991.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 15, 2023

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr19803-d459991
Commitd459991
Direct Downloadwordpress-prototype-build-pr19803-d459991.apk
Note: Google Login is not supported on these builds.

We will enable the feature in production once all project work is
completed.
This was originally added in an attempt to clear an unexpected "failed
media upload" notification displayed after closing the editor. However,
it did not resolve that issue, it must originate from some other
location. Additionally, it would appears successful media uploads
already manage removing media IDs from the `mFailedMediaIds` collection.
@dcalhoun dcalhoun added this to the 24.0 milestone Dec 16, 2023
@dcalhoun dcalhoun marked this pull request as ready for review December 16, 2023 13:09
@dcalhoun dcalhoun requested a review from derekblank December 16, 2023 13:09
@antonis antonis self-requested a review December 18, 2023 06:55
Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this @dcalhoun 🙇
I tested the implementation in debug mode (47df150) and the app performed as expected. The code also looks good and I only added a minor suggestion 🎉
Overall I think this is an improvement to the current user experience when uploads fail 🏅

dcalhoun and others added 2 commits December 19, 2023 10:49
Retrying media uploads without a network connection will undoubtedly fail again.

Co-authored-by: Antonis Lilis <[email protected]>
Copy link
Contributor

@derekblank derekblank left a comment

Choose a reason for hiding this comment

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

I tested this feature successfully on an internal build, and automated retries are working. Also confirmed that the feature is not active on non-debug/internal builds. 🚀

I removed the RELEASE-NOTES entry, keeping with the precedent that we will add public-facing release notes when the DEBUG flag is removed for this feature.

@derekblank derekblank merged commit c719762 into trunk Dec 28, 2023
20 checks passed
@derekblank derekblank deleted the feat/automatically-retry-pending-media-uploads branch December 28, 2023 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks. Media [Type] Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically restart failed media uploads upon regaining an online connection
4 participants