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

IllegalStateException in RecyclerView: Two different ViewHolders have the same stable ID #8659

Closed
loremattei opened this issue Nov 26, 2018 · 4 comments

Comments

@loremattei
Copy link
Contributor

loremattei commented Nov 26, 2018

Fatal Exception: java.lang.IllegalStateException: Two different ViewHolders have the same stable ID. Stable IDs in your adapter MUST BE unique and SHOULD NOT change.
 ViewHolder 1:ViewHolder{425cbd80 position=20 id=72545603, oldPos=-1, pLpos:-1 not recyclable(1)} 
 View Holder 2:ViewHolder{426f6090 position=19 id=72545603, oldPos=-1, pLpos:-1} android.support.v7.widget.RecyclerView{43187c58 VFED.V.. ......ID 0,0-480,606 #7f090420 app:id/recycler_view}, adapter:org.wordpress.android.ui.reader.adapters.ReaderSiteSearchAdapter@43090348, layout:android.support.v7.widget.LinearLayoutManager@43149848, context:org.wordpress.android.ui.main.WPMainActivity@41d736f0
       at android.support.v7.widget.RecyclerView.handleMissingPreInfoForChangeError(RecyclerView.java:3946)
       at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3870)
       at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3540)
       at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4082)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:606)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:132)
       at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
       at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1361)
       at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:894)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
       at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
       at com.android.internal.policy.DecorView.onLayout(DecorView.java:764)
       at android.view.View.layout(View.java:19685)
       at android.view.ViewGroup.layout(ViewGroup.java:6077)
       at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2538)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2254)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1434)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6868)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1026)
       at android.view.Choreographer.doCallbacks(Choreographer.java:838)
       at android.view.Choreographer.doFrame(Choreographer.java:769)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1012)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:171)
       at android.app.ActivityThread.main(ActivityThread.java:6635)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

5ae0fd9b638393737a3c3ea5-fabric

@rachelmcr
Copy link
Member

Adding a high priority label as this is one of our most frequent crashes.

@hypest
Copy link
Contributor

hypest commented Jan 7, 2019

Updated the description to include some more specific info from the crash.

@hypest hypest self-assigned this Jan 7, 2019
@hypest
Copy link
Contributor

hypest commented Jan 8, 2019

I think I found a condition that can probably lead to the crash:

  1. Go to the Reader
  2. Have "Followed Sites" as the selected Reader section
  3. Tap on the search on the right (the magnifier glass icon)
  4. Type a query, for example: test
  5. Select the "Sites" tab from the results
  6. Scroll to the end of the list to trigger infinite scroll. Notice the last item while the new search is ongoing.
  7. Scroll a couple of items down and notice that the last item of the first "page" is repeated, effectively having the same item/site twice on the list

This means that there are two items with the same feed id so, the getItemId() implementation here will produce the same id for two different list positions. That's a problematic situation and most probably can lead to the crash at hand, even though the occurrence of it depends on more conditions too.

Will produce a PR to fix the duplicate list item.

@mzorz
Copy link
Contributor

mzorz commented Jan 8, 2019

nice find here!

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

4 participants