mirror of
https://github.com/home-assistant/iOS.git
synced 2026-06-16 04:16:39 -05:00
<!-- Thank you for submitting a Pull Request and helping to improve Home Assistant. Please complete the following sections to help the processing and review of your changes. Please do not delete anything from this template. --> ## Summary <!-- Provide a brief summary of the changes you have made and most importantly what they aim to achieve --> Fixes three distinct crashes in the widget extension process that cause widgets to go blank and not recover until the app is reinstalled. - **ServerCache precondition crash** — `ServerCache.info.didSet` uses a `precondition` that reads `deletedServers` from shared UserDefaults on every check. When the main app deletes a server, the widget's cached `info` dict still contains it, causing the precondition to fail on the next mutation. Replaced with an error log, matching the existing pattern for the `server` dict. This was the most common crash (4 of 10 logs) and created a permanent crash loop only fixable by reinstalling. - **Thread-unsafe `cachedApis` dictionary** — `AppEnvironment.cachedApis` is a plain dictionary accessed concurrently from multiple AppIntent threads (`ScriptAppIntent`, `SwitchIntent`), causing memory corruption. Added `NSLock` synchronization around all access. - **`fatalError` in GRDB initialization** — When `DatabaseQueue` fails to open the on-disk database (locked file, corruption, file protection), the widget extension calls `fatalError`. Replaced with a fallback to an in-memory database, matching Realm's existing pattern. ## Screenshots <!-- If this is a user-facing change not in the frontend, please include screenshots in light and dark mode. --> ## Link to pull request in Documentation repository <!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" --> Documentation: home-assistant/companion.home-assistant# ## Any other notes <!-- If there is any other information of note, like if this Pull Request is part of a bigger change, please include it here. -->