fix(ios): rebuild audio only when needed and stop VoiceOver list churn
Build and test / test (macos-latest) (push) Waiting to run
Build and test / test (ubuntu-24.04) (push) Waiting to run
Build and test / test (windows-latest) (push) Waiting to run
Build and test / apple-client (push) Waiting to run

Two iOS bugs with the same shape: unconditional rebuilds where a
conditional check belongs.

The audio graph was torn down on every unintentional disconnect and every
foreground transition. A lost connection ran the same teardown as an
explicit disconnect, deactivating the AVAudioSession and so dropping the
Bluetooth HFP link for a transport blip, and foregrounding always called
Reconfigure even though the `audio` background mode keeps the graph live.
Both cost seconds of dead audio on a headset.

Split "session ended" from "transport blipped". Detach unbinds the client
but keeps the session, graph, and route, so a reconnect rebinds to a live
HFP link; the route is parked on stream id 0 so capture cannot feed the
next connection a stream it never announced. StartListening reuses a
running graph, StartMicrophone reuses a running tap of the same width, and
Reconfigure gained a non-forcing mode that no-ops when tap presence,
channel width, and voice processing all still match. Foregrounding now
ensures the graph is running and only reconfigures if it actually stopped.
Route changes, media-services resets, and the stall watchdog still force a
full rebuild.

Every list also reloaded on a model event raised 20 times a second by the
microphone level timer. ReloadData recreates the accessibility element
tree, so VoiceOver explore mode re-announced the row under a dragging
finger and a double tap landed on an element that no longer existed. No
controller ever unsubscribed, so popped controllers kept reloading too.

Move the level to its own LevelChanged event, and reload lists through
ListRefresher, which subscribes only while on screen and only reloads when
the rendered content signature changed. The voice bar publishes its
accessibility value on 5% steps, MoveUserController reloads just its two
checkmark rows, and the chat transcripts skip reassigning identical text.

The changed logic sits on UIKit and AVFoundation types the net10.0 test
project cannot reference, so this carries no tests; the Bluetooth
reconnect and foreground paths need device verification.
This commit is contained in:
2026-09-25 17:00:25 +02:00
parent 724f7e912d
commit 0b81b81c0c
9 changed files with 273 additions and 45 deletions
+13 -4
View File
@@ -240,13 +240,13 @@ internal sealed class IosAudioRouter
catch (Exception exception) { System.Diagnostics.Debug.WriteLine($"Audio recovery ({reason}) failed: {exception}"); }
}
internal void Recover(string reason)
internal void Recover(string reason, bool force = true)
{
RefreshRoutes();
if (!IosAudioEngine.Shared.IsConnected || interrupted) return;
UIApplication.SharedApplication.BeginInvokeOnMainThread(() =>
{
try { IosAudioEngine.Shared.Reconfigure(); }
try { IosAudioEngine.Shared.Reconfigure(force); }
catch (Exception exception) { System.Diagnostics.Debug.WriteLine($"Audio recovery ({reason}) failed: {exception}"); }
});
}
@@ -262,8 +262,17 @@ internal sealed class IosAudioRouter
private void ResetWatchdog() { lastRenderCallbacks = -1; watchdogMisses = 0; }
// An interruption that ends while the app is suspended never delivers its Ended notification.
internal void ResumeForeground() { interrupted = false; ResetWatchdog(); Recover("foreground"); }
// An interruption that ends while the app is suspended never delivers its Ended notification,
// so foregrounding still has to check. It must not rebuild unconditionally though: the `audio`
// background mode keeps the session and graph live across a backgrounding, so the graph is
// almost always healthy here and a rebuild costs a visible glitch plus, on Bluetooth, an HFP
// renegotiation. Ensure it is running, and only reconfigure when it actually stopped.
internal void ResumeForeground()
{
interrupted = false; ResetWatchdog(); RefreshRoutes();
if (IosAudioEngine.Shared.IsConnected && !IosAudioEngine.Shared.IsRunning) Recover("foreground");
else EnsureAudio("foreground");
}
private void TickWatchdog()
{