Skip to content

Fix network detail gating and live audio volume - #1

Merged
JakubMrozek merged 2 commits into
mainfrom
fix/network-detail-and-audio-volume-live
May 14, 2026
Merged

JakubMrozek merged 2 commits into
mainfrom
fix/network-detail-and-audio-volume-live

Conversation

@JakubMrozek

@JakubMrozek JakubMrozek commented May 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Two device-info collection bugs surfaced during sdk-swift v4 wire-shape testing on a real iPhone:

  1. NetworkInfoProvider.collect() reported {type: "wifi", detail: "5g"} because CoreTelephony's cellular RAT lookup is independent of NWPathMonitor's active-path read. The cellular radio stays up on 5G/LTE for calls/fallback even when Wi-Fi is carrying data, so detail was describing the wrong connection. Match sdk-react-native by gating detail on type == "cellular".

  2. AudioInfoProvider.collect() returned a volume reading that updated only on the first preload after app launch and was frozen on every subsequent call — even after the user changed device volume — because AVAudioSession.outputVolume is documented as undefined unless the session is active, and iOS only continuously refreshes the property while something is observing it via KVO. Activate the session at the top of collect() and install a permanent KVO observer in ensureSessionActive() so volume tracks user changes without needing a video ad on screen.

Test plan

  • swift test / xcodebuild test -scheme KontextKit — 39 tests pass.
  • New tests:
    • detailIsNilOnNonCellular + dictOmitsDetailOnNonCellular (NetworkInfoProvider)
    • collectActivatesSessionImplicitly (AudioInfoProvider)
    • consecutiveCollectsKeepSessionActive (AudioInfoProvider)
  • Manual verification on a real device via sdk-swift's Example app — change device volume between preloads, observe the wire shape updates; switch between Wi-Fi and cellular, observe detail appears/disappears.

🤖 Generated with Claude Code

JakubMrozek and others added 2 commits May 14, 2026 11:00
NetworkInfoProvider: CoreTelephony reports the cellular radio's RAT
even when Wi-Fi is the active path (the radio stays up on 5G/LTE
for calls and fallback). Without gating, the SDK was shipping
{type: "wifi", detail: "5g"} which misrepresents the data path to
DSPs. Match sdk-react-native's AdsProvider behaviour by returning
`detail` only when `type == "cellular"`.

AudioInfoProvider: `AVAudioSession.outputVolume` is documented as
undefined unless the session is active, AND iOS only continuously
refreshes the property when something is observing it via KVO (or
audio is playing). Previously `collect()` didn't activate the
session, so it returned a value cached at app launch — fine for
the first preload, frozen on every subsequent one even after the
user changes device volume. Activate the session at the top of
`collect()` and install a permanent KVO observer inside
`ensureSessionActive()` so the value tracks user changes without
needing a video ad on screen.

Tests:
- detailIsNilOnNonCellular / dictOmitsDetailOnNonCellular
- collectActivatesSessionImplicitly
- consecutiveCollectsKeepSessionActive

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@JakubMrozek
JakubMrozek merged commit f1232ac into main May 14, 2026
2 checks passed
@JakubMrozek
JakubMrozek deleted the fix/network-detail-and-audio-volume-live branch May 14, 2026 11:06
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.

1 participant