Skip to content

Report HLS playback health for viewers who never join an SFU - #1448

Open
ipavlidakis wants to merge 11 commits into
ipavlidakis/IOS-2235-hls-rendererfrom
ipavlidakis/IOS-2235-hls-telemetry
Open

ipavlidakis wants to merge 11 commits into
ipavlidakis/IOS-2235-hls-rendererfrom
ipavlidakis/IOS-2235-hls-telemetry

Conversation

@ipavlidakis

@ipavlidakis ipavlidakis commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Issue Links

🎯 Goal

An HLS viewer never connects to an SFU, so the WebRTC stats path stays empty. Without HLS stats, a bad HLS session does not show in call stats.

📝 Summary

🛠 Implementation

The behaviour matches Android HlsStatsReporter and HlsStatsCollector in #1917.

  • HLSStatsCollector watches one AVPlayer. A serial queue applies the KVO changes in order, with the time captured in each callback. A snapshot hands its stats and events to the reporter on that queue, so stop() cannot send ended before them.
  • HLSStatsReporter sends one report at a time through the generated reportHLSStats endpoint.
    • Only started and ended retry, with the shared RetryPolicy.
    • A 429 and network errors retry. A 403 stops all reporting.
    • Events stay queued until the backend accepts or rejects the report. Each report takes the oldest 100 events. The buffer keeps the newest 1,000.
  • HLSStatsAdapter runs the interval timer and connects the collector and the reporter.
  • Wiring. CallState computes one internal value (token and interval) from the join response. HLSStateAdapter creates the stats adapter when it creates a player, and starts it in a Task. free() mutes the player, reads the final stats, and then stops the player. A swap and .webRTC go through free(). Creating the player does not wait for the network.
  • Live stops. When the host stops the live or the HLS broadcast stops, the player is freed, so the stats session sends ended.
  • Reloads. A reload of the item (Play HLS livestreams with a shared HLS player #1445) keeps the stats session. A reload before playback counts no stall.
  • Terminal errors. Agreed with the backend team: ended carries end_reason: error and error_code only for a terminal error. That is when the player gives up after 10 reloads, or when it stops without ever playing after it recorded an error. If started was not sent yet, the SDK sends it first, so the backend creates the participant. A hang with no player error uses error_code: load_timeout (to confirm with the backend team).
  • Recovered errors. When the stream plays again after an error, the SDK forgets the error, so a later stop sends end_reason: left.
  • started events. started carries no events. Buffered events go with the next stats or ended.
  • History. After the Play HLS livestreams with a shared HLS player #1445 redesign, this PR is 5 focused commits instead of 37.

🎨 Showcase

No UI change.

🧪 Manual Testing Notes

Needs a call type with HLS enabled for viewers, a running HLS egress, and a backend with the hls_stats endpoint.

  1. Join a livestream that the backend sends to HLS, with LivestreamPlayer.
  2. Let it play for longer than the report interval. Then leave the call.
  3. In call stats, check that the viewer has a started report, at least one stats report, and an ended report with reason left.

A backend without the endpoint rejects the reports. Playback continues.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change follows zero ⚠️ policy (required)
  • This change should receive manual QA
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (tutorial, CMS)

@ipavlidakis
ipavlidakis requested a review from a team as a code owner November 19, 2026 17:56
@ipavlidakis
ipavlidakis marked this pull request as draft November 19, 2026 17:56
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@ipavlidakis
ipavlidakis added this pull request to stack #1447 November 19, 2026 17:57
@sonarqubecloud

Copy link
Copy Markdown

@ipavlidakis ipavlidakis self-assigned this Nov 20, 2026
@ipavlidakis ipavlidakis added the enhancement New feature or request label Nov 20, 2026
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from 9ba0017 to 71d5adc Compare November 23, 2026 12:52
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from 71d5adc to fa14609 Compare November 24, 2026 08:18
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from fa14609 to 0e12056 Compare November 25, 2026 11:40
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from 0e12056 to fa14609 Compare November 25, 2026 11:44
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch 2 times, most recently from 672ae45 to 1a3b30a Compare November 25, 2026 13:48
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from 1a3b30a to bde2d99 Compare November 25, 2026 14:14
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from bde2d99 to 5e693d2 Compare November 25, 2026 17:12
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from 5e693d2 to b79adb3 Compare November 25, 2026 19:37
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from 2dc46e5 to a7d8fbe Compare November 26, 2026 11:48
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from a7d8fbe to bb2a602 Compare November 26, 2026 13:32
@ipavlidakis
ipavlidakis marked this pull request as ready for review November 26, 2026 15:50
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch 5 times, most recently from 2a7704a to 27cef76 Compare November 27, 2026 14:51
@ipavlidakis
ipavlidakis force-pushed the ipavlidakis/IOS-2235-hls-telemetry branch from 27cef76 to fd530c2 Compare November 27, 2026 16:53
@stream-ios-release-bot

Copy link
Copy Markdown

SDK Size

title develop branch diff status
StreamVideo 7.75 MB 7.93 MB +188 KB 🟢
StreamVideoSwiftUI 2.41 MB 2.45 MB +38 KB 🟢
StreamVideoUIKit 2.53 MB 2.56 MB +39 KB 🟢
StreamWebRTC 12.48 MB 12.48 MB 0 KB 🟢
StreamCore 0.96 MB 0.96 MB 0 KB 🟢

@stream-ios-release-bot

Copy link
Copy Markdown

StreamVideo XCSize

Object Diff (bytes)
HLSPlayer.o +19236
HLSStatsCollector.o +18664
ReportHLSStatsRequest.o +13603
HLSStateAdapter.o +11598
CallController.o +11104
Show 48 more objects
Object Diff (bytes)
HLSStatsReporter.o +10649
PlaybackResponse.o +9808
HLSAudioSession.o +6540
CallState.o +5885
ApplicationLifecycleVideoMuteAdapter.o +5682
JoinCallRequest.o +4673
HLSStatsAdapter.o +4370
CallKitAlwaysAvailabilityPolicy.o +4114
WebRTCStateAdapter.o +3928
HLSPlaybackStats.o +3728
DefaultAPI.o +3426
HLSPlayerEvent.o +2880
WebRTCCoordinator+Connecting.o +2851
PlaybackType.o +2661
WebRTCAuthenticator.o +2523
WebRTCCoordinator+HLSPlayback.o +1504
CallAudioSession.o +1335
OpenAPI+Extensions.o +1302
ReportHLSStatsResponse.o +1285
Call+JoiningStage.o -1270
SFUAdapter.o +1214
CameraInterruptionsHandler.o +1050
CallParticipant.o +972
GeofenceSettings.o +940
RTCMediaStream+CustomStringConvertible.o +864
CallSettingsResponse.o +846
AVCaptureDevice+OutputFormat.o -808
MicrophoneManager.o +684
StatsOptions.o +557
WebRTCCoordinator+Migrated.o +477
Call.o +468
SwiftProtobuf.o -420
JoinCallResponse.o +378
RTCAudioStore+Action.o +370
CallSettings.o +316
RTCAudioStore+RouteChangeEffect.o +306
WebRTCCoordinator.o +246
RTCAudioStore.o +198
StreamVideoEnvironment.o +192
StreamAppStateAdapter.o -122
RTCAudioStore+Coordinator.o +116
GetEdgesResponse.o +100
Foundation.tbd +92
AudioDeviceModule.o -84
IncomingVideoQualitySettings.o +76
MediaFrameReporter.o -72
StreamCallAudioRecorder+InterruptionMiddleware.o -72
OwnCapability.o +44

@stream-ios-release-bot

Copy link
Copy Markdown

StreamVideoSwiftUI XCSize

Object Diff (bytes)
LivestreamPlayer.o +13033
HLSVideoRendererView+Coordinator.o +4783
HLSPlayerView.o +3887
HLSVideoRendererView.o +2622
PermissionsPromptView.o +144
Show 6 more objects
Object Diff (bytes)
SampleBufferVideoCallView.o -90
PictureInPictureController.o -75
LocalParticipantViewModifier.o +68
StreamVideo.tbd +64
HelperViews.o -48
VideoRenderer.o -42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants