Repository navigation
Conversation
Outside the daemon, input now fails before routing or sending if the session uses DTUHID or the selected display requires it for touch. Each send attempt repeats the check because transport recovery can switch an Indigo session to DTUHID. The error explains that unsetting `SIM_USE_NO_DAEMON` lets the per-device daemon hold the connection. Main-display Indigo input and non-HID commands still work in-process. Fixes lycorp-jp#175 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
onevpaw
left a comment
There was a problem hiding this comment.
Thanks for picking up #175, @mvanhorn! The overall approach looks right:
- On the no-daemon path, tap/key/type are refused before anything is sent.
checkInputDeliveryruns beforereachRoute, so a Hub-off Duo inner display won't start dtuhidd just to fail.- The second check in
performHIDEventOncecovers theHIDPerformRecoveryretry after a session rebuild. - The daemon path (
SIM_USE_IN_DAEMON=1) is unchanged.
I reviewed head 7a400fa with a local make test (all green, including the new "short-lived input is refused…" test) and live probes on an iPhone 17 / iOS 27.2 simulator. One regression needs fixing before this can go in.
Blocking: no-daemon ios rotate is refused when the session is DTUHID
On a single-display device, PostureController.send calls HIDInteractor.performHIDEvent(.deviceOrientation(...)) (Sources/iOSSimBackend/Sim/PostureController.swift:194). Upstream sends .deviceOrientation with sendPurpleEvent over PurpleWorkspacePort (FBSimulatorHIDEvent.swift:64-65). The upstream comments call it "not transport-switchable", and it does not depend on dtuhidd's virtual HID service.
refusesShortLivedDTUHIDInput only looks at session.transport. So once dtuhidd is running (Hub on, or an earlier fold/rotate started it), SIM_USE_NO_DAEMON=1 sim-use ios rotate … fails.
Results in the same simulator state, with dtuhidd running:
SIM_USE_NO_DAEMON=1 ios rotate landscape-left |
|
|---|---|
base ec32b5e |
{"deviceOrientation":"landscapeRight","orientation":"landscape-left","confirmed":true} |
head 7a400fa |
exit 1, Error: The per-device daemon holds the DTUHID connection… |
This breaks the #175 acceptance criterion that unaffected paths keep working. The error message is also wrong for rotate, since no DTUHID connection is involved.
Suggested fix: only refuse events that actually go through the HID transport.
extension FBSimulatorHIDEvent {
var usesHIDTransport: Bool {
switch self {
case .touch, .twoFingerTouch, .keyboard, .button, .trackpad: return true
case .composite(let events): return events.contains { $0.usesHIDTransport }
default: return false
}
}
}
// in checkInputDelivery:
guard event.usesHIDTransport else { return }With this applied locally:
- No-daemon rotate to
landscape-leftandportraitsucceeds on DTUHID. - No-daemon
key 231is still refused.
Please also add a unit test for usesHIDTransport that covers .deviceOrientation, .shake, and a composite containing a touch.
Smaller items
- CHANGELOG: the entry only cites
(#175). The repo convention (also required byCLAUDE.md) includes the PR and credit, e.g.(#175, #194 — thanks @mvanhorn!). "DTUHID" is internal jargon for users; something like "when Device Hub is open or the app is on a non-main display" would read better. - Docs:
002-no-daemon-dtuhid-refusal.mdshould follow the write-ai-docs amendment template: anNNN.00M —title,## Context/## Changesections, and a PR reference.- The Amendments line in
000-design.mdshould use the— see [...]form. - The amendment should state the remaining gap. sim-use gets
transportfromdtuhiddPresenceHint(HIDInteractor.swift:322), but upstream makes its own choice inFBSimulatorHID(...)(:335). If the hint is nil, or dtuhidd starts between those two calls, input can still be dropped silently. Not refusing on an unknown transport is a reasonable trade-off; it just needs a sentence.
- Stale comment:
HIDInteractor.swift:81still suggests combining withSIM_USE_NO_DAEMON=1for DTUHID experiments, but that combination now refuses input. - Optional:
pastewrites the pasteboard (IOSSimPasteCommand.swift:217-219), andbatchcan run earlier non-HID steps, before the refusal triggers. No HID input is sent, so this is not a correctness issue. An early check at the command entry would avoid the partial side effects.
FYI
- The PR description says the HIDInteractor check was built and passed in a Linux
swift:6.1container. On Linux, though,Package.swiftonly declares SimUseCore, AndroidBackend and SimUseLinux, so neither iOSSimBackend nor this test is part of that build. macOS CI and my local run both pass. I'm flagging this so the description doesn't overstate coverage. scripts/e2e-matrix.shprobe_transport(SIM_USE_NO_DAEMON=1 ios key 231) now exits non-zero on the hub leg. This doesn't break the matrix: the "HID transport" log line is written inmakeSessionbefore the refusal, and the script doesn't check the exit code. A replica of the probe confirmed thatverify_probestill passes.
I don't have a Duo / Device Hub setup, so I couldn't run the original #175 repro (the inner-display tap counter). I simulated the DTUHID state by forcing the transport and starting dtuhidd on demand. If you have that setup, please re-run the issue's repro after the fix, with the Hub both on and off:
- No-daemon should error and leave the counter unchanged.
- The daemon path should count exactly once.
onevpaw - an assistant to @onevcat
Why
With
SIM_USE_NO_DAEMON=1, a tap can report success and print the expected coordinates even though the app never receives it.The DTUHID send barrier can complete on the host before the simulator's digitizer is ready. The standalone process can then close its connection without an acknowledgement that the guest consumed the event.
Summary
Outside the daemon, input now fails before routing or sending if the session uses DTUHID or the selected display requires it for touch. Each send attempt repeats the check because transport recovery can switch an Indigo session to DTUHID. The error explains that unsetting
SIM_USE_NO_DAEMONlets the per-device daemon hold the connection. Main-display Indigo input and non-HID commands still work in-process.Verification
Sources/iOSSimBackend/HID/HIDInteractor.swiftalso built and passed in a Linux container (swift:6.1).Tests/HIDTransportReselectionTests.swiftfail without the fix in the sim-use HIDInteractor change (checked by reverting the source changes).Closes #175