Happens with both Visual and Aztec editors.
Steps to reproduce:
FATAL EXCEPTION: main
Process: org.wordpress.android, PID: 20465
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.wordpress.android/org.wordpress.android.ui.posts.EditPostActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.wordpress.android.fluxc.model.PostModel.getPostFormat()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.wordpress.android.fluxc.model.PostModel.getPostFormat()' on a null object reference
at org.wordpress.android.ui.posts.EditPostSettingsFragment.fetchSiteSettingsAndUpdateDefaultPostFormatIfNecessary(EditPostSettingsFragment.java:168)
at org.wordpress.android.ui.posts.EditPostSettingsFragment.onActivityCreated(EditPostSettingsFragment.java:154)
at android.app.Fragment.performActivityCreated(Fragment.java:2361)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1014)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1153)
at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2039)
at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:176)
at android.app.Activity.performCreateCommon(Activity.java:6658)
at android.app.Activity.performCreate(Activity.java:6666)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
Duplicate of #6731 - I'm closing #6731, there are more details here.
I can't seem to be able to replicate this 馃槙 . Tried with Samsung Galaxy S3 (Android 4.2.2) and Google Pixel (Android 8.0), Visual, Aztec editors, branches release/8.5 and develop. Posts with and without text, images, etc.
Can you provide more specific conditions to test, @khaykov ? Thanks in advance
Thank's for trying, @mzorz ! I can confirm that it's indeed a bit tricky to reproduce this issue :)
After a couple of tries I came up with steps that work for me every time:
I'm afraid it still doesn't work for me on the Google Pixel 馃槙
Could you offer all sorts of specifics, like Android version, a copy of the Post body that fails, and so on? Is this with the develop branch?
Would you like to try and maybe put a PR together on your end? Don't want to ask for too much but unless I can repro, I feel I can't help too much 馃槙
No problems, @mzorz ! I'll give it a shot - I suspect what the problem is, so probably would be easier to fix it then to look for why it's not reproducible.
So looks like it's a race condition of a sort. That's why it hasn't worked for you, @mzorz.
When you navigate to a post list, fresh posts are fetched, old posts are deleted and ID of all posts are incremented.
How it's causing this crash - you navigate to a post list, _immediately_ tap on a post, adapter opens the editor and sends local id of a post to it. In the meantime, the fetch action is finished in the background, all the posts are deleted and their ID changed. You still have a correct post in Editor, but its ID is out of date. Activity is destroyed and recreated. It's trying to get a post from PostStore using the original ID we sent to it but fails because it's no longer valid.
Thank's to @hypest for pinpointing the exact location of a problem.
Maybe @aforcier would be able give some more insight into this problem.
Awesome! 馃檱 thanks @khaykov and @hypest for taking the time to nail the root cause for this one
Closing via #6830