Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.