Skip to content

test(android SDK): add WebView and JS SDK readiness wait in bridge tests - #1003

Merged
rmi22186 merged 1 commit into
mainfrom
test/add-webview-and-js-sdk-readiness-wait-in-bridge
Nov 10, 2026
Merged

rmi22186 merged 1 commit into
mainfrom
test/add-webview-and-js-sdk-readiness-wait-in-bridge

Conversation

@rmi22186

Copy link
Copy Markdown
Member

Why

In MParticleJSInterfaceITest, runJavascriptTest posts WebView.loadDataWithBaseURL asynchronously to the main looper and returns immediately, so the test's 30-second countdown latch starts before the cold WebView and JavaScript SDK finish initializing. Because JUnit 4's default method sorter (Method.getName().hashCode()) always runs testSetUserAttribute first (hashCode = -2015282559), cold WebView startup overhead falls on testSetUserAttribute and causes intermittent latch timeouts on CI emulators.

Programme

Android SDK and Web SDK native bridge test hardening.

What changes

  • Registers a dedicated @JavascriptInterface readiness callback in MParticleJSInterfaceITest.runJavascriptTest that fires unconditionally from inside window.mParticle.ready once the WebView and JavaScript SDK are initialized, throwing an explicit Error if the readiness bridge is missing.
  • Waits on sdkReadyLatch and asserts readiness in runJavascriptTest before returning to the test's callback assertion latch.
  • Raises WEBVIEW_TIMEOUT_SECONDS from 30 to 60 as extra cover after the readiness wait.

Linked work

  • Paired with the mParticle/mparticle-web-sdk Android Bridge Tests workflow hardening proposal.

Rollout

Merges to mParticle/mparticle-android-sdk main first so the Android Bridge Tests workflow proposal in mParticle/mparticle-web-sdk can pin to the merged commit SHA before promotion. Revert the pull request to roll back.

Risks

  • A broken WebView, missing readiness bridge, or stalled JavaScript SDK bundle could block initialization -> throws an explicit Error if the bridge is missing and bounds sdkReadyLatch.await by WEBVIEW_TIMEOUT_SECONDS (60 seconds) with an explicit readiness failure message.
  • Change class: X3 (instrumentation test harness only).

Who

Prepared by an automated coding agent and reviewed by the SDK team before merge.

Size

30 lines added and 7 removed in 1 file.

@github-actions

Copy link
Copy Markdown

Kotlin migration progress

No change to the Java left to convert.

Module Kotlin LOC Java LOC Java staying (facade) Java left to convert Kotlin share
android-core 8,640 17,301 9,716 7,585 33.3%
android-kit-base 601 5,405 1,651 3,754 10.0%
Total 9,241 22,706 11,367 11,339 28.9%

Conversion progress: 31.5% (11,339 of 16,550 baseline Java LOC left to convert). 96 Java files and 72 Kotlin files in scope.

@rmi22186
rmi22186 marked this pull request as ready for review November 10, 2026 16:46
@rmi22186
rmi22186 requested a review from a team as a code owner November 10, 2026 16:46
@github-actions

Copy link
Copy Markdown

Binary compatibility

  • ✅ android-core is compatible with 6.1.10 (112 classes compared, 0 with additions only).
  • ✅ android-kit-base is compatible with 6.1.10 (37 classes compared, 0 with additions only).

Compares this branch with the last version published to Maven Central, both built without R8, over the public classes and members that release keeps under their own names. It also checks that this branch's release AAR still keeps them (see the script docstring). Full japicmp HTML/XML reports are attached as the api-compat-reports workflow artifact. This check is not in the required-check set yet, so a red result here does not block merging.

@alexs-mparticle alexs-mparticle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: checked MParticleJSInterfaceITest readiness bridge registration before page load, signaling before test JavaScript, bounded startup wait, and all ten callback-latch callers; emulator execution was unavailable locally.

Posted by an AI review agent on behalf of alexs-mparticle.

@github-actions

Copy link
Copy Markdown

📦 SDK Size Impact Report

What the SDK adds to a minified release APK.

mParticle Core SDK

Measured against an empty baseline app. Unlike the Rokt kit, android-core ships no Compose and no resources, so there is nothing here that a host app would already provide.

Metric Target branch This PR Change
APK size 121.39 KB 121.39 KB +3 bytes
Download size 119.21 KB 119.21 KB +3 bytes
Dex bytes 218.44 KB 218.44 KB 0 bytes

mParticle Core + Rokt kit

Measured against a Compose + Material3 reference app, so these are the costs on top of an app that already ships Compose. The reference app's dependencies are a documented convention, not a measured average: see size-report-rokt/README.md.

Metric Target branch This PR Change
APK size 1.26 MB 1.26 MB 0 bytes
Download size 1.25 MB 1.25 MB +1 bytes
Dex bytes 2.24 MB 2.24 MB 0 bytes

Rokt SDK+ umbrella (adds the payment extension)

Metric Target branch This PR Change On top of mParticle Core + Rokt kit
APK size 6.55 MB 6.55 MB 0 bytes +5.29 MB
Download size 6.43 MB 6.43 MB -5 bytes +5.19 MB
Dex bytes 7.12 MB 7.12 MB 0 bytes +4.89 MB

➡️ SDK size impact change is minimal.

Raw measurements

core, Target branch:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2513, "baseline_install_bytes": 7530, "core_dex_bytes": 223684, "core_download_bytes": 124581, "core_install_bytes": 131831}

core, This PR:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2510, "baseline_install_bytes": 7527, "core_dex_bytes": 223684, "core_download_bytes": 124581, "core_install_bytes": 131831}

rokt, Target branch:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4173692, "kit_download_bytes": 2548319, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297648, "sdkplus_download_bytes": 7987551, "sdkplus_install_bytes": 8165359}

rokt, This PR:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4173692, "kit_download_bytes": 2548320, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9297648, "sdkplus_download_bytes": 7987546, "sdkplus_install_bytes": 8165359}

Measured c8dc5e9 merged into 58ba34f

@rmi22186
rmi22186 merged commit cc21fe7 into main Nov 10, 2026
45 checks passed
@rmi22186
rmi22186 deleted the test/add-webview-and-js-sdk-readiness-wait-in-bridge branch November 10, 2026 17:07
@jamesnrokt jamesnrokt added the promoted Opened from Rokt's internal review process label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

promoted Opened from Rokt's internal review process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants