Skip to content

fix a throwing availability handler ending the process - #2

Merged
trypsynth merged 1 commit into
trypsynth:masterfrom
Oire:catch-availability-handler-exceptions
Nov 12, 2026
Merged

trypsynth merged 1 commit into
trypsynth:masterfrom
Oire:catch-availability-handler-exceptions

Conversation

@Menelion

Copy link
Copy Markdown
Contributor

An exception thrown by an AvailabilityChanged or AvailabilityBaselineEstablished handler escapes OnAvailabilityChanged or OnAvailabilityBaseline. Those are UnmanagedCallersOnly methods called on prism's poll thread, so the runtime ends the whole process instead of the exception reaching anyone.

This wraps both callbacks the way PrismLog.Deliver and Backend.DeliverAudio already handle theirs: the handler's exception is dropped and polling carries on. The PrismOptions docs for both handlers now say so.

AvailabilityTests.KeepsPollingWhenHandlersThrow uses a custom backend that is toggled off and on, with both handlers throwing. Without the fix, the test host crashes at the baseline handler ("Test host process crashed: Unhandled exception. System.InvalidOperationException: A failing baseline handler."). With it, both changes are still reported. All 57 tests pass on win-x64, and dotnet format --verify-no-changes is clean.

An exception that leaves an UnmanagedCallersOnly method cannot cross back into prism, so the runtime ends the process. The availability and baseline callbacks now drop a handler's exception, as the log and audio callbacks already do, and polling carries on.
@trypsynth
trypsynth merged commit 4558134 into trypsynth:master Nov 12, 2026
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