Skip to content

Retain output slot registration until disconnect succeeds - #130

Merged
hbashton merged 1 commit into
hbashton:mainfrom
meiameiameia:fix/retain-output-slot-on-removal-failure
Oct 9, 2026
Merged

hbashton merged 1 commit into
hbashton:mainfrom
meiameiameia:fix/retain-output-slot-on-removal-failure

Conversation

@meiameiameia

Copy link
Copy Markdown
Contributor

DeferredRemoval clears the output array and both lookup maps before removing feedback and disconnecting. If either operation throws, the attached slot loses its registration and cannot be retried through the normal lookup. Bulk shutdown also clears the array before disconnecting and can leave stale maps after a partial failure.

Keep the exact registration until teardown returns successfully, then detach the slot and publish its removal. During bulk shutdown, remove each successful output from both maps immediately so a failed later disconnect leaves only the remaining output registered for retry.

Synthetic regression tests cover feedback/disconnect exceptions for bound and unbound outputs, another output connecting after a failure, retries, repeated removal, event publication, partial shutdown and permanent slot preferences. No virtual device or driver is created by these tests.

Validation on Windows, .NET SDK 8.0.425, Release x64:

  • All 6 cases in OutputSlotRemovalTests passed as part of the combined validation run.
  • 136 related tests passed with both proposed fixes present, including existing atomic binding, Switch 2 output ownership and VIIPER haptics negotiation tests.
  • The patch applies independently to upstream commit 36502408cbba17fd20d84e6b258f2258714a39c6.

This covers failures propagated by the output implementation. It does not establish physical removal or address errors swallowed by a backend. Hardware validation has not been performed.

Related work: #70 changes these disconnect call sites to detach native PnP ownership. Its current patch does not defer manager registration removal; these call sites may need reconciliation if that PR lands first.

Focused check:

dotnet test DS4WindowsTests/DS4WindowsTests.csproj -c Release -p:Platform=x64 --filter 'FullyQualifiedName~OutputSlotRemovalTests|FullyQualifiedName~OutputSlotAtomicBindingTests'

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.

2 participants