feat: host the server-delivered mobile core (JS brain) in a hidden WebView with native fallback - #59
Draft
pandeymangg wants to merge 1 commit into
Conversation
…bView with native fallback
|
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.


Ref ENG-2912
What & why
Was: The survey display decision (display types, recontact days, segments, display percentage, language resolution) is compiled into the SDK; changing it requires an SDK release plus a customer app store release.
Now:
setup()fetches a small JS bundle from the Formbricks server (/js/mobile/v1/core.umd.cjs), evaluates it in a hidden, never-attached WebView (Play-policy-exempt interpreter path), andtrack()asks it which survey to show. Any failure — no bundle, wrong protocol version, evaluation error, unreadable decision — falls back to the untouched native logic (nativeTrack), so behaviour without a bundle is identical to today. The brain receives the raworiginalResponseMapJSON, so no native re-encoding sits in the bridge contract.First Android PR of the JS-brain epic (targets
epic/js-brain, not main). Server side: formbricks/formbricks#9152 · iOS twin: formbricks/ios#55.Where to look
android/src/main/java/com/formbricks/android/mobilecore/MobileCoreRuntime.kt— off-screen WebView host, main-thread confined, protocol-version gateandroid/src/main/java/com/formbricks/android/mobilecore/MobileCoreLoader.kt— OkHttp fetch + per-host SharedPreferences cacheandroid/src/main/java/com/formbricks/android/manager/SurveyManager.kt— brain-firsttrack(), native path unchanged as fallbackTesting
MobileCoreRuntimeInstrumentedTest(init validation, protocol rejection, state pass-through across the bridge, brain-throws fallback, loader URL shape).setLanguage("hi")→ survey in Hindi, response persisted ashi-IN).Draft — remaining scope for ENG-2912
FormbricksConfig(disable remote code for enterprise policies).Note
AI model used —
claude-fable-5, reasoning effortunknown.