Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.48k stars 331 forks source link

java.lang.IllegalStateException: Underflow in restore - more restores than saves #184

Open Usman-Click opened 2 years ago

Usman-Click commented 2 years ago

Hi,

pls i get this error when i tried to scroll blurView inside a scroll view

this is what i get from logcat E/AndroidRuntime: FATAL EXCEPTION: main Process: com.clickinc.toplayer, PID: 16537 java.lang.IllegalStateException: Underflow in restore - more restores than saves at android.graphics.Canvas.restore(Canvas.java:679) at eightbitlab.com.blurview.PreDrawBlurController.updateBlur(PreDrawBlurController.java:116) at eightbitlab.com.blurview.PreDrawBlurController$1.onPreDraw(PreDrawBlurController.java:50) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1124) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3854) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2618) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9971) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010) at android.view.Choreographer.doCallbacks(Choreographer.java:809) at android.view.Choreographer.doFrame(Choreographer.java:744) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:246) at android.app.ActivityThread.main(ActivityThread.java:8550) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

thanks

Dimezis commented 2 years ago

Please attach a sample project or code with your XML layout

Usman-Click commented 2 years ago

Okay Where should I send it ? Or should I paste it here ?

Dimezis commented 2 years ago

Post a link to the repository or paste a relevant code here. Repository is preferable

Usman-Click commented 1 year ago
<androidx.constraintlayout.motion.widget.MotionLayout 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="wrap_content"
    app:layoutDescription="@xml/activity_music_player_scene"
    tools:context=".musicplayer.MusicPlayerActivity">

    <RelativeLayout
        android:id="@+id/music_player_parent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        //// imageView to be blured

            <ImageView
                android:id="@+id/musicThumbnailBg"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/pri_color_variant"
                android:scaleType="centerCrop" />

     //// BlurView

        <eightbitlab.com.blurview.BlurView
            android:id="@+id/blurLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#80000000" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

       <Unrelated-date>..........</Unrelated-data>

    </RelativeLayout>

      </eightbitlab.com.blurview.BlurView>

</androidx.constraintlayout.motion.widget.MotionLayout>

Is it because of MotionLayout ???

Dimezis commented 1 year ago

Could you please check if this PR fixes your problem?