Wordpress-android: Media files are sometimes uploaded with path to local storage

Created on 11 Jul 2019  ·  12Comments  ·  Source: wordpress-mobile/WordPress-Android

local-image-path

Expected behavior

When I attach a media file to a post, the post won't get uploaded until the image gets uploaded and the local path to the image is replaced with url.

Actual behavior

When I attach a media file to a post, the post gets sometimes uploaded even though its content still contains local path to the image.

Steps to reproduce the behavior

  1. Turn on airplane mode
  2. Create a draft and add an image into the content
  3. Click on Back
  4. Create another draft and add the same image into the content
  5. Click on back
  6. Turn off the airplane mode
  7. Wait until the uploads completes
  8. Open the second post
  9. Switch to HTML mode
  10. Notice the post contains a path to the local storage

Another scenario which might result in a post with local path being uploaded to the server got fixed here https://github.com/wordpress-mobile/WordPress-Android/pull/10079#issuecomment-510037492

Gutenberg Media PostinEditing [Pri] High [Type] Bug

All 12 comments

The issue was partially fixed in https://github.com/wordpress-mobile/WordPress-Android/pull/10204 so it's not easily reproducible anymore. However, posts with a path to a local storage are still being uploaded to the server sometimes.

I think this issue might have already been fixed and I believe we shouldn't investigate it until we are able to reproduce it or we are at least sure it's still happening in 13.8 and above.

I think this issue might have already been fixed and I believe we shouldn't investigate it until we are able to reproduce it or we are at least sure it's still happening in 13.8 and above.

Haven't been able to reproduce this myself, I think we can close and only reopen in the future if we find it's happening again 👍

I have been able to reproduce yet another scenario when this bug occurs.

  1. Create a new post (in gutenberg)
  2. Add an image and remove it before the upload completes
  3. Wait for the upload to finish
  4. Click on Undo
  5. Click on publish
  6. Open the post and switch to html
  7. Notice the image contains a local path

local-path-to-image

It might be semi-related to https://github.com/wordpress-mobile/WordPress-Android/issues/11039#issuecomment-571073927

Tried out v14.1-rc-2 (from PlayStore) and seeing the same issue with local path to image staying there in the post content. Here are the steps that consistently replicate the issue for me:

  1. Create a new block post
  2. Add an image block and choose an image from the device
  3. Upload starts but, get out of the post
  4. While still uploading, get into the (draft) post
  5. Exit again while still uploading
  6. Wait for upload to finish while you are on the post list
  7. Get into the post
    8.Image is not showing in the block and getting a WARN: Failed to get size for image: ///data/user/0/org.wordpress.android.beta/cache/… message in the app log

GIF:

local-path-persists

Device: Samsung Galaxy S7Edge, Android version 8.0

@hypest I've found the cause of the issue you described.

This is the post content

<!-- wp:image {"id":16,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="file:///data/user/0/org.wordpress.android/cache/wp-112678977001080317373.jpg" alt="" class="wp-image-16"/></figure>
<!-- /wp:image -->

This is the "matcher"

"<!-- wp:image {\"id\":16} -->"

The post content contains "sizeSlug":"large" which the matcher doesn't expect -> isMediaInGutenbergPostBody returns false and CleanUpMediaToPostAssociationUseCase removes the association of the post to the media item.

Is the sizeSlug expected there? Can we expect some other attributes in the wp:image section?

@designsimply We might want to consider putting this to the top of the groundskeeping priority list. We have two different scenarios with reliable steps for reproducing the issue. I think at least one of the scenarios should be relatively easy to fix.

Is the sizeSlug expected there? Can we expect some other attributes in the wp:image section?

Aha, good job pinning this down @malinajirka ! Yes, we should expect more attributes there and in any order. Example: <!-- wp:image {"align":"full","id":97629,"sizeSlug":"large"} -->

Awesome job finding the culprit @malinajirka ! 👏

@malinajirka, we've been seeing more of these issues pop up in the mobile queue. For example, in 2730889-zen and then 2727375-zen. At least one of these users was using the Aztec editor, not Gutenberg. As this GH issue appears to be specific to Gutenberg, I wanted to double-check whether you think the upcoming fix will address the problem in Aztec too. Do you think this warrants a second GH issue?

@SiobhyB The recent fix won't affect Aztec at all 😞. This ticket has already at least 3 different "unrelated" steps for reproduction. I'd suggest creating a new issue so it's clearer. Thank you!

@malinajirka, thank you! I've created a new report at https://github.com/wordpress-mobile/WordPress-Android/issues/11397.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

designsimply picture designsimply  ·  31Comments

roundhill picture roundhill  ·  33Comments

oguzkocer picture oguzkocer  ·  27Comments

designsimply picture designsimply  ·  29Comments

aerych picture aerych  ·  38Comments