Skip to content

Fix CarPlay Settings screen freezing#4478

Open
llkenny wants to merge 2 commits intohome-assistant:mainfrom
llkenny:fix-carplay-freezes
Open

Fix CarPlay Settings screen freezing#4478
llkenny wants to merge 2 commits intohome-assistant:mainfrom
llkenny:fix-carplay-freezes

Conversation

@llkenny
Copy link
Copy Markdown
Contributor

@llkenny llkenny commented Apr 4, 2026

Summary

Fix #4439

Freeze caused by NavigationLink destination implemented as inline computed view inside parent:

  • SwiftUI kept re-evaluating tabsSelection through parent getter
  • List + ForEach + Button triggered infinite view recomposition loop
  • Profiler showed repeated CarPlayConfigurationView.tabsSelection.getter

Fix: extract destination into separate View struct (CarPlayTabsSelectionView):

  • This creates a stable identity boundary
  • SwiftUI diffs child independently from parent
  • Recomposition loop disappears, UI no longer freezes

How to reproduce the bug:

  1. Open Settings -> Companion App -> CarPlay
  2. Tap "Quick access, Areas, Settings"

Screenshots

app

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Before fix
CPU_bug
Memory_bug
Screenshot 2026-04-04 at 09 22 23
After fix
CPU_fix
Memory_fix

Copilot AI review requested due to automatic review settings April 4, 2026 12:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes issue #4439 where the CarPlay Settings screen would freeze immediately upon opening. The root cause was a NavigationLink destination implemented as an inline computed view property, which caused SwiftUI to continuously re-evaluate the view and triggered an infinite recomposition loop. The fix extracts this destination into a separate CarPlayTabsSelectionView struct, creating a stable identity boundary that prevents the recomposition cycle.

Changes:

  • Creates new CarPlayTabsSelectionView.swift with the extracted tabs selection UI
  • Updates CarPlayConfigurationView.swift to use the new extracted view instead of an inline computed property
  • Updates the Xcode project file to include the new file in the build configuration

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Sources/App/Settings/CarPlay/CarPlayTabsSelectionView.swift New view struct that encapsulates the tabs selection UI, replacing the inline computed view
Sources/App/Settings/CarPlay/CarPlayConfigurationView.swift Refactored to instantiate CarPlayTabsSelectionView directly in the NavigationLink
HomeAssistant.xcodeproj/project.pbxproj Added file reference and build phase entry for the new view

@llkenny llkenny force-pushed the fix-carplay-freezes branch from b26908b to cfe853a Compare April 4, 2026 12:37
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@034b8b3). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4478   +/-   ##
=======================================
  Coverage        ?   42.33%           
=======================================
  Files           ?      268           
  Lines           ?    15758           
  Branches        ?        0           
=======================================
  Hits            ?     6671           
  Misses          ?     9087           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@llkenny llkenny changed the title Add CarPlayTabsSelectionView Fix CarPlay Settings screen freezing Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CarPlay Settings screen freezes immediately

2 participants