Start the refresh on open as soon as the network is connected #5583
All Vouch review confidence checks passed
Residual risk 0.35 = Change Risk (0.50) × (1 − Review Confidence (0.30)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 621 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 51% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.385
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #5583"
general
weight: 0.35
claude[bot]
PCIOS-1070 · ●●● High · logs · 2/3 pass
Part of PCIOS-1070. Goes straight to trunk and doesn't depend on the other PRs.
The refresh on open always started 2 seconds after the app became active, to give the network time to come up. Now it starts as soon as the network is connected, which is right away when it already is. When it isn't, it still waits at most 2 seconds.
Gain: about 2 s off every open that refreshes, for every library size. With the heavy staging account (545 podcasts, 315K episodes), an open with nothing new should go from 6.5 s to about 4.5 s from process start to synced, and an open after 14 days away from 16.9 s to about 14.9 s. This is an estimate. In every open measured on trunk (optimized build, iPhone 17 Pro simulator, medians of 4–5 runs), the refresh started exactly 2.0 s after the app became active, and the refresh and the sync after it all wait on that start. On this branch the refresh started 5–166 ms after the app became active (signed out, see below). I didn't measure the open times again.
Risk: ●●● High — the refresh that runs on every open after 5 minutes away.
NetworkUtilsgetswhenConnected(timeout:perform:), which holds the callback until the network connects or the timeout passes. Only the refresh on open uses it.refreshOnOpenWithoutDelay(on by default) turns this off remotely.Root cause and fix
AppDelegate.handleBecomeActive()started the refresh from a 2-secondTimer, so it started 2 s after the app became active even when the network was already up. It now callsNetworkUtils.shared.whenConnected(timeout:)with the same 2 s. The refresh starts as soon as theNWPathMonitorpath is satisfied, or after 2 s if it isn't by then, so it never starts later than before. The 5-minute check and the branch that only checks for pending downloads and uploads are unchanged.Checking
isConnected()alone wasn't enough.NetworkUtilsstarts its monitor lazily, and the path isunsatisfieduntil the first update arrives. On a cold launch where nothing else had usedNetworkUtilsyet, the check inhandleBecomeActive()was its first use, so it would have fallen back to the 2 s timer.How to verify
1. Sign in, force quit the app, wait more than 5 minutes and open it. In the debug log or the Xcode console,
Refresh - Started)comes right after the app opens (on a cold launch, right afterNetworkMonitor: Network is connected), not 2 s later.2. Leave the app in the background for more than 5 minutes and come back. The refresh starts right away.
3. On a device, turn on Airplane Mode, wait 5 minutes and open the app. The refresh starts after 2 s and fails, as on trunk. Turn Airplane Mode off, go to the home screen and come back after 15 seconds. The refresh starts right away and works.
4. Turn off
refreshOnOpenWithoutDelayin Beta Features and repeat step 1. The refresh starts 2 s after the app opens, as on trunk.What I ran
handleBecomeActive()with anunsatisfiedpath while the main queue was still busy with the launch; 5 ms when coming back from the background.NetworkUtilsTeststest that the callback runs once, on the main queueNot verified
handleBecomeActive()when its scene becomes active.Checklist
CHANGELOG.mdif necessary.