Sentry Issue: WORDPRESS-ANDROID-123K
NullPointerException: Attempt to invoke interface method 'boolean org.wordpress.android.fluxc.model.PostImmutableModel.isPage()' on a null object reference
at org.wordpress.android.ui.posts.PostEditorAnalyticsSession.<init>(PostEditorAnalyticsSession.java:65)
at org.wordpress.android.ui.posts.PostEditorAnalyticsSession.getNewPostEditorAnalyticsSession(PostEditorAnalyticsSession.java:95)
at org.wordpress.android.ui.posts.PostEditorAnalyticsSessionWrapper.getNewPostEditorAnalyticsSession(PostEditorAnalyticsSessionWrapper.kt:13)
at org.wordpress.android.ui.stories.StoryComposerViewModel.createPostEditorAnalyticsSessionTracker(StoryComposerViewModel.kt:107)
at org.wordpress.android.ui.stories.StoryComposerViewModel.setupPostEditorAnalyticsSession(StoryComposerViewModel.kt:96)
...
(16 additional frame(s) were not displayed)
RuntimeException: Unable to start activity ComponentInfo{org.wordpress.android/org.wordpress.android.ui.stories.StoryComposerActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean org.wordpress.android.fluxc.model.PostImmutableModel.isPage()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2994)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3072)
at android.app.ActivityThread.-wrap11
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1766)
at android.os.Handler.dispatchMessage(Handler.java:106)
...
(5 additional frame(s) were not displayed)
Sentry issue: WORDPRESS-ANDROID-122Q
This null pointer exception issue is caused due to the fact that the PostEditorAnalyticsSession class was implemented without considering the fact that the PostImmutableModel can be passed to it as null.
By adding the @Nullable annotation during construction (see PostEditorAnalyticsSession, line 62) the warning becomes more evident. However, the fix is not that trivial and would require some more thinking since the PostEditorAnalyticsSession depends too much on the post instance (isPage, content, id).
Thus, probably it make sense to make this a @NonNull explicitly and have the clients skip it (StoryComposerActivity, EditPostActivity).
@mzorz your thoughts?
@ParaskP7 your notes are wonderful! I have a small question about labels 馃Ч should this one be labeled WP Stories or Analytics?
@designsimply you are too kind! 馃槉
Why not label them with both, will that create a confusion?
It seems the Analytics problem is occurring on WP Stories and not EditPost activity, which might suggest it is better fit for WP Stories. But, since this analytics class is being utilised by both the Story and EditPost activities, maybe Analytics is better and more generic. Fixing the Analytics problem with improve both activities. Wdyt?
PS: I wasn't aware I should add more labels to an issue while being a CTOW. Good to know for next time, many thanks! 馃檹
Both sounds good! Done! It's an art more than a science sometimes 馃榿 but I am working now to organize the labels better so I can do some analysis on the repo later. 馃憤
Perfect, thanks for the update! Can't wait for the labels to be organized further by you Sheri! 馃専
Thanks for digging into this @ParaskP7 !
However, the fix is not that trivial and would require some more thinking since the PostEditorAnalyticsSession depends too much on the post instance (isPage, content, id).
Yes I think we need to come up with the root cause of it. Marking it @NonNull is a good improvement but it only goes as far as making the crash happen slightly before.
I think what's going on here is StoryComposerActivity gets passed a Post id that is different from zero, but either such a Post does not exist in the database or can't be retrieved somehow. An hypothesis I'm trying to follow is to see if the Post gets deleted or discarded somehow before trying to edit it (from the logs, I can see they seem to have tapped on an item in the Posts list, and then either added a Story block themselves or edited an existing Story in that post).
Will get back here if I find anything substantial 馃憤
oh, I missed this part:
... and have the clients skip it (StoryComposerActivity, EditPostActivity).
This could be enough for now @ParaskP7 given it's just analytics and not many occurrences it may be ok to just skip it if conditions to keep the analytics session object are not met 馃憤
Thanks for the detailed response @mzorz ! 馃
This could be enough for now @ParaskP7 given it's just analytics and not many occurrences it may be ok to just skip it if conditions to keep the analytics session object are not met 馃憤
I too agree with that. 馃憤
Hi @ParaskP7 ! I ended up doing something different, given I wanted to get to the root cause of it - when thinking again about this part:
given it's just analytics and not many occurrences it may be ok to just skip it if conditions to keep the analytics session object are not met
Actually, if we don't have a Post we not only can't have analytics for the Post but also we won't be able to do anything else at at that point 馃槵 馃槄 so that's why I decided to go a different route than just skipping analytics, which would have meant kicking the problem for later on only. Let me know what you think https://github.com/wordpress-mobile/WordPress-Android/pull/13753 馃憤
馃憢 @mzorz !
Great, I'll take a look at that later today, thanks for opening the PR! 馃専
馃檹
Most helpful comment
馃憢 @mzorz !
Great, I'll take a look at that later today, thanks for opening the PR! 馃専
馃檹