Skip to content

OmSession: use Owner.JAVASCRIPT impression owner for HTML display - #8

Merged
JakubMrozek merged 3 commits into
mainfrom
fix/omid-html-display-js-impression-owner
May 22, 2026
Merged

OmSession: use Owner.JAVASCRIPT impression owner for HTML display#8
JakubMrozek merged 3 commits into
mainfrom
fix/omid-html-display-js-impression-owner

Conversation

@JakubMrozek

Copy link
Copy Markdown
Member

Summary

Switches HTML display sessions from Owner.NATIVE to Owner.JAVASCRIPT for the impression owner, matching the two reference implementations:

  • v3 sdk-kotlin (internal/utils/om/WebViewOmSession.kt:75) — Owner.JAVASCRIPT for both display and video
  • kontextkit-ios (Sources/OMSDK/OMManager.swift:107-115) — .javaScriptOwner for both display and video
  • IAB OMID Android v1.6.4 demo (OM-DemoApp/.../AdSessionUtil.java:55) — Owner.JAVASCRIPT, BEGIN_TO_RENDER, mediaOwner: NONE for HTML_DISPLAY

The v4 KontextKit deviated to Owner.NATIVE on the assumption that firing loaded() + impressionOccurred() natively would stop the JS verification scripts from polling geometry. In practice that wasn't the case — the JS layer still polled, and the IAB validator flagged the resulting impression events on the Kontext sdk-kotlin OMID submission.

Changes

  • src/main/kotlin/so/kontext/kit/omsdk/OmSession.kt — set impressionOwner = jsOwner unconditionally (was nativeOwner for display). Drop the now-unused nativeOwner local and the AdEvents creation block — both display and video are now JS-impression-owner, so the in-iframe useOmidDisplaySession / useOmidVideoSession hooks own the loaded + impressionOccurred calls.
  • Public OmSession.loaded() and OmSession.impressionOccurred() are kept as no-ops for SDK API compatibility — sdk-kotlin v4 still calls them today; cleanup is a follow-up.

Companion change (waits on this release)

  • kontextso/sdk-kotlin#103 — v4 PR. Drops the native loaded() + impressionOccurred() calls in Ad.kt (startOmSessionDelayed) since JS owns them now. Currently consumes KontextKit via local `includeBuild` for testing. After this PR merges + releases as a new KontextKit version, sdk-kotlin's `gradle/libs.versions.toml` will be bumped to point at the new version.

Test plan

  • Verified end-to-end with the IAB validator proxy against sdk-kotlin inline + interstitial video and display banner — all event flows pass section 1.3 of the OMID Integration Validation Test Cases
  • Section 1.3 test cases covered (verified in validator output): 6, 7-22, 23-31, 32-44, 45-69 (video), 70-77, 79, 84, 88-94 (interstitial), 95-108

🤖 Generated with Claude Code

JakubMrozek and others added 3 commits May 21, 2026 22:40
The v4 KontextKit OMID config used `Owner.NATIVE` as impressionOwner
for HTML_DISPLAY sessions on the assumption that the native SDK firing
loaded() + impressionOccurred() would stop the JS verification scripts
from polling geometry. In practice the JS still polled, and after the
hosting WebView was detached from its window the next poll emitted a
spurious `geometryChange { reasons: ["notFound"] }`.

Both reference implementations use Owner.JAVASCRIPT for HTML display:

- IAB OMID Android v1.6.4 demo (`OM-DemoApp/.../AdSessionUtil.java:55`):
    Owner.JAVASCRIPT, BEGIN_TO_RENDER, mediaOwner = NONE for HTML_DISPLAY.
- kontextkit-ios (`Sources/OMSDK/OMManager.swift:107-115`):
    .javaScriptOwner for both display and video.
- v3 sdk-kotlin (`internal/utils/om/WebViewOmSession.kt:75`): same.

All four converge: HTML display sessions are JS-impression-owner. The
in-iframe `use-omid-display-session` hook (in ads/packages/omsdk) fires
`adEvents.loaded(null)` + `adEvents.impressionOccurred()` from the
`sessionStart` observer; the native side just constructs the session
and calls `start()`.

Switching impressionOwner also drops the native AdEvents creation —
no longer needed for any creative type, since the verification scripts
own loaded/impression for both display and video now. `loaded()` and
`impressionOccurred()` on `OmSession` become no-ops kept only for SDK
API compatibility (sdk-kotlin still references them today; can be
removed in a follow-up).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`OmSession.loaded()` and `impressionOccurred()` became no-ops in the
parent commit (`62a497c`) — the JS verification scripts own these
events now that `impressionOwner = Owner.JAVASCRIPT` for both display
and video. The two private booleans that guarded re-entry against
those methods are no longer referenced anywhere; detekt's
`UnusedPrivateProperty` flagged them and failed CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Aligns KontextKit's toolchain with sdk-kotlin's 2.1 baseline (used in
the v3 2.0.1 release) so consuming apps already on Kotlin 2.x stop
hitting compiler-output / metadata mismatches when pulling KontextKit
transitively. v4 dropped Ktor (uses HttpURLConnection) so the bump
here is purely toolchain — no library API changes.

Versions:
- Kotlin 1.9.22 → 2.1.0
- AGP      8.6.1 → 8.7.3 (requires Gradle 8.9+)
- Gradle   8.7   → 8.9
- detekt   1.23.4 → 1.23.8 (Kotlin 2.x compat)
- spotless 6.25.0 → 7.2.1
- kit      0.0.4 → 0.0.5

Verified locally with `./gradlew spotlessCheck detekt test` — clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JakubMrozek
JakubMrozek merged commit cfa135e into main May 22, 2026
1 check passed
@JakubMrozek
JakubMrozek deleted the fix/omid-html-display-js-impression-owner branch May 22, 2026 01:07
JakubMrozek added a commit to kontextso/sdk-kotlin that referenced this pull request May 22, 2026
Toolchain alignment with the v3 2.0.1 baseline so publisher apps
already on Kotlin 2.x stop hitting compiler-output / metadata
mismatches when consuming sdk-kotlin v4. v4 already dropped Ktor
(uses `HttpURLConnection`), so this bump is pure toolchain — no
public API changes.

Versions:
- Kotlin           1.9.22 → 2.1.0
- AGP              8.6.1  → 8.7.3 (requires Gradle 8.9+)
- Gradle           8.7    → 8.9
- detekt           1.23.4 → 1.23.8 (Kotlin 2.x compat)
- spotless         6.25.0 → 7.2.1
- compose-bom      2024.01.00 → 2024.12.01
- kontext-kit      0.0.4  → 0.0.5 (OMID HTML display impression owner
                                    now Owner.JAVASCRIPT — see
                                    kontextso/kontextkit-android#8)

Compose plugin:
The `composeOptions { kotlinCompilerExtensionVersion }` block is
unsupported on Kotlin 2.x. Applied the new
`org.jetbrains.kotlin.plugin.compose` plugin to both `:ads` and
`:example`. Dropped the now-unused `compose-compiler` version
constant from the catalog.

Tests:
Removed two stale tests in `AdTest.kt` that referenced the
`finishOmSessionNow()` method deleted during the OMID rework
earlier in this PR. Kotlin 1.9.22 silently passed them; Kotlin
2.1.0 reports them as unresolved references.

Spotless reformatted a handful of files under
`ads/src/main/kotlin/so/kontext/ads/ui/` to match the 7.2.1
ktlint baseline — formatting-only.

Verified:
- `./gradlew spotlessCheck detekt :ads:testDebug` clean
- `./gradlew :example:installDebug` installs cleanly on a Pixel 9a
  emulator (Android 16)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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