MOBILE-269: WebView cache#35
Merged
Merged
Conversation
MOBILE-0000: Drain in-flight evaluate callbacks before destroying the WebView Now that destroy actually executes, it raced the learned-hosts capture queued right before close: the evaluate had run but its result callback comes back from the renderer asynchronously, and an immediate destroy drops it (verified live — hosts stopped persisting). The controller now counts pending evaluate callbacks and destroys the moment the last one lands; a timeout only bounds a renderer that never answers. MOBILE-0000: Pin the httpsOrigin ASCII-plus-underscore charset with tests MOBILE-0000: Fix the never-executing WebView destroy and pin prewarm navigation AndroidWebViewController posted all work via View.post: after onClose detaches the view, those posts land in the view's HandlerActionQueue and never drain — destroy() included, so every closed webview in-app leaked a live WebView with its page JS still running. Work now posts to a main-looper Handler with an isDestroyed latch. Also: the deprecated shouldOverrideUrlLoading overload now treats navigations as main-frame so the lock holds on API < 24; the prewarm engine pins its hidden WebView to SDK-issued documents; httpsOrigin accepts '_' and rejects non-ASCII letters (punycode is the wire format). MOBILE-0000: Cover fragment handling and authority charset in the planner MOBILE-0000: Harden the prewarm planner and engine after the audit - prewarm params are inserted before a '#' in the baseUrl: appended after it they land in the fragment, location.search stays empty and the web contract silently degrades to a plain page warm; - httpsOrigin accepts only legal host[:port] characters — origins are interpolated into preconnect HTML attributes and a corrupt config value must never become markup; - the engine destroys the WebView in its own runCatching so a failure in the cosmetic cleanup cannot leak the renderer. MOBILE-0000: Let the prewarm engine evaluate JS on its hidden WebView Gives the owning service a way to poll page state (network idle) without exposing the WebView itself; null result when the instance is gone or aborted. MOBILE-0000: Drop the legacy prewarm stub bridge The web page's official prewarm mode ships; the stub existed only to cover pages that predate it. Against an old page the prewarm now degrades to a plain page warm (no byendpoint) — shows are unaffected. Validated live on both platforms with stub-less builds against the new page. MOBILE-0000: Cover the prewarm baseUrl contract with planner tests MOBILE-0000: Add official prewarm params to the content-page baseUrl The web runtime is getting an official prewarm mode: with prewarm=1&endpointId&deviceUuid on the document URL it boots tracker-only instead of relying on the legacy SdkBridge stub. The stub stays attached as a fallback for the current prod page and now logs its calls — the observable signal that a page took the legacy path. MOBILE-0000: Terminal engine abort + preconnect without baseUrl host abort() latches synchronously so a prewarm load posted from a background thread can't recreate the WebView after a real show takes over. Preconnect origins now come from contentUrl hosts only — baseUrl is just the cache partition, typically a synthetic host, and preconnecting it wasted a DNS lookup every launch. MOBILE-0000: Production WebView cache + config-driven prewarm primitives Persistent cache becomes unconditional (LOAD_DEFAULT). Add InAppWebViewPrewarmPlanner (commonMain, pure: origins/preconnect page/observed-hosts probe from config urls) and InAppWebViewPrewarmEngine (androidMain: hidden WebView loading preconnect + content page with a legacy receiveParam stub bridge, no reuse). MindboxWebViewLab shrinks to throwaway measurement switches + profiler. MOBILE-0000: WebView cache + preconnect prototype (throwaway) Add MindboxWebViewLab (LOAD_DEFAULT cache toggle, preconnect prewarm, throwaway show-time profiler) and wire it into AndroidWebViewController. Measurement scaffolding behind compile-time flags; remove before ship.
enotniy
force-pushed
the
feature/MOBILE-269
branch
from
July 14, 2026 07:49
d40e827 to
bddef57
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces infrastructure for warming and reusing WebView network state (DNS/TCP/TLS + HTTP cache) for in-app WebView content, including a planner for deriving what to prewarm from config and Android-side implementations to apply cache policy and run a hidden prewarm WebView.
Changes:
- Added
InAppWebViewPrewarmPlanner(+ common tests) to derive a prewarm plan, sanitize origins, and build preconnect HTML / contract URLs. - Added Android
InAppWebViewPrewarmEngineandwebViewCacheMode()(+ android unit test) to implement prewarm execution and unify cache-mode decisions. - Updated Android WebView controller to support cache-mode toggle, improve destroy sequencing around
evaluateJavascript, and adjust legacyshouldOverrideUrlLoadingbehavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/inapp/webview/InAppWebViewPrewarmPlannerTest.kt | Adds unit tests for origin normalization, plan building, preconnect HTML, and contract URL building. |
| mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/inapp/webview/InAppWebViewPrewarmPlanner.kt | Adds pure planning logic for WebView prewarm: selecting a layer, collecting origins, and generating preconnect HTML / scripts. |
| mindbox-common/src/androidUnitTest/kotlin/cloud/mindbox/mobile_sdk/inapp/webview/WebViewCachePolicyTest.kt | Tests mapping from cache toggle to WebSettings.cacheMode. |
| mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/inapp/webview/WebViewCachePolicy.kt | Introduces shared cache-mode policy helper for Android WebViews. |
| mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/inapp/webview/WebViewAndroid.kt | Adds cache toggle + logging to controller creation, sets cache mode via policy, and improves destroy/evaluateJavascript sequencing. |
| mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/inapp/webview/InAppWebViewPrewarmEngine.kt | Adds Android prewarm engine that loads preconnect/content pages in a hidden WebView and can be released/aborted. |
| mindbox-common/build.gradle.kts | Adds dependencies for androidUnitTest source set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
Тесты не запускаются - |
enotniy
force-pushed
the
feature/MOBILE-269
branch
2 times, most recently
from
July 14, 2026 08:31
05c417c to
baa10ca
Compare
justSmK
reviewed
Jul 14, 2026
enotniy
force-pushed
the
feature/MOBILE-269
branch
from
July 14, 2026 10:26
baa10ca to
e7d1b91
Compare
justSmK
approved these changes
Jul 14, 2026
enotniy
force-pushed
the
feature/MOBILE-269
branch
from
July 14, 2026 10:46
e7d1b91 to
2179679
Compare
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.
https://tracker.yandex.ru/MOBILE-269