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

Crash on FrameLayout layoutChildren #23

Open
oiramcro opened this issue Sep 30, 2016 · 11 comments
Open

Crash on FrameLayout layoutChildren #23

oiramcro opened this issue Sep 30, 2016 · 11 comments
Labels

Comments

@oiramcro
Copy link

Recently I wrapped my RecyclerView with FrameLayout so I can use StickyHeaders. Since then from time to time I notice this strange crash. I extracted the log from Fabric. I can't reproduce it but I it could it's related to onNotifyDataSetChanged when data goes from N to 0 items and list was scrolled to the half height.

<android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/refreshView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/resultDateView">

            <FrameLayout
                android:layout_width="wrap_content"
                android:id="@+id/stickyHolder"
                android:layout_height="wrap_content">

                <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/live_rw_liveMatchList"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scrollbars="vertical" />

            </FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Fatal Exception: java.lang.NullPointerException
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:405)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
       at android.view.View.layout(View.java:15749)
       at android.view.ViewGroup.layout(ViewGroup.java:4880)
       at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:596)
       at android.view.View.layout(View.java:15749)
       at android.view.ViewGroup.layout(ViewGroup.java:4880)

Do you know what is going on here ?

@bgogetap
Copy link
Owner

What line of code is being run at FrameLayout:line#405? (Not matching with the source I have, so just curious).

@oiramcro
Copy link
Author

oiramcro commented Oct 1, 2016

I guess FrameLayout code is different depending on which android version that user has ?

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference at android.widget.FrameLayout.layoutChildren(FrameLayout.java:591) at android.widget.FrameLayout.onLayout(FrameLayout.java:574) at android.view.View.layout(View.java:16001) at android.view.ViewGroup.layout(ViewGroup.java:5181) at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:596)

You can see on this screenshot that it's kind of specific for every android version:
https://www.dropbox.com/s/vw8kcv5u1kh48qy/Screen%20Shot%202016-10-01%20at%2008.59.09.png?dl=1

This started to happen once I wrapped my recycler view with framelayout, but I can't reproduce it.

@bgogetap
Copy link
Owner

bgogetap commented Oct 1, 2016

Ok, I was able to reproduce it. Basically if the currently attached sticky header is removed from the dataset, this happens. Looking into a fix.

@bgogetap bgogetap added the bug label Oct 1, 2016
@bgogetap
Copy link
Owner

bgogetap commented Oct 1, 2016

Fixed in 53e0449 (Version 0.3.4)

I would advise a reasonably thorough testing before pushing this out into an update, but this issue should be resolved. I think there is room for improvement in the way I'm holding onto header state, but this was a pretty big flaw so I wanted to get a preliminary fix out ASAP.

Thanks for reporting the issue!

@utkarshGithub
Copy link

issue still there

@disparate
Copy link

Issue can still be reproduced on v0.4.9

@disparate
Copy link

As a temporary hack you can use your own HackyFrameLayout class and catch NullPointerException inside the onLayout method.

@bgogetap
Copy link
Owner

bgogetap commented Dec 5, 2017

Is there a reproducible set of actions I can try to recreate this issue or are you just seeing it in logs?

@bgogetap bgogetap reopened this Dec 5, 2017
@disparate
Copy link

@bgogetap
Sorry, haven't seen your reply.
I was able to reproduce the issue always following this steps.

  1. Scroll recycler so the sticky header view is fixed at the top of the view.
  2. Change data for adapter (with following notifyDataSetChanged call() )

@mitcho85
Copy link

Is there any update on this bug? @bgogetap thanks!

@bgogetap
Copy link
Owner

bgogetap commented Jun 4, 2019

No update. I'd be happy to look into it if there is a repro I can examine, but it's not something I can blindly dig into right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants