-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Preview Out-Of-Date if Save is In Progress #13361
Comments
When investigating this, we should keep in mind that there is another bug that sometimes causes the preview to not actually open: #12570. |
Added the "Priority High" lavel since this essentially means the Preview flow is broken since one cannot preview the changes currently in the editor. Please dive in @mchowning , thanks! |
I looked into this issue. I added bunch of logs and I think the bug might be in Gutenberg. When the bug happens, the editor doesn't emit change mEditorFragment.getTitleOrContentChanged() Moreover, this method keeps returning the state before the last change (even 5 seconds after the change) -> so even if the EditPostActivity manually tries to sync the content with the UI, it doesn't help, because the EditorFragment keeps returning the old content. Here are logs when the preview works as expected: (I changed title from "A" to "ABC")
Here are logs when the bug happens: (I changed title from "ABC" to "ABC DEF").
I created a testing branch (issue/13361-logs) which is based on this PR and it just adds these testing logs. |
Removed my assignment because I'm not going to have time to get back to this in the near future. Once the new year starts, I will try to find someone else to continue working on this. |
I don't know if this work is small enough to be worked on during a maintenance rotation, but I have added it to the Groundskeeping Prioritized Android list just in case. |
Possibly related to wordpress-mobile/gutenberg-mobile#2207 |
@malinajirka Unfortuntately, I have failed at getting the app in this state that you describe in your comment so far. I checked out your branch so I could see where you're logging, but on title updates I was only getting correct updates, though I tried extensively the steps from this issue description. The steps in the Issue description say to open a large post on a slow device, I'm wondering if there was some race condition I wasn't achieving using my available devices or on the emulator. Are there are extra steps that you could advise that could be helpful for getting the app in the state you described, with title updates not being sent from Gutenberg to WPAndroid correctly? |
Hi @cameronvoell! I tried to build
P.S. We can jump on a pair programming session if you want. Let me know. |
Thanks @malinajirka, those steps with your longer article worked for reproducing the issue near my end of my day today. will dig in more on the Gutenberg side to look for root cause there. Thanks for your help! |
Hey @cameronvoell 👋 I'm currently on my groundskeeping rotation and I'm wondering if any progress was made on this issue since your last comment or if we're still not sure what the root cause is. |
Hi @renanferrari, I was able to find an arguably worse version of this issue that likely has the same underlying cause as this issue: wordpress-mobile/gutenberg-mobile#3177. It can only be re-created with very large posts, so investigating it likely will involve debugging the autosave handoff between Aztec, Gutenberg, and WPAndroid that should ideally be made immune to performance constraints. |
I tested the following scenarios on a Pixel 4 running Android 11:
|
Following up after #15509, I tested this issue again using the long post content (in the hopes that this may have been resolved via that and the related PRs). Unfortunately, I still encountered the issue (on version |
I re-tested on
|
I have confirmed that this issue is still present (tested on Pixel 3a, Android 12, 86225c2). I created a large post using this example content from this comment, and encountered the issue when modifying the content (or title) and selecting the "Preview" from the menu. I began debugging this issue, and found that there is a very long delay when retrieving the HTML content from the Gutenberg editor (even when there are no changes). In some cases, I seemed to be stuck indefinitely with the "Saving..." dialog presented (I waited greater than 10 minutes on some occasions, and had to kill the app to resume testing 😅 ). I suspect (but was unable to confirm, due to the difficulty and time-consuming nature of debugging such a large post) that when
When this issue was first reported and investigated, this error was not being reported properly, even when a timeout was occurring (since the await method does not throw an exception in that case, but rather, merely returns false). These changes (from #36072) make this more visible in this issue as a potential culprit. I also tried increasing the timeout (to 100s instead of 10, though that may not be a good idea in production), but I would always get stuck with the "Saving..." dialog mentioned earlier. |
Update: I have found steps to reliably reproduce stale previews with even "small" content (i.e. without the save mechanism timing out). StepsThe following was reproduced on a Pixel 3a (physical device) with Android 12.
It seems that subsequent previews still contain the same stale content. Also, even leaving the post and selecting "View" from the post list displays the stale content. At least for this particular flow, this seems to indicate that this is some kind of a caching issue, and not a race condition within the editor. Video: stale-previews.mp4 |
Thanks for looking into this tricky issue! 🙇 Great findings!
@mkevins I assume you didn't publish/update the changes, right? So if you can see "View" action on the post card in the list, and not "Publish" action, that'd suggest the app doesn't even know about the changes. Can you see the modified content ("test test test") when you re-open the post in the editor? From what I can tell it seems the issue still might be that the editor doesn't return up-to-date content when the app asks for it (using .getContent()) -> that's what I found during the last investigation of this issue here. Wdyt? Could you please elaborate a bit why you think this might be a caching issue rather than a race condition? |
Hi @malinajirka 👋 😄 Good questions! I'm actually in the process of writing up more details about what I've discovered so far, but it will take me some time to get it all written out. I'm pretty certain it's an issue with caching, and indeed the modified content is still present in the editor (but not the preview's webview). What is interesting is that viewing the same preview url via a desktop browser displays the up-to-date version of the content. I'll post more details soon on what else I've discovered. |
Also, I still believe there are also potential race conditions, so this could be a symptom with multiple possible causes. 🤷♂️ |
@mkevins made a detailed analysis on this issue in this internal P2 post: pbArwn-3XS-p2 |
Expected behavior
A post preview should always represent the current content in the editor.
Actual behavior
If an autosave is in progress when the user attempts to preview the post, the currently-being-saved changes will not be uploaded and included in the preview.
Steps to reproduce the behavior
Tested on Pixel 1, Android 11, WPAndroid 125b398
The text was updated successfully, but these errors were encountered: