Skip to content

Leased iOS simulators share the Mac clipboard through Xcode 27's DeviceHub #1433

Closed

Description

@Shaance

What happens. On Xcode 27.2 (27B52), DeviceHub (com.apple.dt.Devices) syncs the Mac pasteboard with every booted simulator by default. Two agents holding separate simlock leases therefore share one clipboard. In our parallel UI gate, a link one lane's test copied reached another lane's app and replaced a search field with a paste prompt, failing an unrelated test. Test runs also overwrite the user's Mac clipboard.

The old com.apple.iphonesimulator PasteboardAutomaticSync default has no effect under DeviceHub.

Per-device switch that works. DeviceHub reads a per-device preference:

defaults write ~/Library/Containers/com.apple.dt.Devices/Data/Library/Preferences/com.apple.dt.Devices.plist \
  DevicePreferences -dict-add <UDID> '<dict><key>pasteboardSyncEnabled</key><false/></dict>'

DeviceHub reads it when the device boots or when its name changes. For a device that is already booted, renaming it and restoring the name about 0.8 s later applies the setting.

Proof on a leased device. After the write and the rename refresh, a marker string copied on the Mac did not appear in the leased simulator's pasteboard. Before the change it did. We did not re-test the device-to-Mac direction.

Prior art. WebKit passes the same per-device dictionary as a launch argument (WebKit PR 78474, Tools/Scripts/webkitpy/xcode/simulated_device.py). appium/appium-ios PR 26 uses the rename refresh.

Request. Could simlock apply this switch when it grants an iOS lease, ideally before boot so no refresh is needed, and remove the device's DevicePreferences entry when it deletes the device? Today we do it in a lease wrapper, and stale per-UDID entries pile up in DeviceHub's plist because the wrapper never sees the device deleted.

Activity

  1. added
    bug:new
    on Nov 7, 2026
  2. self-assigned this
    on Nov 7, 2026
  3. V3RON commented on Nov 7, 2026

    @V3RON
    Contributor

    This was generated by AI during triage.

    Reproduction

    The missing pre-boot write is reproduced. This is a proposed acceptance test for a gap, not a re-test of DeviceHub clipboard traffic.

    src/drivers/ios/pasteboard-preferences.test.ts: “requests pasteboard sync disabled before boot for full-mode preparation and recovery”. Both UDIDs fail the named “DeviceHub preference write before boot” assertion.

    Base: fc5ac8c3e1d670689cb4eb14396850e7af691ccb (origin/main)
    pnpm exec vitest run --project unit src/drivers/ios/pasteboard-preferences.test.ts
    Expected: defaults write … DevicePreferences -dict-add <UDID>
              '<dict><key>pasteboardSyncEnabled</key><false/></dict>'
    Received at boot: []
    

    Repro: bug/1433-repro, d3b86ae80d143050c94fbbc71a6528b0de933a2f. Only the test is pushed.

    Root cause

    Gap: src/drivers/ios/index.ts:1169 boots in makeReady without configuring DeviceHub; :1205 invokes simctl boot directly. destroy (:1385–1389) removes the simulator and launchd overrides, but no DeviceHub entry. Neither lifecycle path manages pasteboard preferences. The reporter’s host-to-device proof stands; device-to-host isolation remains unverified.

    Simplest fix

    Set DevicePreferences.<UDID>.pasteboardSyncEnabled=false before a managed clone’s first boot and recovery boot; remove only that UDID after successful deletion. Preserve unrelated preferences. Handle already-booted devices explicitly.

    A temporary bounded defaults write before makeReady boot passed the reproduction. The same run passed 251 adjacent tests but failed one strict fake-runner expectation on the new call. Cleanup was not trialled. The prototype was removed; adjacent tests then passed (251, one existing skip), and the reproduction failed again.

    Alternatives rejected

    • Global clipboard defaults: affect the user and unrelated simulators.
    • Rename every new clone: unnecessary when configured before boot.

    Risk

    • Shared-plist concurrency, existing per-device keys, preference caching and deletion failures.
    • Already-booted devices need refresh; the test covers cold boot calls only.
    • Verify both clipboard directions on Xcode 27.2 through the maintainer’s hardware lane; none was run here.

    Fast track

    • Defect: no — missing isolation behavior
    • Fix tried: no — incomplete prototype; adjacent expectation failed
    • Nothing public added or broken: no — existing automatic clipboard syncing changes
    • No ADR or rule changed: yes
    • One fix: no — refresh and failure policies remain unsettled

    Written by an agent.

  4. removed their assignment
    on Nov 7, 2026
  5. added a commit that references this issue on Nov 7, 2026
  6. V3RON commented on Nov 7, 2026

    @V3RON
    Contributor

    Supersedes the report above.

    Reproduction

    This is a gap, so the test's expectation is a proposal. Branch bug/1433-repro (6e3ad6f). This test replaces pasteboard-preferences.test.ts, which checked the boot write only and not the removal.

    src/drivers/ios/index.test.ts, "under deviceSet default the driver turns DeviceHub's pasteboard sync off for a simulator before every boot and removes that entry when it destroys it". It runs a prepare, a recovery boot and a destroy.

    pnpm exec vitest run --project unit src/drivers/ios/index.test.ts -t "pasteboard sync"
    AssertionError: expected [ [ 'xcrun', 'simctl', …(2) ], …(7) ] to deeply equal [ Array(11) ]
    - "defaults" "write" ".../Containers/com.apple.dt.Devices/Data/Library/Preferences/com.apple.dt.Devices.plist"
    -   "DevicePreferences" "-dict-add" <udid> "<dict><key>pasteboardSyncEnabled</key><false/></dict>"   (missing before each boot)
    - "/usr/libexec/PlistBuddy" "-c" "Delete :DevicePreferences:<udid>" <same plist>                      (missing after simctl delete)
    

    Root cause

    Gap. makeReady (src/drivers/ios/index.ts:1169) boots with no DeviceHub setting, and destroy (:1385-1389) removes only the simulator and its launchd overrides. Nothing in Simlock tells DeviceHub to keep a lease's simulator off the Mac pasteboard. This matters only under drivers.ios.deviceSet: default: DeviceHub does not see the simlock set (src/drivers/ios/AGENTS.md, "the simlock set has no DeviceHub").

    Simplest fix

    Under default only (#rootOptions === undefined), do two things:

    • Before #bootAndWait in makeReady, run the defaults write call above. The plist path is derived from coreSimulatorRoot (../../Containers/...).
    • After simctl delete, run the PlistBuddy delete.

    If either call fails, log a warning, as the boot extras do.

    Tried: the fix above, plus the new calls added to the call scripts of the
    default-set argv test and the boot-courtesies tests.
    pnpm exec vitest run --project unit src/drivers/ios/   ->  716 passed, 1 skipped
    Then discarded.
    

    Alternatives rejected

    • A config key to keep the sync on: more surface, and nobody has asked for it.
    • The rename refresh after boot: not needed when the entry is written before boot.
    • The global PasteboardAutomaticSync default: DeviceHub ignores it (per the reporter).

    Risk

    • I could not read DeviceHub's container: ls on the plist hung for over 120 s, likely a macOS app-data prompt. Check that the launchd daemon's defaults and PlistBuddy calls work without one.
    • PlistBuddy bypasses cfprefsd. While DeviceHub runs, its cached copy may write the removed entry back.
    • Not checked on hardware: device-to-Mac sync, and Xcode 27.2.

    Fast track

    • Defect: no — gap: nothing turns DeviceHub's sync off
    • Fix tried: yes
    • Nothing public added or broken: no — simulators under deviceSet default stop sharing the Mac clipboard
    • No ADR or rule changed: yes
    • One fix: no — a config key to keep the sync on would change what users see

    Written by an agent.

  7. V3RON commented on Nov 8, 2026

    @V3RON
    Contributor

    This was generated by AI during triage.

    Decision

    The maintainer approved these requirements, overriding the latest report's warning-and-continue policy and extending its boot-only acceptance test:

    • Always disable Mac clipboard sync for Simlock-managed simulators in Xcode's default device set. No opt-out config key.
    • Ensure isolation before every new grant, including already-booted warm devices. Refuse the grant if isolation cannot be established. Do not interrupt active leases to apply the change.
    • Configure isolation before preparation and recovery boots. Establish a reliable refresh or reboot path where an already-booted device needs it.
    • After successful simulator deletion, remove only its preference entry, preserving unrelated settings. Report cleanup failure without undoing successful deletion or blocking future grants. If simulator deletion fails, keep its isolation preference.
    • Extend the reproduction to cover refusal on isolation failure, warm devices, and cleanup success/failure. Verify both clipboard directions and cleanup with DeviceHub running on Xcode 27.2 through the slow lane before merge.
    • Update public docs and the module manual, including the upgrade limitation for active leases.

    Approved for implementation as bug:ready; hardware verification remains part of delivery.

    Written by an agent.

  8. added
    bug:ready
    and removed
    bug:new
    on Nov 8, 2026
  9. self-assigned this
    on Nov 8, 2026
  10. 6 remaining items

  11. V3RON commented on Nov 8, 2026

    @V3RON
    Contributor

    Handoff

    Done

    Implemented isolation before default-set iOS grants and boots, failure refusal, preference preservation and deletion cleanup. Public docs and manuals updated. PR #1446 is ready and labelled needs-hardware. All six review findings verified fixed; final reviewed head f47cc59c677b61b0847c23e7fbbe7790f7b1cbd3. Targeted tests, website/OpenAPI and hooks passed; review-ledger/body validation passed.

    Not done

    Verify both clipboard directions and cleanup with DeviceHub running on Xcode 27.2 through e2e/slow-ios-window.test.ts, including its hardware mutation probe; then merge through the gate.

    Findings

    Hardware tests did not run. Selected Xcode is 27.1; DeviceHub is not running. CI remains subject to the gate.

    Blocked on

    Xcode 27.2 and a free slow lane; worker PID 89138 holds /Users/aitwar/.simlock. Rerun delivery on an eligible host.

    Written by an agent.

  12. added
    bug:blocked
    and removed
    bug:ready
    on Nov 8, 2026
  13. removed their assignment
    on Nov 8, 2026
  14. V3RON commented on Nov 8, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: none
    Parked: #1433 — PR #1446 needs Xcode 27.2 and a free slow lane for clipboard and cleanup verification.
    Waiting: none
    Decided: none

    Written by an agent.

  15. V3RON commented on Nov 8, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: #1446 (#1433)
    Parked: none
    Waiting: none
    Decided: #1433 — R7 defaults import lost-update window → accepted as nonblocking by the maintainer

    Written by an agent.

  16. removed
    bug:blocked
    on Nov 8, 2026
  17. added a commit that references this issue on Nov 10, 2026
    617b79d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions