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

java.lang.IndexOutOfBoundsException: Index: 6, Size: 0 #110

Closed
AnthonyKoueik opened this issue Jan 15, 2020 · 21 comments
Closed

java.lang.IndexOutOfBoundsException: Index: 6, Size: 0 #110

AnthonyKoueik opened this issue Jan 15, 2020 · 21 comments

Comments

@AnthonyKoueik
Copy link

AnthonyKoueik commented Jan 15, 2020

1.6.3

huawei p20 lite - OS Version: 9

when launching activity

<eightbitlab.com.blurview.BlurView
android:id="@+id/bottom_nav_bar_blurView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:blurOverlayColor="@color/colorTransparentWhite9">
 Process: com.dollargeneral.qa2.android, PID: 7780
    java.lang.IndexOutOfBoundsException: Index: 6, Size: 0
        at java.util.ArrayList.get(ArrayList.java:437)
        at android.view.ViewGroup.getAndVerifyPreorderedView(ViewGroup.java:3635)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4168)
        at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
        at android.view.View.draw(View.java:20486)
        at android.view.View.draw(View.java:20353)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4394)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4170)
        at android.view.View.draw(View.java:20486)
        at eightbitlab.com.blurview.BlockingBlurController.updateBlur(BlockingBlurController.java:150)
        at eightbitlab.com.blurview.BlockingBlurController.draw(BlockingBlurController.java:230)
        at eightbitlab.com.blurview.BlurView.draw(BlurView.java:51)
        at android.view.View.draw(View.java:20353)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4394)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4170)
        at android.view.View.draw(View.java:20351)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4394)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4170)
        at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
        at android.view.View.draw(View.java:20486)
        at android.view.View.draw(View.java:20353)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4394)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4170)
        at android.view.View.draw(View.java:20486)
        at eightbitlab.com.blurview.BlockingBlurController.updateBlur(BlockingBlurController.java:150)
        at eightbitlab.com.blurview.BlockingBlurController.draw(BlockingBlurController.java:230)
        at eightbitlab.com.blurview.BlurView.draw(BlurView.java:51)
        at android.view.View.updateDisplayListIfDirty(View.java:19294)
        at android.view.View.draw(View.java:20211)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4394)
        at android.view.ViewG
@Dimezis
Copy link
Owner

Dimezis commented Jan 15, 2020

Can you post the full layout hierarchy?

@yawarkhan224
Copy link

yawarkhan224 commented Jan 24, 2020

@Dimezis
I am having the same issue. For me this is the error:

java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
        at java.util.ArrayList.get(ArrayList.java:437)
        at android.view.ViewGroup.getAndVerifyPreorderedView(ViewGroup.java:3809)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4323)
        at android.view.View.draw(View.java:21863)
        at eightbitlab.com.blurview.BlockingBlurController.updateBlur(BlockingBlurController.java:146)
        at eightbitlab.com.blurview.BlockingBlurController.draw(BlockingBlurController.java:226)
        at eightbitlab.com.blurview.BlurView.draw(BlurView.java:51)
        at android.view.View.updateDisplayListIfDirty(View.java:20733)
        at android.view.View.draw(View.java:21586)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4551)
        at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1246)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4326)
        at android.view.View.updateDisplayListIfDirty(View.java:20719)
        at android.view.View.draw(View.java:21586)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4551)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4326)
        at android.view.View.updateDisplayListIfDirty(View.java:20719)
        at android.view.View.draw(View.java:21586)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4551)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4326)
        at android.view.View.updateDisplayListIfDirty(View.java:20719)
        at android.view.View.draw(View.java:21586)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4551)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4326)
        at android.view.View.updateDisplayListIfDirty(View.java:20719)
        at android.view.View.draw(View.java:21586)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4551)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4326)
        at android.view.View.updateDisplayListIfDirty(View.java:20719)
        at android.view.View.draw(View.java:21586)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4551)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4326)
        at android.view.View.draw(View.java:21863)
        at com.android.internal.policy.DecorView.draw(DecorView.java:1083)
        at android.view.View.updateDisplayListIfDirty(View.java:20733)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:725)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:731)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:840)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:3932)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3706)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3014)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1873)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8478)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
        at android.view.Choreographer.doCallbacks(Choreographer.java:761)
        at android.view.Choreographer.doFrame(Choreographer.java:696)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:6986)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

Layout looks like:

<eightbitlab.com.blurview.BlurView
        android:id="@+id/orderBlurView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        android:focusable="true"
        android:visibility="gone"
        tools:visibility="visible"
        app:blurOverlayColor="@color/order_state_blur"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/orderLoadingTextView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                android:fontFamily="sans-serif-medium"
                android:textAlignment="center"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                app:layout_constraintBottom_toTopOf="@+id/orderLoadingProgressBar"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_chainStyle="packed"
                tools:text="Starting order process&#8230;" />

            <ProgressBar
                android:id="@+id/orderLoadingProgressBar"
                style="?android:attr/progressBarStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="4dp"
                android:background="@color/order_state_blur"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/orderLoadingTextView" />

            <androidx.constraintlayout.widget.Group
                android:id="@+id/orderLoadingGroup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:constraint_referenced_ids="orderLoadingTextView,orderLoadingProgressBar" />

            <Button
                android:id="@+id/orderAdjustButton"
                style="@style/Widget.AppCompat.Button.Colored"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                android:drawablePadding="8dp"
                android:drawableStart="@drawable/ic_close_white_24dp"
                android:text="@string/adjust_order"
                android:theme="@style/AdjustButtonTheme"
                android:visibility="gone"
                app:layout_constrainedWidth="true"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/orderLoadingProgressBar"
                app:layout_constraintVertical_bias="1.0" />

            <Button
                android:id="@+id/orderPaymentSuccessfulButton"
                style="@style/Widget.AppCompat.Button.Colored"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                android:drawablePadding="8dp"
                android:drawableStart="@drawable/ic_check_white_24dp"
                android:text="@string/order_confirmed"
                android:theme="@style/PaymentSuccessfulButtonTheme"
                android:visibility="gone"
                app:layout_constrainedWidth="true"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/orderLoadingProgressBar"
                app:layout_constraintVertical_bias="1.0" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </eightbitlab.com.blurview.BlurView>

This code is working for version 1.6.1 but for 1.6.2 and 1.6.3 it is crashing.

Setup is done like this:

// setup the blur view
        orderBlurView.setupWith(coordinatorLayout)
            .setFrameClearDrawable(window.decorView.background)
            .setBlurAlgorithm(RenderScriptBlur(this))
            .setBlurRadius(10f)
            .setHasFixedTransformationMatrix(true)

and upon visibility toggle, app is crashing with IndexOutOfBoundsException.

@Dimezis
Copy link
Owner

Dimezis commented Feb 2, 2020

Couldn't reproduce it with the given setup. The full layout and android version would help

@Beeen
Copy link

Beeen commented Feb 19, 2020

Hi guys,

I have the same issue, but It only appears to be occuring on a small number of my users.

One user that had the problem : Android 7 & Galaxy A5(2016)

Here is the full layout of my fragment which appears on top of an activity

`
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<eightbitlab.com.blurview.BlurView
    android:id="@+id/blurView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_black_transparent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/tv_explanation"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="@string/question_overlay_pending_request_explanation"
            android:textAlignment="center"
            android:textColor="@color/white"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="@id/explanationGuidelineRight"
            app:layout_constraintStart_toStartOf="@id/explanationGuidelineLeft"
            app:layout_constraintTop_toBottomOf="@+id/tv_title" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/explanationGuidelineLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.1" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/explanationGuidelineRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.9" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/pictureGuidelineLeft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.3" />

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/question_overlay_pending_request_title"
            android:textColor="@color/white"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/iv_profile_pic"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="@drawable/item_transparent_background_shape_with_white_border_rounded"
            app:layout_constraintBottom_toTopOf="@+id/tv_title"
            app:layout_constraintDimensionRatio="1"
            app:layout_constraintEnd_toEndOf="@id/pictureGuidelineRight"
            app:layout_constraintStart_toStartOf="@+id/pictureGuidelineLeft"
            app:layout_constraintTop_toTopOf="parent" />

        <androidx.constraintlayout.widget.Guideline
            android:id="@+id/pictureGuidelineRight"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.7" />

        <ProgressBar
            android:id="@+id/progress_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.WhiteAccent"
            app:layout_constraintBottom_toBottomOf="@+id/iv_profile_pic"
            app:layout_constraintEnd_toStartOf="@+id/pictureGuidelineRight"
            app:layout_constraintRight_toRightOf="@id/iv_profile_pic"
            app:layout_constraintStart_toStartOf="@+id/pictureGuidelineLeft"
            app:layout_constraintTop_toTopOf="@+id/iv_profile_pic" />
    </androidx.constraintlayout.widget.ConstraintLayout>

</eightbitlab.com.blurview.BlurView>

</androidx.constraintlayout.widget.ConstraintLayout>
`

The setup :
`
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
containerViewGroup = container;
view = inflater.inflate(R.layout.question_overlay_pending_request, container, false);

    View decorView = getActivity().getWindow().getDecorView();
    //ViewGroup you want to start blur from. Choose root as close to BlurView in hierarchy as possible.
    ViewGroup rootView = (ViewGroup) decorView.findViewById(android.R.id.content);

    BlurView blurView = (BlurView) view.findViewById(R.id.blurView);
    blurView.setupWith(rootView)
            .setFrameClearDrawable(containerViewGroup.getBackground())
            .setBlurAlgorithm(new RenderScriptBlur(containerViewGroup.getContext()))
            .setOverlayColor(R.color.black)
            .setBlurRadius(1);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
        blurView.setOutlineProvider(ViewOutlineProvider.BACKGROUND);
        blurView.setClipToOutline(true);
    }

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            animateTitle();
        }
    }, 100);

    return view;

}
`

And here the backtrace of the error :
`
Fatal Exception: java.lang.IndexOutOfBoundsException
Index: 4, Size: 0

java.util.ArrayList.get (ArrayList.java:411)
android.view.ViewGroup.getAndVerifyPreorderedView (ViewGroup.java:3291)
android.view.ViewGroup.dispatchDraw (ViewGroup.java:3753)
androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw (ConstraintLayout.java:2023)
android.view.View.draw (View.java:18397)
android.view.View.draw (View.java:18298)
android.view.ViewGroup.drawChild (ViewGroup.java:3969)
android.view.ViewGroup.dispatchDraw (ViewGroup.java:3755)
android.view.View.draw (View.java:18397)
eightbitlab.com.blurview.BlockingBlurController.updateBlur (BlockingBlurController.java:149)
eightbitlab.com.blurview.BlockingBlurController$1.onPreDraw (BlockingBlurController.java:61)
android.view.ViewTreeObserver.dispatchOnPreDraw (ViewTreeObserver.java:1013)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2555)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1550)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7190)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:959)
android.view.Choreographer.doCallbacks (Choreographer.java:734)
android.view.Choreographer.doFrame (Choreographer.java:670)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:945)
android.os.Handler.handleCallback (Handler.java:751)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6776)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1496)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1386)`

I'd like to mention that I use Glide and Glide complier (4.10.0) and I make requests using ".disallowHardwareConfig()" which helped with this bug but there's still some happening

Thanks for your help !

@Vnicius
Copy link

Vnicius commented Mar 10, 2020

I'm having the same issue with some users. And I couldn't reproduce yet.
But is when I'm animating the BlurView.

@witalobenicio
Copy link

witalobenicio commented Jul 10, 2020

This is also happening in @react-native-community/blur if we try to render two BlurView in screen.

@Dimezis
Copy link
Owner

Dimezis commented Jul 12, 2020

You can report it to the ConstraintLayout issue tracker in this case

@Thecrazyskull
Copy link

@Dimezis this is not necessarily related to ConstraintLayout. I can reproduce this without ConstraintLayout as well.

@Dimezis
Copy link
Owner

Dimezis commented Sep 4, 2020

@Thecrazyskull If you can reproduce it, then please make a repo with a setup that I can run and test

@invyctus92
Copy link

Updates ?

@Dimezis
Copy link
Owner

Dimezis commented Jan 21, 2021

@invyctus92
Until someone posts a reliable way of reproducing this issue, I can't help

@invyctus92
Copy link

I use @react-native-community/blur which relies on BlurView to do the blur on Android. At Kureev/react-native-blur#396 you can find some react native examples that suffer from the problem.

@Dimezis
Copy link
Owner

Dimezis commented Jan 21, 2021

@invyctus92
I appreciate that, but I have zero experience with react native and have no idea how to even approach the debugging in such case.
So I definitely won't be tinkering with that react native code sample

@sapkotamadhusudan
Copy link

@Dimezis I'm having the same issue in my react native app with @react-native-community/blur. i've done some test with different implementation and able to reproduce the issue. You can find the sample here

@Dimezis
Copy link
Owner

Dimezis commented Feb 26, 2021

@sapkotamadhusudan good job!
Already on it

@Dimezis
Copy link
Owner

Dimezis commented Feb 26, 2021

Made a fix, gonna release it today-tomorrow

@sapkotamadhusudan
Copy link

@Dimezis great :) thanks for the support

@Dimezis
Copy link
Owner

Dimezis commented Feb 26, 2021

1.6.6 is out and this should be resolved

Lemon-King added a commit to Lemon-King/react-native-blur that referenced this issue Mar 8, 2021
@Dimezis
Copy link
Owner

Dimezis commented Sep 26, 2021

react-native-blur v3.6.1 uses 1.6.6 of blurView but the problem still exists!
any thoughts 💭 ?
@Dimezis

No thoughts. You can send me a repo with a setup to reproduce the problem and I will take a look. Native android project, no react.

@AmrAbdalkader
Copy link

@Dimezis Could you describe to me what was the issue and how did you solve it ?

@Dimezis
Copy link
Owner

Dimezis commented Jun 18, 2022

1b371bf#diff-d12d186ad42254cba0b899bb19513497132d71172c16f8c491eef7be304acc9c

The problem was that several BlurViews formed a drawing loop sometimes, each triggering a blur update of another BlurView.
I added a safe check based on the Canvas type used for drawing, so the drawing can be skipped when BlurView detects it's requested to be drawn on BlurView's Canvas

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

No branches or pull requests

10 participants