fix: Clear stuck workspace blur after drawer/folder close (#6998)

Depth blur could leave RenderEffect on workspace/hotseat when SurfaceControl apply returned early, then setDepth(0) skipped re-apply. Always sync view blur with depth and force re-apply when settling to NORMAL; also clear leftover effects on folder dismiss.

blurWorkspaceDepthTargets can run on API 30; setRenderEffect and
createBlurEffect require API 31 and would throw on R.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Pavel VolkovandCursor authored and GitHub committed 2026-07-14 09:26:23 +08:00
1 parent 67959b4d66
commit c32af3c8c5
4 files changed
+66 -25

No files matched your search

@@ -184,6 +184,11 @@ public class DepthController extends BaseDepthController implements StateHandler
if (toState == LauncherState.BACKGROUND_APP) {
addOnDrawListener();
}
// Re-apply even when depth is already 0 so an interrupted All Apps / depth transition
// cannot leave workspace RenderEffect or surface blur stuck until the next resume.
if (toState == LauncherState.NORMAL) {
applyDepthAndBlur();
}
}
@Override
@@ -201,8 +201,7 @@ public class BaseDepthController {
boolean applyImmediately, boolean skipSimilarBlur) {
float depth = mDepth;
IBinder windowToken = mLauncher.getRootView().getWindowToken();
if (windowToken != null) {
if (!Utilities.ATLEAST_R) return;
if (windowToken != null && Utilities.ATLEAST_R) {
if (enableScalingRevealHomeAnimation()) {
mWallpaperManager.setWallpaperZoomOut(windowToken, depth);
} else {
@@ -214,6 +213,32 @@ public class BaseDepthController {
}
}
boolean hasOpaqueBg = mLauncher.getScrimView().isFullyOpaque();
boolean isSurfaceOpaque = !mHasContentBehindLauncher && hasOpaqueBg && !mPauseBlurs;
float blurAmount;
if (enableScalingRevealHomeAnimation()) {
blurAmount = mapDepthToBlur(depth);
} else {
blurAmount = depth;
}
int previousBlur = mCurrentBlur;
int newBlur = BlurUtils.supportsBlursOnWindows() && mCrossWindowBlursEnabled
&& !hasOpaqueBg && !mPauseBlurs
? (int) (blurAmount * mMaxBlurRadius) : 0;
int delta = Math.abs(newBlur - previousBlur);
boolean skipUpdate = skipSimilarBlur && delta < Utilities.dpToPx(1) && newBlur != 0
&& previousBlur != 0 && blurAmount != 1f;
// Always keep mCurrentBlur and workspace RenderEffects in sync with depth, even when the
// SurfaceControl is temporarily unavailable. Otherwise setDepth(0) can early-return later
// (same depth) and leave workspace/hotseat stuck blurred until the activity restarts.
if (!skipUpdate) {
mCurrentBlur = newBlur;
blurWorkspaceDepthTargets();
}
if (!BlurUtils.supportsBlursOnWindows()) {
return;
}
@@ -228,44 +253,29 @@ public class BaseDepthController {
return;
}
mWaitingOnSurfaceValidity = false;
boolean hasOpaqueBg = mLauncher.getScrimView().isFullyOpaque();
boolean isSurfaceOpaque = !mHasContentBehindLauncher && hasOpaqueBg && !mPauseBlurs;
float blurAmount;
if (enableScalingRevealHomeAnimation()) {
blurAmount = mapDepthToBlur(depth);
} else {
blurAmount = depth;
}
SurfaceControl blurSurface =
enableOverviewBackgroundWallpaperBlur() && mBlurSurface != null ? mBlurSurface
: mBaseSurface;
int previousBlur = mCurrentBlur;
int newBlur = mCrossWindowBlursEnabled && !hasOpaqueBg && !mPauseBlurs ? (int) (blurAmount
* mMaxBlurRadius) : 0;
int delta = Math.abs(newBlur - previousBlur);
if (skipSimilarBlur && delta < Utilities.dpToPx(1) && newBlur != 0 && previousBlur != 0
&& blurAmount != 1f) {
if (skipUpdate) {
Log.d(TAG, "Skipping small blur delta. newBlur: " + newBlur + " previousBlur: "
+ previousBlur + " delta: " + delta + " surface: " + blurSurface);
return;
}
mCurrentBlur = newBlur;
Log.v(TAG, "Applying blur: " + mCurrentBlur + " to " + blurSurface);
final SurfaceControl.Transaction finalTransaction =
transaction == null ? createTransaction() : transaction;
// LC: Fix blur effect on Android 12.1/12.0
try (finalTransaction) {
if (blurSurface != null && blurSurface.isValid()) {
finalTransaction.setBackgroundBlurRadius(blurSurface, mCurrentBlur)
.setOpaque(blurSurface, isSurfaceOpaque);
} else {
// GRASP
if (blurSurface == null || !blurSurface.isValid()) {
return;
}
finalTransaction.setBackgroundBlurRadius(blurSurface, mCurrentBlur)
.setOpaque(blurSurface, isSurfaceOpaque);
boolean wantsEarlyWakeUp = blurAmount > 0 && blurAmount < 1;
if (wantsEarlyWakeUp && !mInEarlyWakeUp) {
@@ -285,8 +295,6 @@ public class BaseDepthController {
// LC: Always apply immediately.
finalTransaction.apply();
}
blurWorkspaceDepthTargets();
}
/**
@@ -328,7 +336,13 @@ public class BaseDepthController {
/** @return {@code true} if the workspace should be blurred. */
@VisibleForTesting
public boolean blurWorkspaceDepthTargets() {
// RenderEffect / createBlurEffect require API 31+.
if (!Utilities.ATLEAST_S) {
return false;
}
if (!Flags.allAppsBlur()) {
// Still clear any leftover effect if the flag flips or blur was applied earlier.
mLauncher.getDepthBlurTargets().forEach(target -> target.setRenderEffect(null));
return false;
}
StateManager<LauncherState, Launcher> stateManager = mLauncher.getStateManager();
@@ -361,6 +375,11 @@ public class BaseDepthController {
depthF = depthI / 256f;
}
if (Float.compare(mDepth, depthF) == 0) {
// Depth is unchanged, but a previous apply may have returned early (invalid surface)
// leaving blur stuck. Force a re-apply when clearing.
if (depthF == 0f && mCurrentBlur != 0) {
applyDepthAndBlur();
}
return;
}
mDepth = depthF;
@@ -1147,6 +1147,14 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
}
SCALE_PROPERTY.set(launcher.getWorkspace(), 1f);
SCALE_PROPERTY.set(launcher.getHotseat(), 1f);
// Clear any stuck workspace/hotseat RenderEffect if we are not in a depth-blur state.
// Expressive folder open/close can race with All Apps depth blur and leave icons blurred.
if (Utilities.ATLEAST_S
&& launcher.getStateManager().getState().getDepth(launcher) == 0f) {
for (View target : launcher.getDepthBlurTargets()) {
target.setRenderEffect(null);
}
}
}
@Override
@@ -19,6 +19,8 @@ package com.android.launcher3.folder
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import com.android.launcher3.Launcher
import com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY
import com.android.launcher3.Utilities
import com.android.launcher3.views.ScrimView
/**
@@ -51,5 +53,12 @@ class FolderScrimAnimationListener(
scrimView.setScrimColors(
launcher.stateManager.state.getWorkspaceScrimColor(launcher),
)
// Also reset scale here: close animations can be cancelled without going through
// Folder.closeComplete's restore path, leaving workspace/hotseat visually dimmed/scaled.
SCALE_PROPERTY.set(launcher.workspace, 1f)
SCALE_PROPERTY.set(launcher.hotseat, 1f)
if (Utilities.ATLEAST_S && launcher.stateManager.state.getDepth(launcher) == 0f) {
launcher.depthBlurTargets.forEach { it.setRenderEffect(null) }
}
}
}