Skip to content

Fix dialog loaded lifecycle race#260

Merged
e271828- merged 1 commit into
mainfrom
codex/deflake-live-dialog-e2e
May 4, 2026
Merged

Fix dialog loaded lifecycle race#260
e271828- merged 1 commit into
mainfrom
codex/deflake-live-dialog-e2e

Conversation

@e271828-

@e271828- e271828- commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • gate HCaptchaDialogFragment.onStart() loaded replay so it only runs after the WebView has previously reported a real bridge load
  • preserve the existing reuse-after-reset behavior for already-loaded WebViews
  • prevent first dialog start from synthesizing onLoaded() before the JS SDK calls BridgeObject.onLoaded()

Why

This is an SDK lifecycle bug, not a live-test-only flake. onLoaded() has side effects: it emits the loaded listener callback, sets verify params, and auto-executes invisible challenges. Calling it unconditionally from onStart() can run those effects before web content has actually reported loaded, which matches the generic error 29 failure seen in live CI.

The original replay path appears useful for reusing a loaded WebView after reset, so this keeps that behavior but arms it only after a real bridge load.

Testing

  • ./gradlew :sdk:check :test:compileDebugAndroidTestJavaWithJavac
  • repo pre-commit check ran successfully during commit

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

Diffuse report:

OLD: sdk-main.aar
NEW: sdk-pr.aar

 AAR      │ old       │ new       │ diff   
──────────┼───────────┼───────────┼────────
      jar │  94.7 KiB │  94.9 KiB │ +171 B 
 manifest │     411 B │     411 B │    0 B 
      res │  28.3 KiB │  28.3 KiB │    0 B 
    other │     1 KiB │     1 KiB │    0 B 
──────────┼───────────┼───────────┼────────
    total │ 124.4 KiB │ 124.6 KiB │ +171 B 

 JAR     │ old │ new │ diff       
─────────┼─────┼─────┼────────────
 classes │  61 │  61 │  0 (+0 -0) 
 methods │ 800 │ 800 │  0 (+0 -0) 
  fields │ 270 │ 272 │ +2 (+2 -0)
AAR
 size     │ diff   │ path          
──────────┼────────┼───────────────
 94.9 KiB │ +171 B │ ∆ classes.jar 
──────────┼────────┼───────────────
 94.9 KiB │ +171 B │ (total)
JAR
FIELDS:

   old │ new │ diff       
  ─────┼─────┼────────────
   270 │ 272 │ +2 (+2 -0) 
  
  + com.hcaptcha.sdk.HCaptchaDialogFragment replayLoadedOnStart: boolean
  + com.hcaptcha.sdk.HCaptchaDialogFragment webViewLoaded: boolean

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

Benchmark report:

Test name Time ms. (median) Allocations (median)
com.hcaptcha.sdk.HCaptchaBenchmarkTest.EMULATOR_UNLOCKED_benchmarkInvisibleVerification +493.31 +26
com.hcaptcha.sdk.HCaptchaBenchmarkTest.EMULATOR_UNLOCKED_benchmarkInvisibleVerificationColdRun +834.69 +550
com.hcaptcha.sdk.HCaptchaBenchmarkTest.EMULATOR_UNLOCKED_benchmarkInvisibleSetup +9.94 +514.25
com.hcaptcha.sdk.HCaptchaDebugInfoTest.EMULATOR_UNLOCKED_benchmarkDebugInfo +30.13 -5535
com.hcaptcha.sdk.HCaptchaDebugInfoTest.EMULATOR_UNLOCKED_benchmarkDebugSys +49.77 +39

@e271828- e271828- force-pushed the codex/deflake-live-dialog-e2e branch from 18c0e04 to 7c78c1b Compare May 1, 2026 19:03
@e271828- e271828- changed the title Fix invisible dialog live test race Fix dialog loaded lifecycle race May 1, 2026
@e271828- e271828- force-pushed the codex/deflake-live-dialog-e2e branch from 7c78c1b to e139f9a Compare May 1, 2026 20:29
@e271828- e271828- requested review from CAMOBAP and DSergiu May 1, 2026 20:46
@e271828- e271828- force-pushed the codex/deflake-live-dialog-e2e branch from e139f9a to 128f90d Compare May 1, 2026 20:49
@e271828- e271828- merged commit 9fa6898 into main May 4, 2026
12 checks passed
@e271828- e271828- deleted the codex/deflake-live-dialog-e2e branch May 4, 2026 14:14
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.

3 participants