perf: optimize navigation bar and blur animations via caching and dra…#2158
Conversation
…w-phase clipping Implements performance optimizations for the navigation bar and background blur during player expansion. These changes reduce recompositions and object allocations by moving clipping to the graphics layer and caching expensive UI objects. - Moved navigation bar shape and clipping logic to `graphicsLayer` to avoid triggering layout passes during corner radius animations. - Introduced `BlurEffectCache` to quantize blur radii (4px steps) and reuse `RenderEffect` instances, reducing allocations during expansion. - Added `NavBarShapeCache` to provide stable `Shape` instances for quantized corner radii. - Refactored `DynamicSmoothCornerShape` to cache generated `Outline` paths and support toggling between smooth and standard rounded corners. - Updated navigation bar visibility logic to use vertical translation instead of height changes, preventing child elements from resizing or squishing during transitions. - Integrated `useSmoothCorners` state to dynamically switch between `AbsoluteSmoothCornerShape` and `RoundedCornerShape`.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fa0d2c76c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .height(visibleNavBarOccupiedHeight) | ||
| .height(navBarOccupiedHeight) |
There was a problem hiding this comment.
Keep hidden nav bar from reserving full inset
When shouldHideNavigationBar becomes true for hidden routes or an active search bar, shouldRenderNavigationBar remains true during the 220 ms hide animation, so this bottomBar is still measured at the full navBarOccupiedHeight. Since Scaffold passes that measured height as innerPadding to AppNavigation, the content keeps a full blank bottom inset until the bar is finally removed, then jumps; before this change the Box height used visibleNavBarOccupiedHeight, so the reserved space collapsed together with the animation.
Useful? React with 👍 / 👎.
…w-phase clipping
Implements performance optimizations for the navigation bar and background blur during player expansion. These changes reduce recompositions and object allocations by moving clipping to the graphics layer and caching expensive UI objects.
graphicsLayerto avoid triggering layout passes during corner radius animations.BlurEffectCacheto quantize blur radii (4px steps) and reuseRenderEffectinstances, reducing allocations during expansion.NavBarShapeCacheto provide stableShapeinstances for quantized corner radii.DynamicSmoothCornerShapeto cache generatedOutlinepaths and support toggling between smooth and standard rounded corners.useSmoothCornersstate to dynamically switch betweenAbsoluteSmoothCornerShapeandRoundedCornerShape.