Files
Palash Debnath b569856908 Merge train 2026-12-01c: iOS download stall, false crash reports, setup cancel (#4593)
* fix(ios): restart model transfers that stall at 0 B/s (#4587)

Background URLSession retries timed-out tasks silently until the resource
timeout (7 days here) and treats tasks started while the app is in the
background as discretionary. The parallel scheduler only creates the tail
range after the first two 64 MiB ranges finish, which commonly happens while
the app is backgrounded, so Kitten's last range could wait indefinitely at
80%. The transport then reattached that same OS task by key on every retry,
pause/resume and relaunch, so the stall repeated every time.

ModelStore now runs each range wait under a stall watchdog: when the
transport reports no new byte for its idle interval (120 s for the background
transport) during awake time, the wait is abandoned as a retryable network
failure and the next source is tried. The background transport cancels the
abandoned task with resume data instead of suspending it, so the retry starts
a fresh task from the received bytes. Android already fails a stalled read via
OkHttp's 120 s read timeout and moves to the next source.

* Add iOS and Android to the issue forms

Phone reports had to pick a desktop OS and install method; the forms now
offer iOS, Android, the phone app install and on-device compute.

* Name the changelog fragment after the pull request

* fix(diagnostics): do not report Windows shutdown or installer exits as crashes

Windows may end the process as soon as the session-end handler returns, and
installers force-kill the app shortly after asking it to close, so the async
orderly quit often never retired the session marker and the next launch
reported an unclean_exit. Retire this process's own marker synchronously on
session-end and at the start of an orderly quit, and keep liveness refreshes
from restoring it. A process that dies any other way is still reported.

* Name the changelog fragment after the pull request

* fix(setup): keep a cancelled runtime repair cancelled and log why a venv is unusable

Cancel on the setup progress screen calls restart(). When that install was
the automatic repair of an existing runtime (or a first run whose install
marker now counts as an earlier install), start() either launched the same
install again or, once a repair had been attempted this launch, reported
"automatic repair did not finish". The renderer classifies that message as
BROKEN_VENV, so a user's Cancel was reported as a broken environment within
10 s of the restart.

- runtime-repair: a cancelled setup is left to the setup screen (Resume),
  never restarted on the user's behalf or reported as a failed repair.
- backend: restart() during an install marks it cancelled; an explicit
  setup run clears the mark.
- runtime-readiness: report why a project is not usable (missing
  interpreter, missing pyvenv.cfg, unfinished install, other version, or the
  failing import); the supervisor logs it before repairing, so a repair
  that does not help still says why.

* Name the changelog fragment after the pull request

* fix(diagnostics): keep a pending marker write from outliving session end

A marker write that passed the end check before endSession() could still
rename a fresh active marker into place, and the later async removal may
never run once Windows ends the process. Check right before the rename and
remove synchronously as it completes. Document that close to tray followed
by an installer kill, and a windowless app at Windows shutdown, are still
reported, and accept CRLF checkouts in the source-order test.

* fix(setup): address review on the broken-venv recovery

- torch-choice wiring test accepts the readiness reason callback, still
  requiring rememberTorchVariant() right after the ready branch records the
  project; the callback is now a named noteReason(project).
- The "not usable" reason is written to the setup log directly (pushLog only
  feeds it while installing) and stays in the log tail when the automatic
  repair resets it.
- The setup failure handler reads the install marker before writing any
  state and re-checks the generation, so a Cancel during that await keeps
  its Resume screen.
- Only ENOENT/ENOTDIR count as a missing interpreter or pyvenv.cfg; other
  stat errors (EACCES, EPERM, EIO) are named with their code.

* fix(ios): do not count connectivity waits as stalled model transfers

The stall watchdog treated a background task waiting for Wi-Fi (or for any
connection) as stalled, abandoned it and spent all five retry rounds. The
resulting timeout paused the download with an error, so restoring Wi-Fi no
longer resumed it. The watchdog now restarts its interval whenever the
connection the policy requires is unavailable, and counts only steps that
were connected from start to end. The app passes its connectivity state.

* fix(diagnostics): publish the session marker through renameWithRetry

The pending-write guard wrapped node:fs rename directly, which the
rename-retry guard test forbids (Windows antivirus retries). Check
publishability before the plain renameWithRetry and again as it settles;
only microtasks run in between, so an ended session still never keeps
the marker.

* fix(setup): show the unusable-runtime reason only for the runtime it describes

The retained reason now carries its project; setup for a moved runtime
location drops it instead of showing the old location's diagnosis.

* fix(setup): recheck the start generation and keep readiness reasons honest

- start(): read the install, Windows ROCm and interrupted state first, then
  return if a restart() or shutdown() overtook this start, before writing
  any status or starting a repair.
- runtime-readiness: name a build mismatch only when the ready marker
  proves it; keep this decision's Windows ROCm verification failure as the
  reason; otherwise use a neutral reason. No extra native probe runs.

* fix(mobile): demote a stalled model source and qualify resumed bytes

A source that stalled or dropped the connection kept its earlier measured
rate, so when both sources had rates the next range or attempt could wait a
full stall interval on it again. iOS and Android now set that source's rate to
zero on a network failure (not on HTTP retry statuses) and order demoted
sources last until they deliver again.

The docs, contract and changelog no longer claim received bytes are always
kept: completed ranges are, while an abandoned range continues only from
resume data the system provides.

* fix(mobile): end a source's demotion when it delivers again

A demoted source that answered too quickly to sample a rate stayed at
rate 0 and kept going last for later files. A validated answer now clears
the demotion on iOS and Android, with a test on each.

* test(ios): widen the stall window in the demoted-source test

A slow CI runner pushed the mirror's 200 ms answer past the 0.3 s stall
window, scrambling the expected host order.

* test(mobile): keep the demotion-recovery order fixed on slow runners

The recovered source could be sampled as slower than the mirror on a slow
runner; give the mirror a clearly slower measured rate on iOS and Android.
2026-12-02 20:33:55 +05:30
..