fix(audio,voice,log): six P0 issues from Korean Windows test
1. Voice Bar 'Leave voice' button removed entirely. TeamSpeak users are always in some channel; Discord/Mumble-style leave is the wrong model. To stop being heard / hearing, mute mic / speaker. To physically move, tap a different channel. The voiceLeave bridge call + _onLeaveVoice stay as dead code for now (marked unused) so existing tests/integrations don't break. 2. voice_join now confirms the move actually applied server-side by polling the snapshot for up to 1.5 s and matching our own client's channel against the requested one. If the server rejected the move (no permission, wrong password, channel full), voice_join rolls the selector back to in_channel=false and returns Err so the UI surfaces the failure instead of showing a fake 'joined' state. 3. ServerSnapshot + BridgeSnapshot gain own_client_id so the UI can identify our row without name-matching. find_own_in reads it directly. 4. set_self_muted now also clamps the TransmitModeSelector's hard_mute when input is muted server-side. Without this, the Opus encoder kept producing frames after setInputMuted(true), tsclientlib refused each one with 'Sending audio while muted', and the log grew to 200 MB on the Korean host. 5. tsclientlib WARN spam suppressed via tracing filter (tsclientlib=error). Belt-and-braces on top of fix 4. 6. Log file is now rotated at every launch (not just when >4 MiB). Two generations kept: chanora.log.1 (previous) and chanora.log.2 (the one before). The bug that produced 200 MB files was a chatty subsystem flooding a single session; the per-launch rotate keeps disk use bounded by what one session can produce in its lifetime. Bonus Windows fix (separate from the six but found in the same log): the Raw Input + Hook backends now signal readiness BEFORE blocking on GetMessageW. Previously init_tx.send was called after the loop returned (i.e. on WM_QUIT, which never happens during arming), so the main thread's 2 s readiness probe always timed out and the backend reported L0Focused even when registration succeeded. Both run_raw_input_loop and run_hook_loop now take an init_tx parameter and call report!(true) right after a successful registration, and report!(false) on every early-fail return. cargo check --workspace: clean. cargo test --workspace --lib: 80 passed / 0 failed / 1 ignored. flutter analyze: clean (6 pre-existing Radio.groupValue infos).
This commit is contained in:
@@ -55,7 +55,8 @@ fn log_sink() -> &'static chanora_core::InMemoryLogSink {
|
||||
/// `tsproto::resend` and `tsproto::packet_codec` paths that
|
||||
/// flood the diagnostic export during transient packet loss;
|
||||
/// users can still raise verbosity via `RUST_LOG=info`.
|
||||
const DEFAULT_LOG_FILTER: &str = "info,tsproto::resend=error,tsproto::packet_codec=error";
|
||||
const DEFAULT_LOG_FILTER: &str =
|
||||
"info,tsproto::resend=error,tsproto::packet_codec=error,tsclientlib=error";
|
||||
|
||||
/// Initialise the bridge. Must be called once on Dart side before
|
||||
/// any other API call. Sets up panic logging.
|
||||
@@ -193,17 +194,32 @@ fn open_log_file() -> Option<std::fs::File> {
|
||||
if let Some(parent) = path.parent() {
|
||||
let _ = std::fs::create_dir_all(parent);
|
||||
}
|
||||
// Rotate: if the existing file exceeds 4 MiB rename it to .1 so
|
||||
// we never grow unbounded. One generation is enough for
|
||||
// debugging; we are not building a real log-rotation system.
|
||||
if let Ok(meta) = std::fs::metadata(&path) {
|
||||
if meta.len() > 4 * 1024 * 1024 {
|
||||
let _ = std::fs::rename(&path, path.with_extension("log.1"));
|
||||
}
|
||||
// Rotate at every launch (not on size). A single session can
|
||||
// emit huge logs when a chatty subsystem floods (the original
|
||||
// bug that surfaced this: tsclientlib emitting one warning per
|
||||
// outbound voice frame while server-side muted). Truncating on
|
||||
// every launch keeps per-session disk use bounded by what one
|
||||
// session can produce in its lifetime; the on-launch rotate
|
||||
// also gives the previous session's log a stable home at
|
||||
// `chanora.log.1` for post-mortem inspection.
|
||||
//
|
||||
// Two generations kept: `chanora.log.1` (previous launch) and
|
||||
// `chanora.log.2` (the one before that). Older generations
|
||||
// are deleted to keep disk use bounded across many launches.
|
||||
if path.exists() {
|
||||
let g1 = path.with_extension("log.1");
|
||||
let g2 = path.with_extension("log.2");
|
||||
// .2 is dropped; .1 becomes .2; current becomes .1.
|
||||
let _ = std::fs::remove_file(&g2);
|
||||
let _ = std::fs::rename(&g1, &g2);
|
||||
let _ = std::fs::rename(&path, &g1);
|
||||
}
|
||||
// Open fresh (truncate if rename somehow failed so we never
|
||||
// append onto a stale file).
|
||||
std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
.open(&path)
|
||||
.ok()
|
||||
}
|
||||
@@ -251,6 +267,10 @@ pub struct BridgeSnapshot {
|
||||
pub channels: Vec<BridgeChannel>,
|
||||
/// Clients currently known.
|
||||
pub clients: Vec<BridgeClient>,
|
||||
/// Our own client id. Useful for the UI to highlight our row
|
||||
/// in the client list and to know which channel we are in
|
||||
/// without trusting the optimistic local state.
|
||||
pub own_client_id: u64,
|
||||
}
|
||||
|
||||
impl From<chanora_protocol::ServerSnapshot> for BridgeSnapshot {
|
||||
@@ -279,6 +299,7 @@ impl From<chanora_protocol::ServerSnapshot> for BridgeSnapshot {
|
||||
name: c.name,
|
||||
})
|
||||
.collect(),
|
||||
own_client_id: s.own_client_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user