Skip to content

cold start stability#1042

Merged
balboah merged 11 commits into
blokadaorg:mainfrom
balboah:push-lxwrqzkvtwzq
Apr 10, 2026
Merged

cold start stability#1042
balboah merged 11 commits into
blokadaorg:mainfrom
balboah:push-lxwrqzkvtwzq

Conversation

@balboah
Copy link
Copy Markdown
Contributor

@balboah balboah commented Mar 30, 2026

After the startup refactor that separated background bootstrap from foreground startup and exposed bootstrap identity earlier, a few timing issues became visible:

  • the DNS wizard could appear even when DNS was already configured, because the native DNS state was not always available on the first check
  • a white screen could appear on slow startup paths, such as when waiting for the account id store to load from iCloud while in airplane mode
  • the power button could briefly show the timer layout even when no timer was set

This PR resolves those issues by:

  • retrying DNS verification when the native DNS state is temporarily unavailable, and preserving more native DNS state detail instead of collapsing failures into an empty string
  • only showing the timer layout when a timer is actually set
  • releasing the native splash on the first Flutter frame instead of relying on a fixed delay

@balboah balboah requested a review from kar March 30, 2026 10:11
Copy link
Copy Markdown
Contributor

@kar kar left a comment

Choose a reason for hiding this comment

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

Tried to run on Android, will compile but will never settle into loaded state (stuck on "please wait" on start). Log attached

log-pr.txt

Seems to me that similar changes for privatedns service done for ios, are missing for android side in this PR, maybe that's the problem?

Overall missing the "why" comments for new components. In a month we won't know why something was added. But it's a taste thing, if AI can figure it out I'm fine with not having them in this project.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably analogous changes ar needed for _android version of this file

Comment thread common/lib/src/platform/app/startup_first_frame_reporter.dart
Comment thread common/lib/src/platform/app/startup_promotion_gate.dart
@balboah
Copy link
Copy Markdown
Contributor Author

balboah commented Apr 2, 2026

I'll get the android env set up to see what's going on.

regarding comments, perhaps you can suggest a agents.md update with guidelines on what to comment on and when?

@balboah
Copy link
Copy Markdown
Contributor Author

balboah commented Apr 2, 2026

@codex can you try answering the missing "Why" from the PR questions? brief and to the point please

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex couldn't complete this request. Try again later.

@kar
Copy link
Copy Markdown
Contributor

kar commented Apr 7, 2026

regarding comments, perhaps you can suggest a agents.md update with guidelines on what to comment on and when?

I have added to main now

@balboah balboah force-pushed the push-lxwrqzkvtwzq branch 2 times, most recently from ea764f2 to 8cce4c6 Compare April 10, 2026 08:50
balboah and others added 11 commits April 10, 2026 10:53
ensure splash continues showing until flutter is ready to draw something.
- cancel the fallback timer after a successful foreground promotion
- add regression coverage for in-flight and post-success background launches
The cloudPermCheckSettled gate introduced for iOS deferred DNS retries
could leave Android permanently stuck in initializing state. Two fixes:

1. ConnectivityService.rescan() now queries initial DNS state
   synchronously so privateDns is populated before first callback fires,
   matching the iOS behavior of reading DNS state from system settings.

2. PlatformPermActor wraps _recheckDnsPerm in try-catch to ensure
   cloudPermCheckSettled is always restored to true on error, preventing
   the app from getting permanently stuck if a channel call fails.

https://claude.ai/code/session_01Gc63y37qftNhTYNzZQ4d3J
ConnectivityService: check NET_CAPABILITY_NOT_VPN before reading DNS
from activeNetwork, preventing incorrect reads when VPN is active
during later rescan() calls (e.g. doze state changes).

PlatformPermActor: log the error before settling cloudPermCheckSettled
on DNS check failure for easier debugging.

https://claude.ai/code/session_01Gc63y37qftNhTYNzZQ4d3J
- modules.dart: start foreground modules before stage.setForeground so
  routeChanged listeners (DeviceStore.fetch) no longer race the account
  creation and hang the cold start on a fresh install
- StartupContextService: implement firstFrameRendered channel and a
  listener API mirroring the iOS StartupContext signal
- MainActivity + activity_main.xml: add a splash overlay reusing the
  existing @drawable/splash and fade it out when Flutter reports its
  first frame, eliminating the white-screen gap before the home view
- Refactor _recheckDnsPerm with try/finally to guarantee cloudPermCheckSettled
- Add lifecycleSeen gate to prevent duplicate foreground promotion
- Fix BottomManagerSheet: dedup sheets, capture navigator for safe dismiss
- Auto-dismiss DNS onboarding when cloudPermEnabled flips true
- Remove duplicate self-dismiss listener in iOS DNS sheet
- Cancel splash fallback on activity destroy
@balboah balboah force-pushed the push-lxwrqzkvtwzq branch from 8cce4c6 to 778f2cf Compare April 10, 2026 08:54
@balboah balboah requested a review from kar April 10, 2026 09:05
@balboah
Copy link
Copy Markdown
Contributor Author

balboah commented Apr 10, 2026

ok ready for another review

@kar
Copy link
Copy Markdown
Contributor

kar commented Apr 10, 2026

Ok I went through the code as well as built and ran this on android. Did basic onboarding and no-network cold start test.

Behavior seems proper, nice you addressed the modal-dismiss-detection workaround, it was causing some bugs in the past but I couldn't figure out the proper solution before the ai era. I was concerned about the new code not working well but I couldn't bug it out in testing.

I like the new comments. Code changes look reasonable and positive overall. I didn't experience any problems with splash screen / white screen or foreground trigger.

Also built the family flavor, went through onboarding, messed with the lock screen feature and modals (this flavor has more of them), bg/fg switching. All behavior nominal.

lgtm

@balboah
Copy link
Copy Markdown
Contributor Author

balboah commented Apr 10, 2026

also tested ios fcm event to also confirm it still worked

@balboah balboah merged commit 813c828 into blokadaorg:main Apr 10, 2026
@balboah balboah deleted the push-lxwrqzkvtwzq branch May 22, 2026 09:05
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.

3 participants