remoteSnapshot method
Serves remote snapshot requests after flushing any pending frame work.
This is the snapshot provider wired into the remote session endpoint. It is intentionally exposed for development-only frame-regression tests, like createCommandExecutor.
Implementation
@visibleForTesting
Future<CockpitSnapshot> remoteSnapshot({
required CockpitSnapshotOptions options,
}) async {
final binding = WidgetsBinding.instance;
if (_isTestBinding(binding)) {
return snapshot(options: options);
}
// The visual-frame flight is shared process-wide and joined without a
// bound of its own, so a flight parked on a frame a wedged engine will
// never produce must not park the snapshot behind it.
String? degradationReason;
try {
await ensureCockpitVisualFrame(
platform: resolveCockpitRemoteSessionPlatform(
isWeb: kIsWeb,
targetPlatform: defaultTargetPlatform,
),
).timeout(const Duration(milliseconds: 750));
} on TimeoutException {
degradationReason = cockpitFrameTimeoutDegradationReason;
}
final frameWait = await waitForPendingCockpitFrame(
phase: binding.schedulerPhase,
hasScheduledFrame: binding.hasScheduledFrame,
waitForEndOfFrame: () => binding.endOfFrame,
);
if (frameWait == CockpitPendingFrameWaitResult.timedOut) {
degradationReason = cockpitFrameTimeoutDegradationReason;
}
final currentSnapshot = snapshot(options: options);
return currentSnapshot.copyWith(
degradationReason: _mergeDegradationReasons(
currentSnapshot.degradationReason,
degradationReason,
),
);
}