Skip to content

fix(ios): add opt-in fallback for stalled writes without response - #506

Open
MoeHero wants to merge 1 commit into
deviceplug:masterfrom
ServeUOfficial:master
Open

MoeHero wants to merge 1 commit into
deviceplug:masterfrom
ServeUOfficial:master

Conversation

@MoeHero

@MoeHero MoeHero commented Oct 23, 2026

Copy link
Copy Markdown

Problem

On iOS, write-without-response readiness callbacks may stop arriving after an app enters the background. Pending writes then remain queued while waiting for readiness, potentially stalling communication.

Related Apple discussion:
https://developer.apple.com/forums/thread/765444

Changes

Add an opt-in ios-write-without-response-fallback Cargo feature, disabled by default.

When enabled on iOS:

  • Attempt a queued write once 30 ms has elapsed since the previous submission if readiness is still unavailable.
  • Count idle time toward the interval instead of delaying every new request.
  • Preserve FIFO ordering and the normal readiness callback path.
  • Discard queued writes whose caller has cancelled or whose peripheral has disconnected.
  • Wake the event loop for pending fallback writes without blocking notification or disconnect handling.

Timeout and message-expiration policies remain the application's responsibility. Other platforms and writes with a response retain their existing behavior.

Trade-offs

This is a best-effort compatibility workaround. Attempting a write while readiness is false may lose data if the controller buffer is actually full. Applications must explicitly enable the feature and validate it with their peripherals.

The feature does not provide background execution or guarantee delivery.

Validation

  • Default configuration: 72 library tests passed.
  • Feature enabled: 75 library tests passed.
  • Both configurations retain 4 existing hardware-dependent test skips.
  • iOS library compilation checks passed with the feature enabled and disabled.
  • Added 3 focused tests covering bounded initial waiting, paced queued writes, and idle-time accounting.

… feature

- Introduce ios-write-without-response-fallback Cargo feature for iOS background write readiness workaround
- Implement WriteGate policy to pace queued writes when readiness callbacks are missing
- Support future cancellation and automatic retry timing in the internal message loop
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