Skip to content

Conversation

@brainwith
Copy link
Owner

merge upper stream branch

hiroshihorie and others added 17 commits September 23, 2025 23:41
**Audio Engine Availability Control:**

* Added `AudioEngineAvailability` struct and related conversion
extensions in `AudioEngineAvailability.swift` to represent and manage
input/output availability for the audio engine.
* Introduced `setEngineAvailability(_:)` and `engineAvailability` API to
`AudioManager`, providing high-priority control over the engine's
running state.
* Updated publishing logic in `LocalParticipant` to only wait for audio
frames if input is available, respecting the new availability controls.

**Testing and Documentation:**

* Added `AudioEngineAvailabilityTests` to verify that the audio engine
stops and resumes correctly when availability is toggled, ensuring
robust behavior.
* Added a helper sleep extension to `LKTestCase` to support async test
scenarios.

**Dependency Updates:**

* Updated `LiveKitWebRTC` dependency to version `137.7151.08` in
`LiveKitClient.podspec`, `Package.swift`, and `[email protected]`
to support the new audio engine availability features.
[[1]](diffhunk://#diff-cd792874225249a1976737e2b629c17cc7c8bb8de175a12d6b93a4e49b33dedbL17-R17)
[[2]](diffhunk://#diff-f913940c58e8744a2af1c68b909bb6383e49007e6c5a12fb03104a9006ae677eL22-R22)
[[3]](diffhunk://#diff-8e7a2b05a09a07931d721896a66b6648bf9cc39fa80e2b4f65f3cdd6c8e553abL23-R23)

Other minor changes include internal test updates to use `ObjCBool` for
engine state properties.
Resolves #757 

- Adds cancellation to reconnect, making sure that it cannot continue
after `disconnect()` and bring the room back to life
- ⚠️ Optionally, we can introduce a breaking `.disconnecting` state to
prevent new tasks from being started (vs cancelling ongoing tasks - a
little _less elegant_)
- Theoretically it should not affect other state transitions, as
`disconnect()` is basically "destructive" - the only valid path leads to
`.disconnected` during `cleanup()`, however that's not statically
enforced in any way
- On the other hand, it does not provide any added value for other parts
of the SDK, just covering this tiny time window
Move audio recording perms checks from SDK to WebRTC.
Patch: webrtc-sdk/webrtc#200

A simple way to test this would be trying to enable mic while in a phone
call.
AVAudioSession activation fail will be detected in the lib, and report
error instead of crashing.
- Adds data channel encryption based on
livekit/client-sdk-js#1595
- Adds `currentKey` state to `BaseKeyProvider`
- It was missing comparing to other platforms, and we cannot explicitly
default to `0`
- Adds some integration tests, as most of the _crypto_ stuff is tested
by webrtc
- Existing hi-level tests e.g. data streams will get a `sharedKey` by
default 🎉

### Migration/deprecations
- Replace `E2EEOptions` with `EncryptionOptions` (1:1)
- Add `EncryptionType` parameter to `Room/ParticipantDelegate` methods

---------

Co-authored-by: Hiroshi Horie <[email protected]>
Mirrors Android setup for easier/more consistent tracking. Keeps the
generated files, you don't need to install anything in order to build...
I didn't get the feedback on the actual runtime errors yet, but I
believe it's still worth merging - as a decent technical change
(removing `Unsafe...`).

I don't see any obvious mistakes in the existing code either.
So that it can be resolved by SPM for a fresh build.
Discovered while moving tests:
- `OutgoingStreamManagerTests`
- `ByteStreamInfoTests`
Problem

The testSerialRunnerCancel() test was failing with the counter ending up
negative (-1, -8, etc.) instead of the expected 0, indicating a race
condition.

Root Cause

The condition !Task.isCancelled was causing cancelled tasks to skip
waiting for the previous task to complete. This broke the serial
execution guarantee, allowing multiple blocks to run concurrently and
causing unsynchronized access to the shared counter.

Fix

Removed the !Task.isCancelled condition to ensure all tasks wait for the
previous task, even when cancelled. This maintains the serial ordering
guarantee that the actor is designed to provide.

---------

Co-authored-by: Błażej Pankowski <[email protected]>
Let's try to separate on-device tests from the core suite (with proper
retry, timeout, etc.).
Turns out that the configuration closure:
- must be run _before_ any logs (expected) - this is kinda fixable
- may run once per process, so will break for anyone using the same
framework... and we cannot do any default setup

If we need the flexibility anyway, maybe it's better to drop the
`swift-logging` right now...

My assupmtions:
- we use pure OSLog by default (info or warning)
- we can easily enable rtc internal logs via the same channel
- we can easily provide our custom implementation
@brainwith brainwith merged commit a857234 into brainwith:main Oct 14, 2025
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.

3 participants