Skip to content

Release 0.0.4 - #3

Merged
JakubMrozek merged 1 commit into
mainfrom
release/0.0.4
May 16, 2026
Merged

JakubMrozek merged 1 commit into
mainfrom
release/0.0.4

Conversation

@JakubMrozek

Copy link
Copy Markdown
Member

Summary

Restores per-session AVAudioSession activation for OMID video sessions, fixing a regression where hardware device-volume changes were not delivered to the IAB OMID verification script.

What changed

OMManager.createSession, for creativeType == .video, now inlines:

```swift
let session = AVAudioSession.sharedInstance()
try? session.setCategory(.playback, mode: .default, options: [.mixWithOthers])
try? session.setActive(true)
```

…called per video OMID session, immediately before the OMID context is created. Matches the IAB OMSDK demo's WebViewVideoController.swift and the sdk-swift v3 PR #119 pattern that was IAB-certified.

Why this is necessary

Prior to this release, OMManager.createSession routed through AudioInfoProvider.ensureSessionActive() — a one-shot lazy static. First access typically came from AudioInfoProvider.collect() during the very first /preload (long before any video ad). By the time a video OMID session started, the static had already evaluated and ensureSessionActive() was a no-op.

That broke OMID's internal outputVolume KVO observer in practice: even with .mixWithOthers, the WKWebView's video element appears to take over audio focus, and iOS stops publishing volume KVO events to observers that registered before the video session was active. Re-issuing setActive(true) per-session refreshes the publishing pipeline.

Hand-verified against the IAB Validator Proxy: with the new pattern, volumeChange events now carry updated deviceVolume values on every hardware volume press (verified deviceVolume: 0 → 0.05 → 0.15 → 0.20 → 0.15 → 0.20 → 0.30 → 0.40 → 0.45 → 0.40 → 0.30 → 0.40 → 0.45 across two test sessions).

What was NOT changed

The "never deactivate" decision stays. setActive(false, .notifyOthersOnDeactivation) is what produced the 1-second audio-cut bug fixed in sdk-flutter PR #51, and .mixWithOthers makes a permanent active session gentle on host audio. The new code only ever calls setActive(true) — never setActive(false).

The earlier AudioInfoProvider.ensureSessionActive() lazy static remains in place for /preload's getDevice() consumer (which uses it to keep outputVolume live for device-info collection); it's just no longer relied on for OMID's per-session KVO.

Test plan

  • xcodebuild clean test -scheme KontextKit -destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=latest,arch=arm64' -skipPackagePluginValidation — green
  • Hand-test against sdk-swift Example (Package.swift pinned to local path): play a video ad, press hardware volume up/down, verify volumeChange events with updated deviceVolume arrive at the IAB Validator Proxy
  • pod lib lint KontextKit.podspec --allow-warnings --use-libraries
  • After merge: tag 0.0.4, GitHub release, pod trunk push KontextKit.podspec --allow-warnings --use-libraries

🤖 Generated with Claude Code

OMManager.createSession now activates AVAudioSession per video OMID
session (setCategory(.playback, .mixWithOthers) + setActive(true)),
matching sdk-swift v3 PR #119 and the IAB OMSDK demo. The previous
one-shot lazy activation through AudioInfoProvider froze device-volume
KVO after first /preload, so hardware volume events never reached
the verification script. Hand-verified against the IAB validator
proxy — deviceVolume changes now fire correctly.

No deactivation path: setActive(false, .notifyOthersOnDeactivation)
is what caused the 1s audio-cut bug fixed in sdk-flutter PR #51.
`.mixWithOthers` keeps the permanent active session gentle on host
audio.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JakubMrozek
JakubMrozek merged commit f51abf6 into main May 16, 2026
3 of 4 checks passed
@JakubMrozek
JakubMrozek deleted the release/0.0.4 branch May 16, 2026 19:04
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