A post preview should always represent the current content in the editor.
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.

When investigating this, we should keep in mind that there is another bug that sometimes causes the preview to not actually open: https://github.com/wordpress-mobile/WordPress-Android/issues/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")
14:22:22.675 - D/WordPress-MAIN: malinjir: change in editor detected.
14:22:38.308 - D/WordPress-MAIN: malinjir: updating from editor: ABC
14:22:38.320 - D/WordPress-MAIN: malinjir: Right before the post is saved into db: ABC
14:22:40.716 - D/WordPress-MAIN: malinjir: updating from editor: ABC
14:22:40.727 - D/WordPress-MAIN: malinjir: Right before the post is saved into db: ABC
14:22:40.754 - D/WordPress-MAIN: malinjir: unpacking post intent: ABC
14:22:40.777 - D/WordPress-MAIN: malinjir: upload handler: ABC
14:22:47.885 - D/WordPress-MAIN: malinjir: postuploaded: ABC
14:22:47.886 - D/WordPress-MAIN: malinjir: postuploaded - repo: ABC
Here are logs when the bug happens: (I changed title from "ABC" to "ABC DEF").
14:24:38.106 D/WordPress-MAIN: malinjir: updating from editor: ABC
14:24:43.829 D/WordPress-MAIN: malinjir: updating from editor: ABC
14:24:43.839 D/WordPress-MAIN: malinjir: Right before the post is saved into db: ABC
14:24:43.867 D/WordPress-MAIN: malinjir: unpacking post intent: ABC
14:24:43.888 D/WordPress-MAIN: malinjir: upload handler: ABC
14:24:49.344 D/WordPress-MAIN: malinjir: postuploaded: ABC
14:24:49.345 D/WordPress-MAIN: malinjir: postuploaded - repo: ABC
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 https://github.com/wordpress-mobile/gutenberg-mobile/issues/2207
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()
...
I created a testing branch (issue/13361-logs) which is based on this PR and it just adds these testing logs.
@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 issue/13361-logs and the issue still sometimes happens to me - eg. emulator api 30 and this post.
updating from editor: [TITLE] sometime contain the out-dated title (if you see the up-to-date title, repeat steps 2-5)P.S. We can jump on a pair programming session if you want. Let me know.
Hi @cameronvoell! I tried to build
issue/13361-logsand the issue still sometimes happens to me - eg. emulator api 30 and this post....
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.
Most helpful comment
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!