@mentra/crust 3.5.0-dev.1360 → 3.5.0-dev.1363
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/ios/Source/JSCRuntime.swift +40 -35
- package/package.json +2 -2
|
@@ -184,12 +184,11 @@ public final class JSCRuntime: NSObject {
|
|
|
184
184
|
// "ready", []) flips the record's readyAcked flag (see
|
|
185
185
|
// markReady). If we never see the ack, the timer logs a hung
|
|
186
186
|
// context warning so observability picks it up.
|
|
187
|
-
armReadyNackTimer(record: record, timeoutSeconds: Self.coldStartNackTimeoutSeconds, cold: true)
|
|
188
|
-
|
|
189
187
|
// All evaluation happens on `queue`. We `sync` for the bootstrap so
|
|
190
188
|
// the caller knows whether spawn succeeded before returning.
|
|
191
189
|
var success = true
|
|
192
190
|
queue.sync {
|
|
191
|
+
self.armReadyNackTimer(record: record, timeoutSeconds: Self.coldStartNackTimeoutSeconds, cold: true)
|
|
193
192
|
self.installNativeBridges(ctx: ctx, record: record)
|
|
194
193
|
success = self.evaluateCatching(record: record, label: "polyfill", source: polyfillBundle)
|
|
195
194
|
if success {
|
|
@@ -216,42 +215,48 @@ public final class JSCRuntime: NSObject {
|
|
|
216
215
|
}
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
/// Schedule (or re-schedule)
|
|
220
|
-
///
|
|
218
|
+
/// Schedule (or re-schedule) the NACK timer. Call on `record.queue`, the
|
|
219
|
+
/// only queue that touches `readyNackTimer`, right before the work it
|
|
220
|
+
/// guards, and cancel it there once that work returns.
|
|
221
|
+
///
|
|
222
|
+
/// The timer fires on `watchdogScheduler`, not `record.queue`: a handler
|
|
223
|
+
/// on the context's own queue can't run while an evaluate blocks that
|
|
224
|
+
/// queue, so it could never report a slow one. It was also armed with
|
|
225
|
+
/// `record.queue.async` from a block already on that queue, which queued
|
|
226
|
+
/// the arming behind the delivery: the delivery's cancel ran first, and
|
|
227
|
+
/// every delivery then raised `ready_nack` 3s after it had finished.
|
|
221
228
|
private func armReadyNackTimer(record: Context, timeoutSeconds: TimeInterval, cold: Bool) {
|
|
222
|
-
record.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
)
|
|
229
|
+
record.readyNackTimer?.cancel()
|
|
230
|
+
let packageName = record.packageName
|
|
231
|
+
let timer = DispatchSource.makeTimerSource(queue: Self.watchdogScheduler)
|
|
232
|
+
timer.schedule(deadline: .now() + timeoutSeconds)
|
|
233
|
+
timer.setEventHandler { [weak self] in
|
|
234
|
+
guard let self else { return }
|
|
235
|
+
let phase = cold ? "cold-start" : "steady-state"
|
|
236
|
+
os_log("MentraJS NACK: %{public}@ %{public}@ ready signal not received in %.0fs",
|
|
237
|
+
log: Self.log, type: .error,
|
|
238
|
+
packageName, phase, timeoutSeconds)
|
|
239
|
+
// Surface to RN as a recoverable error frame so the
|
|
240
|
+
// crash controller (if wired) can decide whether to
|
|
241
|
+
// respawn. We don't auto-kill — the spec says "host
|
|
242
|
+
// dispatchToJs returns an error to its caller"; we
|
|
243
|
+
// emit a structured event instead.
|
|
244
|
+
self.lock.withLock { self._onOutbound }?(
|
|
245
|
+
OutboundMessage(
|
|
246
|
+
packageName: packageName,
|
|
247
|
+
payload: [
|
|
248
|
+
"packageName": packageName,
|
|
249
|
+
"iface": "__error",
|
|
250
|
+
"method": "ready_nack",
|
|
251
|
+
"argsJson": JSCRuntime.jsonString(
|
|
252
|
+
from: ["phase": phase, "timeoutSeconds": timeoutSeconds],
|
|
253
|
+
) ?? "{}",
|
|
254
|
+
],
|
|
249
255
|
)
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
record.readyNackTimer = timer
|
|
253
|
-
timer.resume()
|
|
256
|
+
)
|
|
254
257
|
}
|
|
258
|
+
record.readyNackTimer = timer
|
|
259
|
+
timer.resume()
|
|
255
260
|
}
|
|
256
261
|
|
|
257
262
|
/// Diagnostic: force a JSC garbage-collection cycle on the named
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/crust",
|
|
3
|
-
"version": "3.5.0-dev.
|
|
3
|
+
"version": "3.5.0-dev.1363",
|
|
4
4
|
"description": "Mentra Native Module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"license": "Apache-2.0",
|
|
36
36
|
"homepage": "https://github.com/Mentra-Community/MentraOS/tree/dev/mobile/modules/crust#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@mentra/jspolyfill": "3.5.0-dev.
|
|
38
|
+
"@mentra/jspolyfill": "3.5.0-dev.1363"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@expo/config-plugins": ">=8.0.0",
|