iOS copy: keep the app database at the copy's own UDID

Đang mở
#2,077 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@V3RON đang làm issue này rồi.

Từ ngày 3/12/2026.

  • #2084 của @V3RON — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

platform:ios task:ready

Part of #2070.

Scope

After this PR an iOS simulator no longer rebuilds its app database when a lease boots it. Seeds, settled seeds and baselines keep the database, and each copy has it rewritten for its own UDID before the first boot. The copy itself is still made with simctl clone.

If this goes wrong, a lease's simulator misses an app or opens one the wrong way, or leases stay as slow as before.

Technical spec

Commit 4d3c176fb.

Rows
  • Behaviours: B1, B2, B3, B4, B5, B6, B11
  • Stored state: S1, S2, S3
  • Interfaces: I1
  • Existing code: X1, X2, X3, X4, X5, X6, X7, X8, X17, X18, X14
Facts
# Fact Source
F1 A lease's grant holds the simulator's UDID in device.driverDeviceId and the device set in environment.SIMLOCK_IOS_DEVICE_SET. On a worker in Xcode's own set the grant's environment is empty, and the set's folder is ~/Library/Developer/CoreSimulator/Devices. e2e/slow-baseline.test.ts:48 to :53; src/drivers/ios/index.ts:607
F2 The sources set is <device set>/sources, or <home>/devices/ios-sources under Xcode's own set. e2e/slow-baseline.test.ts:76
F3 e2e/slow-baseline.test.ts installs and launches an app before the save, and on a lease from the baseline checks that get_app_container answers a path under the copy's UDID and that the app launches. e2e/slow-baseline.test.ts:59, :136 to :147
F4 lsdiagnose run inside a booted simulator exits 0 and prints a gzip stream, not text. Unpacked it is about 368 MB: a csviz header, then property lists as XML text. One "string" of the comparison is the content of one <string> element; each dump of the measurement held 28,784 distinct ones. xcrun simctl --set <set> spawn <udid> lsdiagnose > kept-1-lsdiagnose.bin, then file kept-1-lsdiagnose.bin printed gzip compressed data, max compression, original size modulo 2^32 368287091; gzip -dc kept-1-lsdiagnose.bin | head -c 400 | strings printed csviz0jgtm and <plist version="1.0"> (2026-12-03, iOS 27.2)
F5 A filesystem fake that fails chosen writes exists. src/drivers/ios/test-slim.ts:152 FaultyFilesystem
F6 simlock lease takes --mode <slim|full>. src/cli/commands/lease.ts:97
F7 A slow-lane test reads a line of the driver's log, debug level included, from the daemon log file (env.logPath). e2e/slow-ios-source-isolation.test.ts:120 to :130
F8 The iOS driver's manual is 7,991 characters and a repository test caps a manual at 8,000, so a line added to it needs another one shortened. wc -c src/drivers/ios/AGENTS.md printed 7991; src/docs-manuals.repo.test.ts:10
F9 A slow-lane test sets a worker up in Xcode's own device set with drivers: { ios: { deviceSet: "default" } }, and another lists the installed iOS runtimes. e2e/slow-ios-window.test.ts:60; e2e/slow-ios-os-range.test.ts:11
Modules touched

drivers/ios: seeds.ts, source-data.ts, new app-database.ts, index.ts (makeReady), testing.ts, test-index.ts, the four test files of X8, AGENTS.md. e2e: new e2e/slow-ios-app-database.test.ts, e2e/slow-baseline.test.ts, e2e/slow-ios-smoke.test.ts (a comment). Searches: rg -n "dropLaunchServicesDatabase|LAUNCH_SERVICES" src/drivers/ios, rg -n "seedIsStale|findReadySeed|markReady|promoteSettled" src/drivers/ios, rg -n "plantSource|seededDatabase" src.

Rules in play
  • ADR 0104 §1, §2, §4 and §5 (Accepted — not yet implemented): the parent's rows hold the shapes.
  • ADR 0076 §3: the swap stays byte for byte and keeps each file's length; the app database joins the files it covers.
  • ADR 0061 §2, as narrowed by ADR 0104: a database that does not fit the rule is still deleted before the copy's first boot.
  • ADR 0036 §2: only IosSourceTable reads or writes ios_source_data; S1 is one more migration step of its owner.
  • Safety rule 1: the seed that B6 makes again is destroyed through its row, as a stale seed is today.
  • src/ports/AGENTS.md: no fs import in the driver; the file is read and written through the Filesystem port. crc32 of node:zlib is a computation, as in src/drivers/android/sdk-device-definitions.ts:2.
Tests

Seam: the iOS driver built by createDriver (src/drivers/ios/test-index.ts:217); model the cases on src/drivers/ios/index-seed-swap.test.ts.

  • B1: Core provisions a copy of a source that recorded its app database, and the database fits I1. Before the boot the copy's database is still there, holds the copy's UDID wherever a lineage UDID stood, has its old length, and its stored checksum is the one I1 gives for its new bytes.: lineage of one UDID; lineage of two UDIDs, both in the file; a UDID stored as UTF-16; a database longer than 1,048,576 bytes with a UDID across that boundary; a body whose CRC's low 16 bits are 0, 1 or 2
  • B2: Core provisions a copy whose database cannot be kept. The database is deleted before the boot and the provision succeeds. The first time for a source in a daemon run, the log gets one warn line: app database of source <sourceId> is not kept (<reason>); its copies rebuild it at boot.: reason unknown format: the stored checksum is not the computed one; bytes 0 to 3 are not bdsl; the file is shorter than 100 bytes; the recorded length is under 100 or over the file's size; the stored checksum is 0, 1 or 2. Reason not recorded by its source: the source's files do not list it; they list it as unreadable. No line and nothing deleted: the copy has no database file. A second provision from the same source: no second line.
  • B3: A step on the copy fails after the copy was made: the copy is deleted with simctl delete and the provision throws that step's error, as today.: the swap throws; the checksum cannot be read or written; the delete of a database that cannot be kept throws
  • B4: An operator saves a baseline from a lease. The baseline's simulator keeps its app database, and the source's recorded files list it when it holds a lineage UDID. A lease from that baseline then meets B1.: the lease's simulator has a database; it has none (nothing recorded, the save succeeds)
  • B5: Core settles a quick seed. The settled seed keeps its app database and records it. The settle's own copy is made as B1 or B2.: the settle's copy has a database; it has none
  • B6: Core provisions a kind whose ready seed is settled and was saved before S1 existed. The seed is destroyed and made again as a quick seed, and the copy is made from the new one.: settled, S1 null: made again; settled, S1 = 1: copied; quick, S1 null: copied, not made again; a baseline, S1 null: copied, not stale
  • B11: Core boots a simulator for a lease (makeReady with purpose prepare; a recovery boot is not checked, because only first boots were measured). The driver reads the identity of each app database file before the boot and again after the boot succeeded. When a file that was there before is gone or has another identity, the simulator rebuilt it, and the first time for a runtime in a daemon run the log gets one warn line: the simulator rebuilt the app database of <udid> (<runtimeId>); a boot on this runtime takes as long as before. The boot's result never changes.: same identity: no line; another identity: the line; a recovery boot: nothing read, no line; the file gone after the boot: the line; no database before the boot (B2 deleted it): no line; a second simulator of the same runtime: no second line; stat throws before or after the boot: no line, the boot succeeds. Slow lane: a B11 line on a lease does not fail e2e/slow-ios-app-database.test.ts; the test prints it, and its checksum case fails only when three leases in a row logged it (decided in delivery, pending the maintainer)

Done when

  • Every unit case of B1 to B6 and B11 passes.
  • Slow lane (real simulator): e2e/slow-ios-app-database.test.ts leases an iPhone, finds that in every path simctl listapps prints under the device set's folder the folder right after it is the lease's own UDID (a system app's bundle path is in the runtime's folder, outside the set; a deleted throwaway's UDID there is a failure), and finds no B2 line in the daemon log. A B11 line for the lease is allowed and the test prints it: about one cold boot in three rebuilt the kept database in the trial runs of 2026-12-03, cause unknown (decided in delivery, pending the maintainer).
  • Slow lane (real simulator): e2e/slow-ios-app-database.test.ts makes the same check on a worker set up with drivers: { ios: { deviceSet: "default" } }, and with --os naming an older installed iOS runtime when the Mac has one beside the newest.
  • Slow lane (real simulator): e2e/slow-ios-app-database.test.ts changes the stored checksum in the ready seed's database, leases again, finds B2's line with unknown format in the daemon log, and finds that the lsdiagnose dumps of the kept and of the rebuilt simulator hold the same set of strings once each UDID, every x-csstore-vis-unit: address and every _CSbr<n> index is masked. The kept side is a lease that logged no B11 line; the test leases up to three times to get one and fails when none kept its database (decided in delivery, pending the maintainer).
  • Slow lane (real simulator): e2e/slow-ios-app-database.test.ts takes three leases with the database kept and three with it deleted, in turn, for --mode full and again for --mode slim, prints the time from request to grant of each, and for each mode the three kept leases take less time together than the three others.
  • Slow lane (real simulator): e2e/slow-baseline.test.ts passes, and the daemon log of its run has no B2 line for the baseline it saved.
  • Slow lane (real simulator): e2e/slow-ios-smoke.test.ts and e2e/slow-ios-source-isolation.test.ts pass.
  • The PR description holds the printed times of one slow-lane run, as the measurement #2040 asked for.

Out of scope

The copy step (simctl create and the one-call clone, the next task). The log folder a leased simulator leaves in ~/Library/Logs/CoreSimulator. Push notifications, which no run tested.

Depends on

None. Issue 2043 (PR 2058) also changes makeReady in src/drivers/ios/index.ts, where B11 adds its check. The maintainer decided on 2026-12-03 that this task does not wait for it: whichever of the two lands second resolves the conflict.

Written by an agent.

Ngôn ngữ chính
TypeScript
Star
730
Fork
44
Merge trung bình
15 giờ 28 phút
Pull request đã merge (30 ngày)
387

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của callstackincubator/simlock

Tất cả issue của callstackincubator/simlock

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.