@otaupdate/react-native 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -320,3 +320,5 @@ compatible with. Devices on other binary versions never receive it.
320
320
  | `no_matching_binary_version` | The release's `targetBinaryVersion` does not cover the installed native version. |
321
321
  | Works in debug, not release | Debug builds load from Metro; the OTA path only runs in release builds. |
322
322
  | Android: mandatory update reload-loops (bare RN) | Fixed in 1.0.2. Before that, `IMMEDIATE`/`ON_NEXT_RESUME` tried an in-place JS reload that reused a bundle path fixed at process start, so the same mandatory update kept re-triggering forever. 1.0.2 does a real process restart instead — update to it. |
323
+ | A newer update never shows up, app stays on an older-than-expected release | Fixed in 1.0.3. `notifyApplicationReady()` used to clear *any* pending hash unconditionally — if a second update was downloaded and queued for a future restart while the first one was still being confirmed, its pending state was silently wiped and the device never advanced to it. |
324
+ | Android: old screen briefly visible during a mandatory/resume install | Improved in 1.0.3. The process-restart fix in 1.0.2 is correct but showed Android's default activity-transition animation (old screen sliding/fading out). 1.0.3 suppresses it via `overridePendingTransition(0, 0)` so the switch is instant. |
@@ -246,7 +246,25 @@ class OtaUpdateModule(private val reactContext: ReactApplicationContext) :
246
246
  try {
247
247
  val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)
248
248
  ?: throw IllegalStateException("no launch intent for ${context.packageName}")
249
- context.startActivity(Intent.makeRestartActivityTask(launchIntent.component))
249
+ val restartIntent = Intent.makeRestartActivityTask(launchIntent.component)
250
+
251
+ // Starting the restart from the current Activity (when one is attached)
252
+ // instead of the bare application context lets us suppress the default
253
+ // activity-transition animation right after — otherwise Android
254
+ // animates the old screen sliding/fading out while the new one comes
255
+ // in, so the old content stays visibly on screen for the transition's
256
+ // duration. overridePendingTransition(0, 0) makes the switch instant
257
+ // instead. Falls back to starting from the application context if no
258
+ // activity is currently attached — the restart still works, just with
259
+ // the default (visible) transition.
260
+ val activity = reactContext.currentActivity
261
+ if (activity != null) {
262
+ activity.startActivity(restartIntent)
263
+ @Suppress("DEPRECATION")
264
+ activity.overridePendingTransition(0, 0)
265
+ } else {
266
+ context.startActivity(restartIntent)
267
+ }
250
268
  Runtime.getRuntime().exit(0)
251
269
  } catch (e: Exception) {
252
270
  Log.e(OtaUpdateStore.TAG, "failed to restart the app process", e)
@@ -147,10 +147,21 @@ class OtaUpdateStore(private val context: Context) {
147
147
  return true
148
148
  }
149
149
 
150
- /** Confirms the running bundle. After this it can never be rolled back. */
150
+ /**
151
+ * Confirms the running bundle. After this it can never be rolled back.
152
+ *
153
+ * Only confirms when `pendingIsLoading` is true — meaning this session
154
+ * actually booted into `pendingHash` via `promotePendingIfAny()`. A
155
+ * `pendingHash` set by `markPending()` describes a *different*, newer
156
+ * package downloaded and queued for a *future* restart, not something
157
+ * running right now. Clearing it here — as an earlier version of this
158
+ * method did unconditionally — silently discarded that queued update: the
159
+ * next restart would find nothing pending and keep loading the older
160
+ * package, i.e. "the newly downloaded update never shows up."
161
+ */
151
162
  @Synchronized
152
163
  fun notifyApplicationReady() {
153
- if (pendingHash == null) return
164
+ if (pendingHash == null || !pendingIsLoading) return
154
165
  Log.i(TAG, "update ${pendingHash} confirmed healthy")
155
166
  lastConfirmedHash = currentHash
156
167
  pendingHash = null
@@ -143,9 +143,19 @@ static NSString *const kLogTag = @"[OtaUpdate]";
143
143
  }
144
144
  }
145
145
 
146
+ /**
147
+ * Confirms the running bundle. After this it can never be rolled back.
148
+ *
149
+ * Only confirms when pendingIsLoading is YES — meaning this session actually
150
+ * booted into pendingHash via promotePendingIfAny. A pendingHash set by
151
+ * markPending: describes a *different*, newer package downloaded and queued
152
+ * for a *future* restart, not something running right now. Clearing it here
153
+ * unconditionally (as an earlier version of this method did) silently
154
+ * discarded that queued update.
155
+ */
146
156
  - (void)notifyApplicationReady {
147
157
  @synchronized(self) {
148
- if (!self.pendingHash) return;
158
+ if (!self.pendingHash || !self.pendingIsLoading) return;
149
159
  NSLog(@"%@ update %@ confirmed healthy", kLogTag, self.pendingHash);
150
160
  self.lastConfirmedHash = self.currentHash;
151
161
  self.pendingHash = nil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otaupdate/react-native",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Over-the-air JS bundle updates for React Native \u2014 bare and Expo",
5
5
  "license": "MIT",
6
6
  "publishConfig": {