Skip to content

Feat/perf player UI optimizations#259

Merged
theovilardo merged 5 commits intomasterfrom
feat/perf-player-ui-optimizations
Oct 15, 2025
Merged

Feat/perf player UI optimizations#259
theovilardo merged 5 commits intomasterfrom
feat/perf-player-ui-optimizations

Conversation

@theovilardo
Copy link
Copy Markdown
Owner

No description provided.

google-labs-jules bot and others added 5 commits October 13, 2025 01:34
Removed `compositingStrategy = CompositingStrategy.Offscreen` from several components in the player UI to improve animation performance, especially on low-end devices. This change avoids forcing the entire UI to be re-rendered into a separate bitmap on each frame, which was causing significant lag.

The strategy was removed from the main player sheet surface and other simpler components where the overhead was greater than the benefit. It was retained only for complex visual elements that are transformed without their internal content changing, ensuring a smoother animation experience without sacrificing visual quality.
This commit implements a deep performance optimization of the UnifiedPlayerSheet to eliminate animation jank, following a detailed performance guide.

The key changes include:

1.  **State-Read Deferral:** Refactored `FullPlayerContent` and its children to accept state provider lambdas (`() -> T`) for frequently changing values like `currentPosition`, `isPlaying`, and `isFavorite`. This isolates recomposition to only the lowest-level composables that consume the state, drastically reducing the recomposition scope.

2.  **Stable Lambdas:** Replaced all inline lambda event handlers (e.g., `{ viewModel.playPause() }`) with stable function references (e.g., `viewModel::playPause`) to ensure parameter stability and allow Compose to skip recompositions more effectively.

3.  **Component Isolation:** Extracted `FullPlayerContent` and its related sub-composables into a separate file (`player/FullPlayerContent.kt`) for better modularity and code organization.

4.  **Graphics Optimization:** Removed unnecessary `compositingStrategy = CompositingStrategy.Offscreen` from `graphicsLayer` modifiers where simple alpha or translation transformations are used, reducing GPU and memory overhead.
This commit implements a deep performance optimization of the UnifiedPlayerSheet to eliminate animation jank, following a detailed performance guide.

The key changes include:

1.  **State-Read Deferral:** Refactored `FullPlayerContent` and its children to accept state provider lambdas (`() -> T`) for frequently changing values like `currentPosition`, `isPlaying`, and `isFavorite`. This isolates recomposition to only the lowest-level composables that consume the state, drastically reducing the recomposition scope.

2.  **Stable Lambdas:** Replaced all inline lambda event handlers (e.g., `{ viewModel.playPause() }`) with stable function references (e.g., `viewModel::playPause`) to ensure parameter stability and allow Compose to skip recompositions more effectively.

3.  **Component Isolation:** Extracted `FullPlayerContent` and its related sub-composables into a separate file (`player/FullPlayerContent.kt`) for better modularity and code organization.

4.  **Graphics Optimization:** Removed unnecessary `compositingStrategy = CompositingStrategy.Offscreen` from `graphicsLayer` modifiers where simple alpha or translation transformations are used, reducing GPU and memory overhead.

Fixes a bug where `collectAsState()` was called inside a non-composable lambda, causing a crash. The state is now correctly collected in the parent composable context.
This commit implements a deep performance optimization of the UnifiedPlayerSheet to eliminate animation jank, following a detailed performance guide.

The key changes include:

1.  **State-Read Deferral:** Refactored `FullPlayerContent` and its children to accept state provider lambdas (`() -> T`) for frequently changing values like `currentPosition`, `isPlaying`, and `isFavorite`. This isolates recomposition to only the lowest-level composables that consume the state, drastically reducing the recomposition scope.

2.  **Stable Lambdas:** Replaced all inline lambda event handlers (e.g., `{ viewModel.playPause() }`) with stable function references (e.g., `viewModel::playPause`) to ensure parameter stability and allow Compose to skip recompositions more effectively.

3.  **Component Isolation:** Extracted `FullPlayerContent` and its related sub-composables into a separate file (`player/FullPlayerContent.kt`) for better modularity and code organization.

4.  **Graphics Optimization:** Removed unnecessary `compositingStrategy = CompositingStrategy.Offscreen` from `graphicsLayer` modifiers where simple alpha or translation transformations are used, reducing GPU and memory overhead.

**Fixes:**
- Corrects a bug where `collectAsState()` was called inside a non-composable lambda. The state is now correctly collected in the parent composable context.
- Resolves a crash (`IllegalStateException: No ColorScheme provided`) caused by incorrect `CompositionLocal` scoping after refactoring. The `LocalMaterialTheme` is now made `internal` and shared correctly between files, eliminating the need for a duplicate private definition and ensuring the theme is properly provided to all child composables.
This commit refactors `UnifiedPlayerSheet.kt` by removing a significant amount of unused code and commented-out logic.

The key changes include:
- Removing unused imports, including `Trace`, `Toast`, and several animation-related imports.
- Deleting obsolete state collectors for dismissed songs/queues.
- Eliminating commented-out shape and radius calculations related to the player sheet and navigation bar, simplifying the component's layout logic.

This cleanup improves code readability and maintainability by removing deprecated and unnecessary code paths.
@theovilardo theovilardo merged commit 1f03376 into master Oct 15, 2025
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