@3dsource/angular-unreal-module 0.0.146-dev.7 → 0.0.146-dev.8

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.
@@ -6122,81 +6122,76 @@ class StreamStatusTelemetryService2 {
6122
6122
  /**
6123
6123
  * Emit the region / signaling / webrtc phases for an ADOPTED connection.
6124
6124
  *
6125
- * The prefetch script established the connection in parallel with page load,
6126
- * so its raw timeline (prefetch_start … ready) mostly predates this session —
6127
- * showing it verbatim would look identical to a non-prefetched connect. What
6128
- * matters is measured from the moment Angular reached the connect call
6129
- * (session start, == `lastMilestonePerf` here): the REAL wait until adoption,
6130
- * and how much the prefetch SAVED by finishing the handshake during page load.
6131
- *
6132
- * So the three phases fill exactly the `[session start → adopted]` window
6133
- * (split across signaling / webrtc by the prefetch's own sub-step ratio; the
6134
- * region was served from cache → ~0), and the savings figures ride in params:
6135
- * - `prefetchConnectMs` — full handshake the prefetch measured (the cost a
6136
- * cold, non-prefetched connect would pay here).
6137
- * - `prefetchSavedMs` — how much of it completed before Angular was ready.
6138
- * - `adoptionWaitMs` — the actual wait Angular experienced (= window).
6139
- * - `adoptionOverheadMs` — gap between prefetch-ready and adoption.
6125
+ * The prefetch script established the connection in PARALLEL with page load,
6126
+ * so the phases are positioned at their real (anchor-relative) spans — shifted
6127
+ * LEFT to overlap the HTML-loading / route-idle rows — rather than sequentially
6128
+ * after them. That's the whole point of the prefetch: the handshake already
6129
+ * happened while the page was loading. Each phase ships:
6130
+ * - `duration` — the real sub-step time the prefetch spent.
6131
+ * - `spanStartMs` — anchor-relative start, so the viewer left-shifts the bar.
6132
+ * - `adoptionAtMs` — where Angular took over (the next phase, Unreal
6133
+ * communication, resumes here on the sequential timeline).
6134
+ * - savings params: `prefetchConnectMs` (full handshake), `prefetchSavedMs`
6135
+ * (done before Angular was ready), `adoptionWaitMs` (real connect→adopted
6136
+ * wait), `adoptionOverheadMs` (prefetch-ready → adopted gap).
6140
6137
  */
6141
6138
  emitAdoptedConnection(timings) {
6142
6139
  const s = this.session;
6143
6140
  if (!s)
6144
6141
  return;
6145
6142
  const t = timings ?? {};
6146
- const start = t['prefetch_start'] ?? s.startedAtPerf;
6147
- const wsOpen = t['ws_open'] ?? start;
6148
- const ready = t['ready'] ?? t['dc_open'] ?? wsOpen;
6149
- // Real prefetch sub-durations — how the handshake actually broke down.
6150
- const sigRaw = Math.max(0, wsOpen - start);
6151
- const webRaw = Math.max(0, ready - wsOpen);
6152
- const connectMs = Math.round(sigRaw + webRaw);
6153
- // `lastMilestonePerf` is still pinned at session start (the connection
6154
- // closers are suppressed for adopted sessions), so this is the genuine
6155
- // connect → adopted wait the user lived through.
6156
6143
  const now = performance.now();
6157
- const waitMs = Math.max(0, Math.round(now - s.lastMilestonePerf));
6158
- // What running the handshake during page load bought us: the part already
6159
- // done by the time Angular reached the connect call.
6160
- const savedMs = Math.max(0, Math.min(connectMs, Math.round(s.startedAtPerf - start)));
6161
- const adoptionOverheadMs = Math.max(0, Math.round(now - ready));
6144
+ // Everything in anchor-relative ms — the same scale the viewer renders on
6145
+ // (and the prefetch marks share the page `performance` clock).
6146
+ const toMs = (perf) => Math.round(perf - s.anchorPerf);
6147
+ const startMs = toMs(t['prefetch_start'] ?? s.startedAtPerf);
6148
+ const wsOpenMs = Math.max(startMs, toMs(t['ws_open'] ?? t['prefetch_start'] ?? s.startedAtPerf));
6149
+ const readyMs = Math.max(wsOpenMs, toMs(t['ready'] ?? t['dc_open'] ?? t['ws_open'] ?? s.startedAtPerf));
6150
+ const adoptionAtMs = toMs(now);
6151
+ const sessionStartMs = toMs(s.startedAtPerf);
6152
+ const sigDur = wsOpenMs - startMs;
6153
+ const webDur = readyMs - wsOpenMs;
6154
+ const connectMs = readyMs - startMs;
6155
+ // Savings, anchored at the moment Angular reached the connect call.
6162
6156
  const savings = {
6163
6157
  prefetched: true,
6164
6158
  prefetchConnectMs: connectMs,
6165
- prefetchSavedMs: savedMs,
6166
- adoptionWaitMs: waitMs,
6167
- adoptionOverheadMs,
6159
+ // How much of the handshake finished before Angular was ready (the win).
6160
+ prefetchSavedMs: Math.max(0, Math.min(connectMs, sessionStartMs - startMs)),
6161
+ // The real wait Angular experienced (connect call → adopted).
6162
+ adoptionWaitMs: Math.max(0, adoptionAtMs - sessionStartMs),
6163
+ // Gap between the prefetch being ready and Angular adopting it.
6164
+ adoptionOverheadMs: Math.max(0, adoptionAtMs - readyMs),
6168
6165
  };
6169
- // Split the real wait across signaling / webrtc by the prefetch's own
6170
- // signaling:webrtc proportion.
6171
- const denom = sigRaw + webRaw;
6172
- const sigMs = denom > 0 ? Math.round((waitMs * sigRaw) / denom) : 0;
6173
- const webMs = Math.max(0, waitMs - sigMs);
6174
6166
  // Region (phaseNo 1) — served from the ping cache during prefetch (~0),
6175
- // but ship the samples so the phase still carries its data.
6167
+ // positioned at the prefetch start; ship the samples.
6176
6168
  const region = this.readRegionCache();
6177
- this.emitAdoptedPhase(0, 0, {
6169
+ this.emitAdoptedPhase(0, startMs, 0, adoptionAtMs, {
6178
6170
  region: region?.region_code ?? '',
6179
- pingsMs: region?.result.length
6180
- ? `${region.result.join(', ')} ms`
6181
- : null,
6182
- prefetched: true,
6183
- }, []);
6184
- // Signaling (phaseNo 2) — carries the streamer identity + savings summary.
6185
- this.emitAdoptedPhase(1, sigMs, {
6171
+ pingsMs: region?.result.length ? `${region.result.join(', ')} ms` : null,
6172
+ });
6173
+ // Signaling (phaseNo 2) — [prefetch_start → ws_open]; streamer identity +
6174
+ // savings; ws-connected marker sits at the phase's own end.
6175
+ this.emitAdoptedPhase(1, startMs, sigDur, adoptionAtMs, {
6186
6176
  ...this.adoptedSignalingParams(),
6187
6177
  ...savings,
6188
- prefetchSignalingMs: Math.round(sigRaw),
6189
- }, [{ id: 'signaling-ws-connected', time: Math.round(wsOpen) }]);
6190
- // WebRTC negotiation (phaseNo 3).
6191
- this.emitAdoptedPhase(2, webMs, {
6178
+ prefetchSignalingMs: sigDur,
6179
+ }, [{ id: 'signaling-ws-connected', time: wsOpenMs }]);
6180
+ // WebRTC negotiation (phaseNo 3) — [ws_open → ready].
6181
+ this.emitAdoptedPhase(2, wsOpenMs, webDur, adoptionAtMs, {
6192
6182
  iceCandidateCount: 0,
6193
- prefetched: true,
6194
- prefetchWebrtcMs: Math.round(webRaw),
6195
- }, []);
6183
+ prefetchWebrtcMs: webDur,
6184
+ });
6185
+ // Unreal communication chains from the adoption moment (real wall-clock).
6186
+ s.lastMilestonePerf = now;
6196
6187
  }
6197
- /** Emit one adopted phase with an explicit (prefetch-derived) duration and
6198
- * advance `lastMilestonePerf` synthetically so the next phase chains right. */
6199
- emitAdoptedPhase(bucketIdx, durationMs, extras, milestones) {
6188
+ /**
6189
+ * Emit one adopted phase positioned at its real `spanStartMs` (left-shifted
6190
+ * to overlap page load) with its real prefetch `duration`. `prefetched`,
6191
+ * `spanStartMs` and `adoptionAtMs` ride as top-level wire fields the viewer
6192
+ * uses to lay the bar out; the rest become display params.
6193
+ */
6194
+ emitAdoptedPhase(bucketIdx, spanStartMs, durationMs, adoptionAtMs, extras, milestones = []) {
6200
6195
  const s = this.session;
6201
6196
  if (!s)
6202
6197
  return;
@@ -6207,11 +6202,13 @@ class StreamStatusTelemetryService2 {
6207
6202
  id: bucket.id,
6208
6203
  color: bucket.color,
6209
6204
  duration: durationMs,
6205
+ prefetched: true,
6206
+ spanStartMs,
6207
+ adoptionAtMs,
6210
6208
  milestones,
6211
- params: toPhaseParams(extras),
6209
+ params: toPhaseParams({ ...extras, prefetched: true }),
6212
6210
  overlays: [],
6213
6211
  });
6214
- s.lastMilestonePerf += durationMs;
6215
6212
  }
6216
6213
  /** Streamer identity params for the adopted signaling phase — mirrors the
6217
6214
  * `ssinfo-received` closer's shape (client / instanceName / …ssData). */