Fix late webview completion race - #212
Merged
Merged
Conversation
|
Cocoapods size report: |
CAMOBAP
previously approved these changes
Mar 21, 2026
e271828-
marked this pull request as draft
March 22, 2026 14:22
Contributor
Author
|
draft, as we may want to keep recording including the initial load cost. |
e271828-
marked this pull request as ready for review
March 25, 2026 10:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes the late-completion race behind the flaky
HCaptchaWebViewManager__Tests.test__Configure_Web_Viewfailure seen in GitHub Actions job 67922018521, while keepingHCaptcha__Bench.testBenchVerifymeasuring webview startup plus verification.Reference:
Root Cause
HCaptchaWebViewManagerkept the active validation completion alive after delivering a terminal result.That allowed later
WKNavigationDelegatecallbacks, especiallywebViewWebContentProcessDidTerminate, to re-enter the same completion path with an error result after success had already been delivered.The earlier branch version tried to hide that race by preloading the benchmark before
measureMetrics, but that changed whattestBenchVerifymeasures. We do not want that benchmark warmed up ahead of time.What Changed
complete(...), which clears the stored completion before invoking it.validate(on: nil)now uses the same terminal completion path for.failedSetup.stop()clears any pending completion so post-stop callbacks cannot leak through.testBenchVerifystill includes webview startup time.test__Validate__Ignores_Late_Termination_After_Tokenremains to cover the late-termination case directly.Validation
Ran locally:
xcodebuild test -workspace Example/HCaptcha.xcworkspace -scheme HCaptcha_Tests -destination 'platform=iOS Simulator,id=AD95999C-D8DE-4206-848B-AF7EC34B7EA9' -only-testing 'HCaptcha_Tests/HCaptchaWebViewManager__Tests/test__Validate__Ignores_Late_Termination_After_Token' -only-testing 'HCaptcha_Tests/HCaptchaWebViewManager__Tests/test__Configure_Web_View' -only-testing 'HCaptcha_Tests/HCaptchaWebViewManager__Tests/test__Stop'xcodebuild test -workspace Example/HCaptcha.xcworkspace -scheme HCaptcha_Tests -destination 'platform=iOS Simulator,id=AD95999C-D8DE-4206-848B-AF7EC34B7EA9' -only-testing 'HCaptcha_Tests/HCaptcha__Bench/testBenchVerify'Both passed.