Skip to content

Fix audio engine node detach crash #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LiveKitClient.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Pod::Spec.new do |spec|

spec.source_files = "Sources/**/*"

spec.dependency("LiveKitWebRTC", "= 125.6422.22")
spec.dependency("LiveKitWebRTC", "= 125.6422.24")
spec.dependency("SwiftProtobuf")
spec.dependency("Logging", "= 1.5.4")
spec.dependency("DequeModule", "= 1.1.4")
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
],
dependencies: [
// LK-Prefixed Dynamic WebRTC XCFramework
.package(url: "https://github.com/livekit/webrtc-xcframework.git", exact: "125.6422.22"),
.package(url: "https://github.com/livekit/webrtc-xcframework.git", exact: "125.6422.24"),
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.26.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),
Expand Down
2 changes: 1 addition & 1 deletion Package@swift-5.9.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let package = Package(
],
dependencies: [
// LK-Prefixed Dynamic WebRTC XCFramework
.package(url: "https://github.com/livekit/webrtc-xcframework.git", exact: "125.6422.22"),
.package(url: "https://github.com/livekit/webrtc-xcframework.git", exact: "125.6422.24"),
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.26.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.2"), // 1.6.x requires Swift >=5.8
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),
Expand Down
19 changes: 19 additions & 0 deletions Tests/LiveKitTests/AudioEngineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,25 @@ class AudioEngineTests: LKTestCase {
try? await Task.sleep(nanoseconds: 1 * 100_000_000) // 10ms
}
}

func testFailingPublish() async throws {
AudioManager.shared.set(engineObservers: [FailingEngineObserver()])
// Should fail
// swiftformat:disable redundantSelf hoistAwait
await XCTAssertThrowsErrorAsync(try await withRooms([RoomTestingOptions(canPublish: true)]) { rooms in
print("Publishing mic...")
try await rooms[0].localParticipant.setMicrophone(enabled: true)
})
}
}

final class FailingEngineObserver: AudioEngineObserver {
var next: (any LiveKit.AudioEngineObserver)?

func engineWillEnable(_: AVAudioEngine, isPlayoutEnabled _: Bool, isRecordingEnabled _: Bool) -> Int {
// Fail
-4101
}
}

final class SineWaveNodeHook: AudioEngineObserver {
Expand Down
9 changes: 9 additions & 0 deletions Tests/LiveKitTests/Support/Xcode14.2Backport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
import Foundation
import XCTest

func XCTAssertThrowsErrorAsync(_ expression: @autoclosure () async throws -> some Any) async {
do {
_ = try await expression()
XCTFail("No error was thrown.")
} catch {
// Pass
}
}

// Support iOS 13
public extension URLSession {
func downloadBackport(from url: URL) async throws -> (URL, URLResponse) {
Expand Down
Loading