Skip to content

MOBILE-311: Heal poisoned in-app WebView cache#746

Open
sergeysozinov wants to merge 1 commit into
developfrom
feature/MOBILE-311
Open

MOBILE-311: Heal poisoned in-app WebView cache#746
sergeysozinov wants to merge 1 commit into
developfrom
feature/MOBILE-311

Conversation

@sergeysozinov

Copy link
Copy Markdown
Collaborator

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Implements a self-healing path for WebView in-apps when a cacheable HTTP error response (e.g., a transient 404 on a bootstrap script) gets persisted in Chromium’s HTTP cache, by allowing a single reload with cache bypass and enriching timeout telemetry.

Changes:

  • Added WebViewNoCacheRetryPolicy (pure JVM-testable logic) to decide when to trigger a one-shot no-cache reload based on subresource HTTP errors.
  • Wired the policy into WebViewInappViewHolder to perform a cache-bypassed reload before runtime init, prevent duplicate onShown, and include last script HTTP error context in timeout failure telemetry.
  • Updated WebView prewarm to restart the settle-release budget when a no-cache retry is initiated, with corresponding test updates/additions.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/presentation/view/WebViewNoCacheRetryPolicy.kt Adds the retry decision policy for recoverable script HTTP errors and cache-gated one-shot reload.
sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/presentation/view/WebViewInappViewHolder.kt Integrates no-cache retry behavior into the in-app WebView flow and augments init-timeout telemetry.
sdk/src/main/java/cloud/mindbox/mobile_sdk/inapp/presentation/InAppWebViewPrewarmManager.kt Restarts the prewarm settle-release timer budget when a no-cache retry begins.
sdk/src/test/java/cloud/mindbox/mobile_sdk/inapp/presentation/view/WebViewNoCacheRetryPolicyTest.kt Adds unit tests covering retry eligibility, one-shot behavior, cache gate, and telemetry details.
sdk/src/test/java/cloud/mindbox/mobile_sdk/inapp/presentation/InAppWebViewPrewarmManagerImplTest.kt Updates expected domain and adds a test validating settle budget restart on no-cache retry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +496 to +500
mindboxLogI("[WebView] Retrying In-App content load with cache bypassed (${noCacheRetryPolicy.lastHttpErrorDetail})")
stopTimer()
readyChecker?.cancel()
controller.setCacheBypass(true)
onContentPageLoaded(content)
if (isRecoverableScriptHttpError(url, statusCode)) {
mindboxLogW("[WebView] HTTP error $statusCode for $url (mainFrame=$isForMainFrame)")
} else {
mindboxLogD("[WebView] HTTP error $statusCode for $url (mainFrame=$isForMainFrame)")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

mindboxLogD не используем. Надо бы боту сказать и пометить анотацией метод

webViewController?.let { controller ->
hasInitialized = false
pendingReadyCheckFailure = null
lastLoadedContent = content

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

дополнительный уровень кэша?

fun `grants only one retry per page load`() {
val policy = policy()

assertTrue(policy.onHttpError(trackerUrl, 404, hasInitialized = false))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ошибки 500 так же будут работаь?

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