Skip to content

fix: ensure system info is loaded before MainShell builds#1105

Merged
SERDUN merged 1 commit into
developfrom
fix/main-shell-no-system-info-crash
Apr 13, 2026
Merged

fix: ensure system info is loaded before MainShell builds#1105
SERDUN merged 1 commit into
developfrom
fix/main-shell-no-system-info-crash

Conversation

@SERDUN

@SERDUN SERDUN commented Apr 11, 2026

Copy link
Copy Markdown
Member

Problem

After an FGS failure (e.g. Xiaomi "did not start in time"), the app could crash with:

StateError: No system info in cache, ensure getLocalSystemInfo() has been called
on logged-in routes after the initial system info load

#0  SystemInfoRepositoryImpl.getLocalSystemInfo  (system_info_repository.dart:96)
#1  _MainShellState.build.<anonymous closure>    (main_shell.dart:257)
...
#6  _MainShellState._pollingRegistrations        (main_shell.dart)

Root cause: CallerIdSettingsRepository.create (and one other provider at line 176) call getLocalSystemInfo() synchronously. The MainShellRoute guard only checked for a valid session token — it did not verify that system info was actually in the cache.

After FGS failure the app can reach MainShellRoute in authenticated state (session token still in SecureStorage) while system info is absent — either because userSessionCleanupResolver.clear() ran in a previous process, or because the initial info fetch was interrupted before setSystemInfo() completed.

Fix

Add getSystemInfo(cacheFirst) to onMainShellRouteGuardNavigation, executed after the auth check:

  • If cache already has data → returns immediately (no network call)
  • If cache is empty → fetches from network and populates cache before navigation resolves
  • If both cache and network fail → redirects to login

SystemInfoRepository is injected into AppRouter via constructor.

Test plan

  • Normal launch: MainShell opens, no extra network round-trip (cache hit)
  • Clear app data → launch → login → MainShell opens correctly after info fetch
  • Simulate no-cache + offline → app redirects to login instead of crashing
  • FGS crash on Xiaomi → app recovers to login, not crash

CallerIdSettingsRepository.create and another provider create: in main_shell.dart
call getLocalSystemInfo() synchronously. If system info is absent (cleared during
session cleanup after FGS failure, or never fetched in this session) the provider
throws StateError and crashes the app.

Add a getSystemInfo(cacheFirst) call to onMainShellRouteGuardNavigation, executed
after the auth check and before navigation resolves. If system info cannot be
loaded — no cache and network unreachable — redirect to the login screen.

This prevents the crash observed on Xiaomi after FGS recovery:
  CallerIdSettingsRepository.create → getLocalSystemInfo() → StateError:
  "No system info in cache" (main_shell.dart:257)

This comment was marked as resolved.

@SERDUN SERDUN marked this pull request as ready for review April 13, 2026 13:59
@SERDUN SERDUN merged commit 040dd8a into develop Apr 13, 2026
5 checks passed
@SERDUN SERDUN deleted the fix/main-shell-no-system-info-crash branch April 13, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants