Repository navigation
test(android SDK): add WebView and JS SDK readiness wait in bridge tests - #1003
Conversation
Kotlin migration progressNo change to the Java left to convert.
Conversion progress: 31.5% (11,339 of 16,550 baseline Java LOC left to convert). 96 Java files and 72 Kotlin files in scope. |
Binary compatibility
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 |
alexs-mparticle
left a comment
There was a problem hiding this comment.
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.
📦 SDK Size Impact ReportWhat the SDK adds to a minified release APK. mParticle Core SDKMeasured 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.
mParticle Core + Rokt kitMeasured 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
Rokt SDK+ umbrella (adds the payment extension)
➡️ SDK size impact change is minimal. Raw measurementscore, 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} |
Why
In
MParticleJSInterfaceITest,runJavascriptTestpostsWebView.loadDataWithBaseURLasynchronously 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 runstestSetUserAttributefirst (hashCode = -2015282559), cold WebView startup overhead falls ontestSetUserAttributeand causes intermittent latch timeouts on CI emulators.Programme
Android SDK and Web SDK native bridge test hardening.
What changes
@JavascriptInterfacereadiness callback inMParticleJSInterfaceITest.runJavascriptTestthat fires unconditionally from insidewindow.mParticle.readyonce the WebView and JavaScript SDK are initialized, throwing an explicitErrorif the readiness bridge is missing.sdkReadyLatchand asserts readiness inrunJavascriptTestbefore returning to the test's callback assertion latch.WEBVIEW_TIMEOUT_SECONDSfrom30to60as extra cover after the readiness wait.Linked work
mParticle/mparticle-web-sdkAndroid Bridge Testsworkflow hardening proposal.Rollout
Merges to
mParticle/mparticle-android-sdkmainfirst so theAndroid Bridge Testsworkflow proposal inmParticle/mparticle-web-sdkcan pin to the merged commit SHA before promotion. Revert the pull request to roll back.Risks
Errorif the bridge is missing and boundssdkReadyLatch.awaitbyWEBVIEW_TIMEOUT_SECONDS(60seconds) with an explicit readiness failure message.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.