Skip to content

Optimize UnifiedPlayerSheet performance#916

Draft
google-labs-jules[bot] wants to merge 4 commits intofix/unified-player-sheet-laggingfrom
optimized-unified-player-sheet-perf-11139090902579458025
Draft

Optimize UnifiedPlayerSheet performance#916
google-labs-jules[bot] wants to merge 4 commits intofix/unified-player-sheet-laggingfrom
optimized-unified-player-sheet-perf-11139090902579458025

Conversation

@google-labs-jules
Copy link
Contributor

Optimized UnifiedPlayerSheet performance by refactoring state reads and removing updateTransition usage for continuous values. eliminated Excessive Recompositions and Alpha Jitter.


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

Refactored `UnifiedPlayerSheet` to reduce recompositions and eliminate jitter during expansion.
- Replaced `rememberExpansionTransition` with direct `derivedStateOf` interpolation for alpha and elevation, fixing the animation jitter.
- Optimized `zIndex` logic by introducing `isMiniPlayerAbove` derived boolean state, preventing recomposition on every frame.
- Deferred state reads for `alpha` inside `graphicsLayer`.
- Removed unused `Expansion.kt` helper file.
@google-labs-jules
Copy link
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!

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


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

Refactored `UnifiedPlayerSheet` to eliminate excessive recompositions and layout thrashing during expansion/drag gestures.

- Replaced `rememberExpansionTransition` with direct `derivedStateOf` interpolation for alpha and elevation, fixing the animation jitter.
- Optimized `zIndex` logic by introducing `isMiniPlayerAbove` derived boolean state.
- Introduced `playerLayout` custom modifier to defer height and padding updates to the layout phase, preventing recomposition of the modifier chain.
- Introduced `DynamicCornerShape` to read corner radius from `State` objects during draw/layout, preventing shape instance recreation.
- Wrapped all animated values (alpha, translation, padding, height) in `State` objects and updated usages to read them only inside `graphicsLayer`, `layout`, or `draw` blocks.
- Deleted unused `Expansion.kt` helper file.
- Fixed `MiniPlayerContentInternal` usage to avoid passing animated values.
Fixed unresolved references and ambiguity errors introduced in the previous optimization step.
- Updated `queueHiddenOffsetPx` to correctly read `.value` from `currentBottomPaddingState`.
- Created `Modifier.bottomPadding(State<Dp>)` using `layout` to apply bottom padding dynamically without recomposition.
- Replaced usage of `.padding(bottom = ...)` with `.bottomPadding(...)`.
Optimized shape rendering to fix "stuck at 0.dp" corners and further reduce recompositions.
- Replaced `DynamicCornerShape` with `dynamicRoundedShapeState` (derived state) to ensure correct shape creation.
- Used `graphicsLayer` with `shape` and `clip` parameters referencing state values internally, avoiding composition invalidation.
- Removed shape argument from `background` modifier, relying on the layer's clip.
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.

0 participants

Comments