diff --git a/src/lib/coredump.ts b/src/lib/coredump.ts index ba649d54f..1f76b69fc 100644 --- a/src/lib/coredump.ts +++ b/src/lib/coredump.ts @@ -109,11 +109,13 @@ export class CoreDumpManager { getWebrtcStats(): Promise { if (!this.engineCommandManager.engineConnection) { - throw new Error('Engine connection not initialized') + // when the engine connection is not available, return an empty object. + return Promise.resolve(JSON.stringify({})) } if (!this.engineCommandManager.engineConnection.webrtcStatsCollector) { - throw new Error('Engine webrtcStatsCollector not initialized') + // when the engine connection is not available, return an empty object. + return Promise.resolve(JSON.stringify({})) } return this.engineCommandManager.engineConnection diff --git a/src/wasm-lib/kcl/src/coredump/mod.rs b/src/wasm-lib/kcl/src/coredump/mod.rs index a48dcb794..9e84afc52 100644 --- a/src/wasm-lib/kcl/src/coredump/mod.rs +++ b/src/wasm-lib/kcl/src/coredump/mod.rs @@ -230,29 +230,42 @@ pub struct OsInfo { #[serde(rename_all = "snake_case")] pub struct WebrtcStats { /// The packets lost. - pub packets_lost: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub packets_lost: Option, /// The frames received. - pub frames_received: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frames_received: Option, /// The frame width. - pub frame_width: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frame_width: Option, /// The frame height. - pub frame_height: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frame_height: Option, /// The frame rate. - pub frame_rate: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frame_rate: Option, /// The number of key frames decoded. - pub key_frames_decoded: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub key_frames_decoded: Option, /// The number of frames dropped. - pub frames_dropped: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub frames_dropped: Option, /// The pause count. - pub pause_count: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pause_count: Option, /// The total pauses duration. - pub total_pauses_duration: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub total_pauses_duration: Option, /// The freeze count. - pub freeze_count: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub freeze_count: Option, /// The total freezes duration. - pub total_freezes_duration: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub total_freezes_duration: Option, /// The pli count. - pub pli_count: u32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pli_count: Option, /// Packet jitter for this synchronizing source, measured in seconds. - pub jitter: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub jitter: Option, }