From b36167cf473873673c7a98aaea9715c459a445a4 Mon Sep 17 00:00:00 2001 From: PJ Date: Thu, 23 Apr 2026 16:34:32 +0700 Subject: [PATCH] fix(sdk-ios): check semaphore wait result and throw on snapshot timeout dispatch_semaphore_wait returns nonzero on timeout; ignoring the return value caused pauseAndSnapshot to silently return an empty map, sending a garbage empty STATE frame to the host. Now throws so the agent loop reconnects instead. --- .../src/iosMain/kotlin/app/folio/sanderling/IosPauser.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/folio/composeApp/src/iosMain/kotlin/app/folio/sanderling/IosPauser.kt b/examples/folio/composeApp/src/iosMain/kotlin/app/folio/sanderling/IosPauser.kt index e680427..e9220cd 100644 --- a/examples/folio/composeApp/src/iosMain/kotlin/app/folio/sanderling/IosPauser.kt +++ b/examples/folio/composeApp/src/iosMain/kotlin/app/folio/sanderling/IosPauser.kt @@ -15,7 +15,8 @@ internal object IosPauser { dispatch_semaphore_signal(snapshotReady) dispatch_semaphore_wait(resumeGate, dispatch_time(DISPATCH_TIME_NOW, 5_000_000_000L)) } - dispatch_semaphore_wait(snapshotReady, dispatch_time(DISPATCH_TIME_NOW, 5_000_000_000L)) + val waited = dispatch_semaphore_wait(snapshotReady, dispatch_time(DISPATCH_TIME_NOW, 5_000_000_000L)) + check(waited == 0L) { "snapshot timed out: main thread did not signal within 5s" } return capturedSnapshot }