Fix frontend settings reset by preserving WebView cache across scene lifecycle#3863
Fix frontend settings reset by preserving WebView cache across scene lifecycle#3863binarylogic wants to merge 1 commit intohome-assistant:masterfrom
Conversation
…lifecycle Remove clearCachedControllers() call from sceneDidDisconnect to prevent WebView recreation during normal app lifecycle events. Scene disconnect occurs frequently (backgrounding, multitasking, memory pressure) and should not clear cached WebViews as this destroys frontend settings stored in WebKit localStorage/IndexedDB. WebView cache cleanup still occurs appropriately during logout/error states via the onboarding observer. Fixes periodic dashboard/theme/sidebar settings reset reported in community for years across iPhone, iPad, and Mac apps. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Hi @binarylogic
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Pull Request Overview
Fixes the long-standing issue where user frontend settings (dashboard selection, theme, sidebar configuration, timezone) periodically reset by preventing aggressive WebView cache clearing during normal app lifecycle events.
- Removes unnecessary
clearCachedControllers()call from scene disconnect handler - Preserves WebView state during backgrounding, multitasking, and memory pressure events
- Maintains proper cleanup during logout/error states via existing onboarding observer
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Cleaning cached controllers doesn't mean cleaning the webview cache, if that was the case then force closing the app would also clean the cache as the controller would be deallocated. |
|
Feel free to reopen the PR in case I misunderstood your change or you add a different approach. |
|
@bgoncal Thanks for checking this out. This issue only occurs in the iOS app, never in the browser. When I access Home Assistant through a browser, my settings persist correctly. That makes me think this is specific to the iOS app rather than the frontend. If that’s not the case, could you point me to where I should look next? |
|
When I saw your PR I forwarded the issue to frontend devs and requested priority in moving this settings to be persisted out of the browser (webview) domain, they will give priority to this. |
is there a github issue for it? |
|
There is a PR open already home-assistant/frontend#25702 |
Summary
Closes #3862
Fixes the long-standing issue where user frontend settings (dashboard selection, theme, sidebar configuration, timezone) periodically reset as if the app were freshly installed. This has been reported for years across iPhone, iPad, and Mac apps.
Root Cause: The app was aggressively clearing WebView cache on every scene disconnect via
clearCachedControllers()insceneDidDisconnect. Scene disconnects happen frequently during normal app lifecycle (backgrounding, multitasking, memory pressure), causing WebView recreation and loss of frontend settings stored in WebKit localStorage/IndexedDB.Fix: Remove the unnecessary
clearCachedControllers()call from scene disconnect while preserving appropriate cleanup during logout/error states via the existing onboarding observer.Context: I'm a software engineer (Rust/Go/Ruby) but not an iOS developer. I used Claude to investigate the codebase and identify this root cause after experiencing the bug myself on multiple devices running internal-URL-only configurations.
Screenshots
N/A - Internal bug fix with no UI changes
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#N/A
Any other notes
This is a focused, surgical fix that:
The fix is conservative and low-risk - it only removes an overly aggressive cache clearing operation while leaving all legitimate cleanup paths intact.