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

[Offline Posting] Duplicate posts may appear in the Post List #12800

Closed
shiki opened this issue Oct 29, 2019 · 12 comments
Closed

[Offline Posting] Duplicate posts may appear in the Post List #12800

shiki opened this issue Oct 29, 2019 · 12 comments

Comments

@shiki
Copy link
Member

shiki commented Oct 29, 2019

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 #5364 and #6102.

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

@shiki shiki added this to Backlog in Offline Support: Posting [iOS] via automation Oct 29, 2019
@shiki shiki moved this from Backlog to Fix as soon as possible in Offline Support: Posting [iOS] Oct 29, 2019
@jklausa jklausa self-assigned this Oct 30, 2019
@jklausa jklausa moved this from Fix as soon as possible to In Progress in Offline Support: Posting [iOS] Oct 30, 2019
@designsimply
Copy link
Contributor

I think this is a duplicate of #12164. @jklausa should we close #12164 since this issue is already in an In Progress list in the Offline Support: Posting [iOS] project?

@yaelirub
Copy link
Contributor

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

@jklausa
Copy link
Contributor

jklausa commented Oct 31, 2019

@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!

@jklausa
Copy link
Contributor

jklausa commented Oct 31, 2019

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.

@shiki
Copy link
Member Author

shiki commented Oct 31, 2019

@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?

AbstractPost *postInContext = (AbstractPost *)[self.managedObjectContext existingObjectWithID:postObjectID error:nil];
if (postInContext) {
if ([postInContext isRevision]) {
postInContext = postInContext.original;
[postInContext applyRevision];
[postInContext deleteRevision];
}

@shiki shiki moved this from In Progress to Work after 13.6 is frozen (Nov 4th) in Offline Support: Posting [iOS] Nov 14, 2019
@leandroalonso leandroalonso moved this from Work after 13.6 is frozen (Nov 4th) to Fix as soon as possible in Offline Support: Posting [iOS] Jan 24, 2020
@designsimply
Copy link
Contributor

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?

@guarani
Copy link
Contributor

guarani commented Aug 10, 2020

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?

@leandroalonso
Copy link
Contributor

@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?

@yaelirub
Copy link
Contributor

+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

@shiki
Copy link
Member Author

shiki commented Aug 11, 2020

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

@guarani
Copy link
Contributor

guarani commented Aug 12, 2020

Thanks for the input, y'all! I've reopened the separate issue, #14572 👍

@kean
Copy link
Contributor

kean commented May 4, 2024

Fixed in #23152

@kean kean closed this as completed May 4, 2024
Offline Support: Posting [iOS] automation moved this from Fix as soon as possible to Done May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants