Skip to content

Bugfix/display stream hang#1728

Merged
doronz88 merged 3 commits into
masterfrom
bugfix/display-stream-hang
Jun 16, 2026
Merged

Bugfix/display stream hang#1728
doronz88 merged 3 commits into
masterfrom
bugfix/display-stream-hang

Conversation

@doronz88

Copy link
Copy Markdown
Owner

No description provided.

doronz88 added 3 commits June 16, 2026 09:47
Device-side syslog (captured via `pymobiledevice3 syslog live`) showed
the failure mode: when iOS's idle timer dims the display, the
CoreDevice host de-registers its listeners --

  SpringBoard ... ActiveOn->Dimmed: "idle timer"(Idle)
  remoted ERROR: No listener for "com.apple.coredevice.displayservice"
  remoted ERROR: No listener for "com.apple.coredevice.screencaptureservice"

-- so svc.connect() and svc.stop_media_stream() hang on the RemoteXPC
response. The stall watchdog tried to recover by restarting the stream
but the cleanup path took _stream_lock and never released it, leaving
/codec and /stream.bin replying 503 forever.

Three changes:

1. Hold a PreventUserIdleSystemSleep IOPMAssertion via assertion_agent
   for the lifetime of serve(); renew every 2 minutes well under the
   5-minute timeout. This is the actual root-cause fix -- the device
   stops idle-locking, so the listeners stay registered.

2. Bound every device-side RPC in _stop_active_stream / _stop_audio_stream
   with asyncio.wait_for(..., timeout=2.0). The shutdown path already
   wrapped these for the same reason; the watchdog/runtime paths now
   match.

3. Wrap the watchdog's _ensure_fresh_stream(force=True) in a 10 s
   outer wait_for as a safety net covering the start side
   (connect / start_video_stream) too.
FPS shows the frame-delta over the previous 1 s so a stall reads as
"0.0 fps" instantly, while the status panel's `frames: N` counter
keeps the cumulative total.

The bottom-left status panel is intentionally compact (white-space:pre,
overflow:hidden) and was cutting long error messages mid-line. Mirror
log() into console.log('[serve-web]', msg) so the full text is always
recoverable from devtools without giving up the compact on-page UI.
@doronz88 doronz88 merged commit b3e3c4e into master Jun 16, 2026
17 checks passed
@doronz88 doronz88 deleted the bugfix/display-stream-hang branch June 16, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant