Wordpress-ios: [Offline Posting] Duplicate posts may appear in the Post List

Created on 29 Oct 2019  ·  11Comments  ·  Source: wordpress-mobile/WordPress-iOS

Expected behavior

Only one post is shown.

Actual behavior

Two posts are shown. The other one disappears after pulling to refresh.

Steps to reproduce the behavior

  1. Go offline.
  2. Create a post and save it as a draft.
  3. While still in the Post List, go online.
  4. As soon as you see that the draft is getting uploaded, tap between Published and Drafts lists multiple times. Do this until it finishes uploading.
  5. Go back to the Drafts list and look for the duplicated post.

It may take a few tries to reproduce the issue.

Tested on iPhone XS, iOS 12.4.1, WPiOS develop (d2d9ada)

Notes

This may be related to https://github.com/wordpress-mobile/WordPress-iOS/issues/5364 and https://github.com/wordpress-mobile/WordPress-iOS/pull/6102.

As far as I can tell, only one post is created on the server. This looks like a Core Data concurrency issue.

Posts List [Status] Needs Testing [Type] Bug

Most helpful comment

@guarani I'd say that a new issue for online makes more sense IMHO.

Anyway, duplicated posts it's something that I've seen popping up on different occasions and multiple times. :( This one apparently involves the FAB button... so maybe the prev fixes doesn't apply to it somehow?

All 11 comments

I think this is a duplicate of https://github.com/wordpress-mobile/WordPress-iOS/issues/12164. @jklausa should we close https://github.com/wordpress-mobile/WordPress-iOS/issues/12164 since this issue is already in an In Progress list in the Offline Support: Posting [iOS] project?

Thanks @designsimply, you're right. I'm closing the other issue as duplicate.

@designsimply ah, I knew that issue seemed familiar but I couldn't find #12164 in my cursory search. Glad someone here has better memory and/or search skills :)

@yaelirub Thanks for closing the other one!

So, I was looking into this yesterday and today morning and I'm pretty sure now that @shiki was correct and this is indeed a Core Data issue, as no duplicate posts get made on the backend.

What's going on here, is that _sometimes_ when a post is being uploaded, from the _main thread context_'s point of view, there are suddenly now _two_ posts — with the same contents, but otherwise separate objects. This usually get's fixed on relaunch if the post gets uploaded succesfully, but I also once saw it persist across relaunches. So this screams multi-thread Core Data weirdness to me.

I spend some time trying to change the posting logic to change how they handle the multi-threaded nature of them, but mostly made things worse.

If I can't make the root-cause disappear by the end of day, I'll write a workaround to just filter out the post in the post list.

@jklausa I'm not well versed with how AbstractPost.revisionworks but I wonder if we're seeing 2 posts because the first one is the original, and the other is the original.revision.

Perhaps the deleted revision on this block was not synchronized to the main context right away?

https://github.com/wordpress-mobile/WordPress-iOS/blob/d9d5e904b76aeffee9c60f396b09d8aa2cffb919/WordPress/Classes/Services/PostService.m#L270-L276

While testing 14.6 beta, I found that duplicates appear in the Pages List as well and when publishing online, particularly, if you use the X at top left to leave a new draft then tap "Save Draft" in the bottom sheet. (1m47s)

IMG_3628

Tested with WPiOS 14.6.0.1 TestFlight beta on iPhone 6S iOS 13.3.1.

@shiki or @leandroalonso, should this note be filed as a separate issue since it's online vs offline and Pages not Posts?

This bug seems to occur when the device is online as well, using these steps to reproduce:

  1. Navigate to the site screen
  2. Tap the create button (the floating action button) and select blog post
  3. Add any content and tap Publish followed by Publish Now
  4. Immediately tap the Posts button to show the post list screen
  5. Notice that the newly added post appears twice in the post list

@shiki or @designsimply do you agree I can add the above to the main issue comment? Would it be appropriate to remove this from offline posting or leave it as-is?

@guarani I'd say that a new issue for online makes more sense IMHO.

Anyway, duplicated posts it's something that I've seen popping up on different occasions and multiple times. :( This one apparently involves the FAB button... so maybe the prev fixes doesn't apply to it somehow?

+1 to what Leandro said.

do you agree I can add the above to the main issue comment?

I say yes.

Would it be appropriate to remove this from offline posting or leave it as-is?

I'd say remove it

I agree with Yael and Leandro. 😄 Thanks, @guarani!

Thanks for the input, y'all! I've reopened the separate issue, https://github.com/wordpress-mobile/WordPress-iOS/issues/14572 👍

Was this page helpful?
0 / 5 - 0 ratings