Skip to content

Commit 961a8bc

Browse files
committed
fix: update JS bundle loading for OTA reload to prevent app loop
1 parent b5b5f7d commit 961a8bc

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

android/src/main/java/com/mendix/mendixnative/react/NativeReloadHandler.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,25 @@ class NativeReloadHandler(val context: ReactApplicationContext) {
5151

5252
private fun handleJSBundleLoading() {
5353
val bundle = (context.applicationContext as MendixApplication).jsBundleFile
54-
val instanceManager =
55-
(context.applicationContext as ReactApplication).reactNativeHost.reactInstanceManager
5654

5755
val latestJSBundleLoader = if (bundle != null) {
5856
getAssetLoader(bundle)
5957
} else {
6058
getAssetLoader("assets://index.android.bundle")
61-
}
59+
} ?: return
6260

63-
ReflectionUtils.setField(instanceManager, "mBundleLoader", latestJSBundleLoader)
64-
ReflectionUtils.setField(
65-
instanceManager,
66-
"mUseDeveloperSupport",
67-
(context.applicationContext as MendixApplication).useDeveloperSupport
68-
)
61+
// New Architecture (Bridgeless): on reload, ReactHostImpl loads the bundle from
62+
// its ReactHostDelegate.jsBundleLoader, which is captured once at host-creation
63+
// time and never re-consults getJSBundleFile(). Without updating it here, a warm
64+
// reload keeps loading the original bundle, so a freshly-deployed OTA bundle is
65+
// never picked up and the app loops: download -> deploy -> reload -> same bundle.
66+
val reactHost = (context.applicationContext as? ReactApplication)?.reactHost ?: return
67+
try {
68+
val delegate = ReflectionUtils.getField<Any>(reactHost, "mReactHostDelegate")
69+
ReflectionUtils.setField(delegate, "jsBundleLoader", latestJSBundleLoader)
70+
} catch (e: Exception) {
71+
FLog.e(javaClass, "Failed to update JS bundle loader for OTA reload", e)
72+
}
6973
}
7074

7175
private fun getAssetLoader(bundle: String): JSBundleLoader? {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mendix-native",
3-
"version": "0.3.0",
3+
"version": "0.3.2",
44
"description": "Mendix native mobile package",
55
"main": "./lib/module/index.js",
66
"types": "./lib/typescript/src/index.d.ts",

0 commit comments

Comments
 (0)