# KeepTrack iOS diagnostic test, build 02

## Gregle production deployment

Public hostname: https://satellites.gregle.uk/. The production package opens the
full catalogue directly, retaining the device-tested low-memory settings.
Current data comes from KeepTrack's official /v4/sats/brief bulk endpoint through
the gregle-satellites-catalog Cloudflare Worker in the owner's Cloudflare account.
The API key is a server-side secret binding (KEEPTRACK_API_KEY), never a browser
setting or source file. Responses are streamed and cached for one hour. The app
explicitly labels current data or an older offline fallback if the feed fails.
API data: KeepTrack, CC BY-NC 4.0, https://api.keeptrack.space/.
The diagnostic toolbar is opt-in using ?diagnostics=1; the comparison launcher
remains at /diagnostics.html. Source attribution remains visible on the app.
Package for production with `node scripts/package-ios-test.mjs --production`.
Public hosting is through Sites with Cloudflare DNS, not GitHub Pages.

## Report-driven revision

The supplied iPhone iOS 18.7 reports show sample mode reaching Ready at 568ms,
and full mode first observing context loss at 1451ms in OrbitManager.allocateBuffer.
The old startup loop reserves a 4096-byte orbit buffer for every object slot
(roughly 130 MiB for 33,373 slots, excluding GPU object/driver overhead).
This identifies a catalogue-dependent allocation burst, but does not distinguish
byte exhaustion from GPU-object-count or driver limits.

Build 02 enables isLazyOrbitBuffers for this test profile. It retains all catalogue
slots and existing orbit calculations while allocating an object's GPU buffer only
when an actual worker/variable-length path is uploaded. Unused paths have no GPU
object or storage. Catalogue swaps release lazy buffers. Legacy eager allocation
remains the default outside the test profile. Reports now identify ios-test-2 and
record orbit-buffer startup slot and allocation counts. iPhone retesting is required.

Independent test fork, modified 2026-11-13. Not an official KeepTrack deployment.
Base commit: 9c9f2611429bddda08e70980e8da89d757ba8dd5 (v13.15.0).
Toolkit submodule: 7ad319f7a020b233913f65b3ebf7480c219c6935.
Original code copyright Kruczek Labs LLC, AGPL-3.0. Original attribution is retained.

## Purpose and changes

Investigate startup WebGL context loss on a physical iPhone. This is an experiment,
not a verified fix. Native device testing is required to identify the cause.

- New ios-test OSS build profile, with the original application interface.
- 0.75 CSS-pixel backing-store scale, antialias off, low-power GPU preference,
  preserveDrawingBuffer off, 30 FPS target and 512-pixel Earth maps.
- Skip Moon GPU initialization and post-processing shader initialization.
- Disable planets, skybox, clouds, specular/bump maps, political boundaries,
  atmosphere and aurora by default. Optional comparison toggles reload the app.
- Reduce spare analyst/missile/debris buffer allocations. No changes to orbit math.
- Reapply the diagnostic graphics category after mobile defaults run; otherwise
  startup can silently re-enable 4k maps and effects. Retain original mobile UI.
- This build omits scenario fixtures and spacecraft meshes. Larger day/night
  texture URLs serve the corresponding 512px maps where available.
- Sample mode uses 100 real records including the ISS; full mode includes all
  33,337 objects in the upstream bundled offline catalogue. Neither is live data.
- No telemetry, sound, service worker, onboarding or stored quality overrides.
- A bounded ring of GPU allocation/compile calls records the earliest observed
  context loss, browser/canvas details and errors. Reports remain browser-local.
  Reported operation is the first observed loss, not proof of root cause.
- Export report remains available over the loading/error screen. Launcher can
  recover the previous locally saved report after a reload. No automatic uploads.
- Context restoration is reported; this test makes no claim to fully reconstruct
  the renderer after restoration. Restart the test after exporting a loss report.

## Reproduce

Use Node >=24 and pnpm 10.33.0. Clone the public upstream repository and check out
the base commit above. Initialize only the public src/engine/ootk submodule.
Extract source-code.tar.gz over the checkout to install the modified sources and
test files. Public artwork comes from that pinned upstream checkout; no Pro code
or private API credentials are needed.

The hosting source repository excludes the large public textures/meshes/scenario
directories to stay below its per-push limit. If rebuilding from that checkout,
run `node scripts/restore-ios-test-assets.mjs` first to restore them from the
same immutable upstream commit. A clone of upstream already has those assets.

```sh
git clone https://github.com/thkruz/keeptrack.space.git
cd keeptrack.space
git checkout 9c9f2611429bddda08e70980e8da89d757ba8dd5
git submodule update --init src/engine/ootk
# Extract the downloaded source-code.tar.gz here, overwriting source files.
npx --yes pnpm@10.33.0 install --frozen-lockfile
node --import tsx scripts/plugin/index.ts sync --skip-locales
node --import tsx build/generate-translation.ts
node --import tsx build/build-manager.ts production --profile=ios-test --skip-locales
node scripts/package-ios-test.mjs
python3 -m http.server 5544 --directory dist
```

Open http://localhost:5544. To test on an iPhone, deploy dist to HTTPS hosting and
start with sample mode and all comparison toggles off. Export the report for
success or failure, then compare one feature at a time. Do not use old snapshot
positions for present-day pass predictions.
