Skip to content

Optimize UnifiedPlayerSheet animations#617

Merged
theovilardo merged 14 commits intomasterfrom
optimize-player-sheet-animations-2316053300601963138
Dec 23, 2025
Merged

Optimize UnifiedPlayerSheet animations#617
theovilardo merged 14 commits intomasterfrom
optimize-player-sheet-animations-2316053300601963138

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

This change optimizes the performance of the UnifiedPlayerSheet expansion and collapse animations, specifically targeting lag on mid/low-end devices.

Key changes:

  1. Eliminated Layout Thrashing: Replaced the expensive Modifier.height(animated...) on the root Surface with a fixed-height strategy (.fillMaxWidth().height(containerHeight)) combined with Modifier.offset. This prevents the entire player hierarchy from being re-measured and re-laid out on every frame of the animation, moving the workload to the placement/draw phase.
  2. Optimized Shadow Rendering: Replaced the AbsoluteSmoothCornerShape (which generates a complex Path every frame) with RoundedCornerShape in the .shadow() modifier. The visual background (.background and .clip) retains the high-quality AbsoluteSmoothCornerShape to preserve the design intent, while the shadow uses the cheaper primitive for GPU efficiency.
  3. Preserved Visuals: Restored dynamic padding animations in FullPlayerContent that were initially considered for removal, ensuring the UX remains fluid and rich.

Included a PERFORMANCE_ANALYSIS.md detailing the diagnosis and strategy.


PR created automatically by Jules for task 2316053300601963138 started by @theovilardo

@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

google-labs-jules bot and others added 13 commits December 23, 2025 12:08
*   Refactored `UnifiedPlayerSheet` to use `Modifier.offset` instead of `Modifier.height` for expansion, eliminating layout thrashing.
*   Updated `FullPlayerContent` to accept expansion fraction as a provider lambda `() -> Float` to prevent expensive recompositions during drag.
*   Moved staggered animations (alpha, translation) into `Modifier.graphicsLayer`.
*   Optimized shadow rendering by using `RoundedCornerShape` for the shadow layer while keeping `AbsoluteSmoothCornerShape` for the visible background.
*   Implemented `zIndex` and off-screen offset logic to ensure correct interactivity of MiniPlayer and underlying content.
*   Fixed compilation issues related to `TopAppBar` and `Scaffold` parameter usage.
…error

*   Refactored `UnifiedPlayerSheet` to use `Modifier.offset` instead of `Modifier.height` for expansion, eliminating layout thrashing.
*   Updated `FullPlayerContent` to accept expansion fraction as a provider lambda `() -> Float` to prevent expensive recompositions during drag.
*   Moved staggered animations (alpha, translation) into `Modifier.graphicsLayer`.
*   Optimized shadow rendering by using `RoundedCornerShape` for the shadow layer while keeping `AbsoluteSmoothCornerShape` for the visible background.
*   Implemented `zIndex` and off-screen offset logic to ensure correct interactivity of MiniPlayer and underlying content.
*   Fixed `Unresolved reference: expansionFraction` compilation error in `FullPlayerContent.kt` by using `expansionFractionProvider` inside `graphicsLayer`.
…atures

*   Refactored `UnifiedPlayerSheet` to use `Modifier.offset` instead of `Modifier.height` for expansion, eliminating layout thrashing.
*   Updated `FullPlayerContent` to accept expansion fraction as a provider lambda `() -> Float` to prevent expensive recompositions during drag.
*   Moved staggered animations (alpha, translation) into `Modifier.graphicsLayer`.
*   Optimized shadow rendering by using `RoundedCornerShape` for the shadow layer.
*   Implemented `zIndex` and off-screen offset logic to ensure correct interactivity of MiniPlayer and underlying content.
*   Restored "Delay Content" functionality: Updated `FullPlayerContent` to respect `FullPlayerLoadingTweaks` by dynamically adjusting alpha start thresholds (e.g., 0.95f) when delay is enabled.
*   Fixed `Unresolved reference: expansionFraction` compilation error.
…aceholders

*   Refactored `UnifiedPlayerSheet` to use `Modifier.offset` instead of `Modifier.height` for expansion, eliminating layout thrashing.
*   Updated `FullPlayerContent` to accept expansion fraction as a provider lambda `() -> Float` to prevent expensive recompositions during drag.
*   Moved staggered animations (alpha, translation) into `Modifier.graphicsLayer`.
*   Optimized shadow rendering by using `RoundedCornerShape` for the shadow layer.
*   Implemented `zIndex` and off-screen offset logic to ensure correct interactivity of MiniPlayer and underlying content.
*   Restored "Delay Content" features: Added `DelayedContent` composable wrapper and implemented `ShimmerBox` placeholders for Album, Controls, Metadata, and Progress.
*   Fixed `Unresolved reference: expansionFraction` compilation error.
*   Fixed regression where TopAppBar disappeared when "Delay All" was enabled; it now remains visible during transitions.
*   Refactored `UnifiedPlayerSheet` to use `Modifier.offset` instead of `Modifier.height` for expansion, eliminating layout thrashing.
*   Updated `FullPlayerContent` to accept expansion fraction as a provider lambda `() -> Float` to prevent expensive recompositions during drag.
*   Moved staggered animations (alpha, translation) into `Modifier.graphicsLayer`.
*   Optimized shadow rendering by using `RoundedCornerShape` for the shadow layer.
*   Implemented `zIndex` and off-screen offset logic to ensure correct interactivity of MiniPlayer and underlying content.
*   Restored "Delay Content" features with `DelayedContent` wrapper.
*   Restored exact dimensions and padding for Placeholders (`ShimmerBox`) to match real content (`AlbumCover`, `Controls`, `Metadata`, `Progress`) precisely, as requested.
*   Fixed `Unresolved reference: expansionFraction` compilation error.
…roll fix

*   Refactored `UnifiedPlayerSheet` to use `Modifier.offset` instead of `Modifier.height` for expansion, eliminating layout thrashing.
*   Updated `FullPlayerContent` to accept expansion fraction as a provider lambda `() -> Float` to prevent expensive recompositions during drag.
*   Moved staggered animations (alpha, translation) into `Modifier.graphicsLayer`.
*   Optimized shadow rendering by using `RoundedCornerShape` for the shadow layer.
*   Implemented `zIndex` and off-screen offset logic to ensure correct interactivity of MiniPlayer and underlying content.
*   Restored "Delay Content" features with `DelayedContent` wrapper and updated threshold (0.85f -> 1.0f) for smoother, less abrupt transitions.
*   Restored exact dimensions and padding for Placeholders (`ShimmerBox`) to match real content precisely.
*   Fixed `AutoScrollingTextOnDemand` broken by the optimization: updated it to accept `expansionFractionProvider` and use `derivedStateOf` to correctly trigger scrolling only when fully expanded (> 0.99f).
*   Fixed `Unresolved reference: expansionFraction` compilation error.
…holders

*   Refactored `UnifiedPlayerSheet` to use `Modifier.offset` instead of `Modifier.height` for expansion, eliminating layout thrashing.
*   Updated `FullPlayerContent` to accept expansion fraction as a provider lambda `() -> Float` to prevent expensive recompositions during drag.
*   Moved staggered animations (alpha, translation) into `Modifier.graphicsLayer`.
*   Optimized shadow rendering by using `RoundedCornerShape` for the shadow layer.
*   Implemented `zIndex` and off-screen offset logic to ensure correct interactivity of MiniPlayer and underlying content.
*   Restored "Delay Content" features with `DelayedContent` wrapper and updated threshold for smoother transitions.
*   Replaced `ShimmerBox` placeholders with simpler, static `PlaceholderBox` composables using `Surface` and `RoundedCornerShape`, matching the exact requested design and layout.
*   Updated `FullPlayerLoadingTweaks` to disable `showPlaceholders` by default.
*   Fixed `AutoScrollingTextOnDemand` to work with the provider-based state.
*   Fixed `Unresolved reference: expansionFraction` compilation error.
…eter

Updates the `MarqueeText` composable in `LibraryScreen.kt` to align with a recent API change.

- The `expansionFraction` parameter, which previously accepted a `Float`, is now changed to `expansionFractionProvider`, which accepts a lambda `() -> Float`.
- The implementation is updated from `expansionFraction = 1f` to `expansionFractionProvider = { 1f }` to match the new function signature.
@theovilardo theovilardo merged commit d7b9eef into master Dec 23, 2025
@lostf1sh lostf1sh deleted the optimize-player-sheet-animations-2316053300601963138 branch January 16, 2026 20:40
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

Successfully merging this pull request may close these issues.

1 participant