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

NullPointerException: Attempt to invoke virtual method 'boolean org.wordpress.android.ui.FilteredRecyclerView.isRefresh... #11992

Closed
oguzkocer opened this issue May 22, 2020 · 8 comments

Comments

@oguzkocer
Copy link
Contributor

The line that's failing has been last updated 2 years ago, but this issue started happening in the latest alpha/beta. (and it's the top crash for it)

Sentry Url: https://sentry.io/share/issue/518b348ef95844eca7ccc17717cfde3a/
User Count: 17
Count: 27
First Release: org.wordpress.android-14.9-rc-1
First Seen: 2020-05-20T00:49:43Z
Last Seen: 2020-05-22T00:56:06Z
24 Hours: 14
30 Days: 27

NullPointerException: Attempt to invoke virtual method 'boolean org.wordpress.android.ui.FilteredRecyclerView.isRefreshing()' on a null object reference
     at org.wordpress.android.ui.reader.ReaderPostListFragment.onSaveInstanceState(ReaderPostListFragment.java:825)
     at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:2766)
     at androidx.fragment.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManagerImpl.java:2289)
     at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManagerImpl.java:2348)
     at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:151)
     at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:513)
     at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:533)
     at android.app.Activity.performSaveInstanceState(Activity.java:2041)
     at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1507)
     at android.app.ActivityThread.callActivityOnSaveInstanceState(ActivityThread.java:5539)
...
(13 additional frame(s) were not displayed)
@yaelirub
Copy link

Marking high priority as it's a new crash.
@ashiagr , can you please take a look at this?

@designsimply
Copy link
Contributor

I ran into this crash while testing #12001, and there are steps, a video, and app logs on the issue.

(also see internal reference: p5T066-1jy-p2#comment-5006)

@ashiagr
Copy link
Contributor

ashiagr commented May 25, 2020

This crash seems to have started occurring after this fix: #11927 was added in 14.9-rc-1.
(cc @malinajirka)

When toggling from Reader tab to My site tab, ReaderPostListFragment is detached but its state is still managed by the fragment manager according to FragmentTransaction detach (Fragment fragment) def. Its view hierarchy is destroyed though.

Detach the given fragment from the UI. This is the same state as when it is put on the back stack: the fragment is removed from the UI, however its state is still being actively managed by the fragment manager. When going into this state its view hierarchy is destroyed.

It is unsafe to access any of the view elements in the onSaveInstanceState of the detached fragment as was already accessed here before above fix was introduced.

I was able to reproduce this crash as follows:

  1. Enable "Don't keep activities" under Device Settings -> Systems -> Advanced -> Developer options -> Apps section
  2. Open WordPress Android app and toggle from Reader tab to My site tab.
    This triggers Reader tab fragment's detach.
  3. Click Blog Posts on My site tab and return from it.
    This triggers My site tab fragment's attach.
  4. Click Blog Posts again or Site Pages on My site tab -> 💥.
    This triggers Reader tab fragment's onSaveStateInstance and if the detached fragment's view is garbage collected by this time, the view elements will be null.

(Don't forget to disable "Don't keep activities" in step 1 after testing)

Fix could be to add a null check for the view element mRecyclerView on this line.


Note:

I ran into this crash while testing #12001, and there are steps, a video, and app logs on the issue.

Above crash is due to this sentry issue and should be investigated separately.

@malinajirka
Copy link
Contributor

Awesome investigation @ashiagr!!! 🙇 Thanks

I'll create a PR with a fix.

@malinajirka
Copy link
Contributor

malinajirka commented May 25, 2020

I think this bug is related to this discussion (change in appcompat 1.1.0) #11292 (review)


This triggers Reader tab fragment's onSaveStateInstance and if the detached fragment's view is garbage collected by this time, the view elements will be null.

I believe the view isn't garbage collected. The issue is that "onCreateView" was never invoked for the fragment on a backstack. However, it doesn't change anything.

@oguzkocer
Copy link
Contributor Author

@ashiagr Friendly reminder to use the public urls for the Sentry crashes so it'd work for everyone. Re: #11992 (comment)

@oguzkocer
Copy link
Contributor Author

@malinajirka Since this is a new crash, assuming the fix is simple enough, I think you can target release/14.9 for it.

@bummytime
Copy link
Member

Fixed in #12018 (targeting v14.9).

Apochens added a commit to Apochens/WordPress-Android that referenced this issue Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants