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 in RecyclerView #29634

Closed
SergeyZhukovsky opened this issue Apr 11, 2023 · 5 comments · Fixed by brave/brave-core#18002
Closed

Crash in RecyclerView #29634

SergeyZhukovsky opened this issue Apr 11, 2023 · 5 comments · Fixed by brave/brave-core#18002
Assignees
Labels
crash OS/Android Fixes related to Android browser functionality priority/P2 A bad problem. We might uplift this to the next planned release. QA Pass - Android ARM QA/Yes release-notes/include

Comments

@SergeyZhukovsky
Copy link
Member

SergeyZhukovsky commented Apr 11, 2023

We have that crash stack in a Play Store on a stable 1.50.x. Not sure what RecyclerView causes it, but I have feelings that it's the one on the NTP. That crash is a top 1 crash and accounts to ~22% of crashes we have. I propose to make an attempt of fixing it and see how it performs on nightly and uplift if we are good with the fix. For verifying we just need to make sure we can interact with news, scroll and etc as I don't have steps on how to replicate it.
Edit: there are step on how to verify described in that issue #29860

Exception java.lang.IndexOutOfBoundsException:
  at androidx.recyclerview.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition (RecyclerView.java:6580)
  at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:6763)
  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6724)
  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6720)
  at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2422)
  at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1722)
  at androidx.recyclerview.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1682)
  at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:747)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1 (RecyclerView.java:4586)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayout (RecyclerView.java:4341)
  at androidx.recyclerview.widget.RecyclerView.onLayout (RecyclerView.java:4909)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at org.chromium.chrome.browser.compositor.CompositorViewHolder.onLayout (CompositorViewHolder.java:1350)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild (CoordinatorLayout.java:1251)
  at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild (CoordinatorLayout.java:937)
  at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:957)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at com.android.internal.policy.DecorView.onLayout (DecorView.java:804)
  at android.view.View.layout (View.java:23158)
  at android.view.ViewGroup.layout (ViewGroup.java:6470)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:3597)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:3065)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2068)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:8402)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1058)
  at android.view.Choreographer.doCallbacks (Choreographer.java:880)
  at android.view.Choreographer.doFrame (Choreographer.java:813)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1043)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:236)
  at android.app.ActivityThread.main (ActivityThread.java:7904)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:656)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:967)
@SergeyZhukovsky SergeyZhukovsky added crash priority/P2 A bad problem. We might uplift this to the next planned release. QA/Yes release-notes/include OS/Android Fixes related to Android browser functionality labels Apr 11, 2023
@SergeyZhukovsky SergeyZhukovsky self-assigned this Apr 11, 2023
@SergeyZhukovsky
Copy link
Member Author

SergeyZhukovsky commented Apr 11, 2023

There are reports that it's a bug in a RecyclerView widget or we update and interact with it from different threads https://stackoverflow.com/questions/31759171/recyclerview-and-java-lang-indexoutofboundsexception-inconsistency-detected-in/33822747#33822747.
I tried to check the code to figure out do we really do something from diff threads, but it looks to me that we update it and fetch data from the main UI thread only. I'm going to try to override the LinearLayoutManager and put an assert there so we can easily catch and analyse it in a debug mode in case it happens.

@kjozwiak
Copy link
Member

@brave/qa-team you can find the STR/Cases that @Uni-verse outlined re: the above crash via #29860 (comment):

## Steps to reproduce <!-- Please add a series of steps to reproduce the issue -->

1. Install 1.50.x
2. Complete onboarding, don't set brave as default.
3. Open another tab (keep first tab)
4. Enable news via NTP card on second tab
5. Confirm feed is showing in current tab
6. Enable rewards (US)
7. Allow notifications when dialog presented
8. Skip through rewards tutorial
9. Switch to original tab using tab tray

@brave-builds brave-builds modified the milestones: 1.52.x - Nightly, 1.51.x - Beta, 1.50.x - Release #6 Apr 25, 2023
@kjozwiak
Copy link
Member

The above requires 1.50.127 or higher for 1.50.x verification 👍

@kjozwiak
Copy link
Member

kjozwiak commented May 1, 2023

Moving this into 1.51.x as it looks like we're not going to get another 1.50.x release. The above can basically be checked with https://github.com/brave/brave-browser/releases/tag/v1.51.107 or higher as the above landed into 1.51.x ~week ago.

@kjozwiak kjozwiak modified the milestones: 1.50.x - Release #6, 1.51.x - Release May 1, 2023
@kjozwiak
Copy link
Member

kjozwiak commented May 1, 2023

Verification PASSED on Pixel 6 running Android 14 using the following build(s):

Brave | 1.51.107 Chromium: 113.0.5672.63 (Official Build) (32-bit)
--- | ---
Revision | 0e1a4471d5ae5bf128b1bd8f4d627c8cbd55f70c-refs/branch-heads/5672@{#912}
OS | Android 13; Build/UPB1.230309.014; 33; UpsideDownCake

Went through the STR/Cases outlined via #29634 (comment) several times and verified that Brave doesn't crash when switching back to the original NTP that was opened when Brave was first launched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash OS/Android Fixes related to Android browser functionality priority/P2 A bad problem. We might uplift this to the next planned release. QA Pass - Android ARM QA/Yes release-notes/include
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants