Skip to content

Batch 2 Bugfix: IRemoteTrack.SetEnabled: dispatch EnableRemoteTrackRequest over FFI#250

Merged
MaxHeimbrock merged 2 commits into
mainfrom
max/fix-enable-remote-track-dispatch
Apr 22, 2026
Merged

Batch 2 Bugfix: IRemoteTrack.SetEnabled: dispatch EnableRemoteTrackRequest over FFI#250
MaxHeimbrock merged 2 commits into
mainfrom
max/fix-enable-remote-track-dispatch

Conversation

@MaxHeimbrock
Copy link
Copy Markdown
Contributor

Summary

`IRemoteTrack.SetEnabled` was completely non-functional:

```
System.Exception: Unknown request type: LiveKit.Proto.EnableRemoteTrackRequest
at LiveKit.Internal.FFIClients.FfiRequestExtensions.Inject[T] (...) in FfiRequestExtensions.cs:237
at LiveKit.Internal.FFIClients.Requests.FfiRequestWrap`1[T].Send () (...) in FfiRequestWrap.cs:59
at LiveKit.IRemoteTrack.SetEnabled (System.Boolean enabled) (...) in Track.cs:59
```

The proto field `EnableRemoteTrack` exists on `FfiRequest` but `FfiRequestExtensions.Inject`'s type switch had no case for `EnableRemoteTrackRequest`, so it fell through to `default` and threw. Adds the one missing case (matches the pattern used for all other request types).

Regression test

`Tests/PlayMode/RemoteTrackEnabledRegressionTests.cs` — publishes an audio track from a second room, waits for `TrackSubscribed` on the subscriber, and calls `SetEnabled(false)` / `SetEnabled(true)`. Before the fix this test throws; after, it round-trips through FFI cleanly.

To make the test runnable in batch-mode CI (no real microphone), also introduces `Tests/PlayMode/Utils/SineWaveAudioSource.cs` — an `RtcAudioSource` subclass that pushes 20ms 48kHz PCM frames from a `System.Threading.Timer`, avoiding Unity's audio subsystem. Same utility is also part of an in-flight coverage expansion branch (`max/more-tests/batch-2`); merging either first is fine, content is identical.

Test plan

  • `./Scripts~/run_unity.sh test -m PlayMode -f LiveKit.PlayModeTests.RemoteTrackEnabledRegressionTests -n 5` → 5/5 iterations pass

🤖 Generated with Claude Code

EnableRemoteTrackRequest was missing from FfiRequestExtensions.Inject's
type switch, so every call to IRemoteTrack.SetEnabled threw
"Unknown request type: LiveKit.Proto.EnableRemoteTrackRequest" and never
reached the native layer. The proto field exists on FfiRequest, just
nothing was injecting into it.

Adds the one missing case alongside LocalTrackMuteRequest and includes a
PlayMode regression test using a new test-only SineWaveAudioSource (which
pushes 20ms PCM frames via a timer, avoiding Unity's audio subsystem so
it runs cleanly in batch-mode CI).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MaxHeimbrock MaxHeimbrock changed the title Fix IRemoteTrack.SetEnabled: dispatch EnableRemoteTrackRequest over FFI Batch 2 Bugfix: IRemoteTrack.SetEnabled: dispatch EnableRemoteTrackRequest over FFI Apr 20, 2026
@MaxHeimbrock MaxHeimbrock requested a review from ladvoc April 21, 2026 14:38
case LocalTrackMuteRequest localTrackMuteRequest:
ffiRequest.LocalTrackMute = localTrackMuteRequest;
break;
case EnableRemoteTrackRequest enableRemoteTrackRequest:
Copy link
Copy Markdown
Contributor

@ladvoc ladvoc Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment (non-blocking): From our sync, it might be worth later revisiting how the FFI client is implemented to reduce the possibility for this kind of bug.

Copy link
Copy Markdown
Contributor

@ladvoc ladvoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@MaxHeimbrock MaxHeimbrock merged commit 0976db0 into main Apr 22, 2026
15 checks passed
@MaxHeimbrock MaxHeimbrock deleted the max/fix-enable-remote-track-dispatch branch April 22, 2026 08:47
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