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

Ripple in views near BlurView doesnt render (at least in Android 13) #185

Open
hugomc92 opened this issue Sep 13, 2022 · 3 comments
Open

Comments

@hugomc92
Copy link

Please include:

  1. Library version

2.0.2

  1. Device and OS version

OnePlus 6 Android 13 CherishOS (https://forum.xda-developers.com/t/rom-official-13-0-cherish-os-aosp-oneplus-6-6t-v4-0-4-sept-2022.4485817/)

  1. Detailed steps to reproduce the issue -

If you set a BlurView, every view with ripple near it doesnt show ripple.

Even when activities and aplication is hardware accelerated, at the moment the blurview is shown the ripple near it stop to work.

  1. XML layout and code for BlurView setup
<FrameLayout
    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:id="@+id/rootLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="false">
    
    <eightbitlab.com.blurview.BlurView
        android:id="@+id/titleBlurView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="8dp"
        app:blurOverlayColor="@color/colorOverlay"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:clickable="false">
        
        <TextView
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:text="@string/my_packs"
            android:textSize="18sp"
            android:textStyle="bold"
            android:textColor="@color/colorPrimary"
            android:padding="16dp"
            android:layout_marginTop="24dp"/>
    </eightbitlab.com.blurview.BlurView>
    
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/boughtPacksList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:nestedScrollingEnabled="false"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        android:paddingTop="78dp"
        android:paddingBottom="56dp"
        android:clipToPadding="false"
        android:layoutAnimation="@anim/layout_animation_fall_down"/>
</FrameLayout>

The ripple in the recycler items are set with

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:focusable="true"
    android:foreground="?attr/selectableItemBackgroundBorderless">

   ... 

</androidx.constraintlayout.widget.ConstraintLayout>

I setup the blur as this

BlurUtils.setupBlur(titleBlurView, boughtPacksList, activity)

fun setupBlur(blurView: BlurView?, rootLayout: ViewGroup?, activity: Activity?, blurRadius: Float = 25f) {
  if(blurView != null) {
    blurView.setBlurEnabled(false)
    blurView.setBlurEnabled(true)
    
    val blurAlgorithm: BlurAlgorithm = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) RenderEffectBlur() else RenderScriptBlur(blurView.context)
    
    rootLayout?.let {
    blurView.setupWith(rootLayout, blurAlgorithm)
      ?.setFrameClearDrawable(activity?.window?.decorView?.background)
      ?.setBlurRadius(blurRadius)
      ?.setBlurAutoUpdate(true)
    }
  }
}
  1. Stacktrace in case of a crash

Not a crash really but this log is showed.

The RippleDrawable.STYLE_PATTERNED animation is not supported for a non-hardware accelerated Canvas. Skipping animation.
@hugomc92
Copy link
Author

hugomc92 commented Oct 7, 2022

Any news on this?

@Dimezis
Copy link
Owner

Dimezis commented Oct 7, 2022

@hugomc92
It indeed seems to be the case, but I'm afraid there's nothing reasonable I can do to fix it.

I'm not sure what they changed internally so it stopped working, because they shouldn't stop the ripple on the Render thread and system canvas just because someone requests drawing on a different unrelated software Canvas. They could just skip drawing on that software Canvas only.

The only fix I imagine is to move to a hardware-accelerated Canvas for view snapshotting, but because it forces a quite different rendering approach, I couldn't squeeze a reasonable performance for real-time blur from it.
And I tried it implementing it a couple of times already.

So most likely this won't ever be fixed, unless one day I find some brilliant way of doing the same thing on a hardware canvas

@asierpn
Copy link

asierpn commented Nov 9, 2023

We had the same warning in our app only in Android 13 emulators and it went away after removing android:hardwareAccelerated="false" from the manifest.

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

3 participants