From 9a81bc8213d83c9e4cfcd6724873e6828abfdb27 Mon Sep 17 00:00:00 2001 From: caszuu Date: Sat, 21 Feb 2026 18:52:13 +0100 Subject: [PATCH] ignore network errors instead of crashing wrap some code paths which could cause uncaught exceptions if called from one of the monado owned threads. --- server/driver/tracking_control.cpp | 11 +++++++++-- server/driver/wivrn_comp_target.cpp | 10 +++++++++- server/driver/wivrn_session.cpp | 11 +++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/server/driver/tracking_control.cpp b/server/driver/tracking_control.cpp index 1cb6c3ee..2755f987 100644 --- a/server/driver/tracking_control.cpp +++ b/server/driver/tracking_control.cpp @@ -43,8 +43,15 @@ void wivrn::tracking_control::add_request(device_id device, XrTime now, XrTime a if (not std::ranges::contains(last_control.pattern, device, &to_headset::tracking_control::sample::device)) { - last_control.pattern.push_back({.device = device, .prediction_ns = prediction}); - cnx.send_control(to_headset::tracking_control(last_control)); + try + { + cnx.send_control(to_headset::tracking_control(last_control)); + last_control.pattern.push_back({.device = device, .prediction_ns = prediction}); + } + catch (...) + { + // ignore network errors + } } } diff --git a/server/driver/wivrn_comp_target.cpp b/server/driver/wivrn_comp_target.cpp index 92d4081b..3142a195 100644 --- a/server/driver/wivrn_comp_target.cpp +++ b/server/driver/wivrn_comp_target.cpp @@ -785,7 +785,15 @@ static xrt_result_t comp_wivrn_request_refresh_rate(struct comp_target * ct, flo if (refresh_rate_hz == 0.0f) refresh_rate_hz = get_default_rate(cn->cnx.get_info(), *cn->cnx.get_settings()); - cn->cnx.send_control(to_headset::refresh_rate_change{.fps = refresh_rate_hz}); + try + { + cn->cnx.send_control(to_headset::refresh_rate_change{.fps = refresh_rate_hz}); + } + catch (...) + { + // ignore network errors + } + return XRT_SUCCESS; } diff --git a/server/driver/wivrn_session.cpp b/server/driver/wivrn_session.cpp index 86c97a48..32f1e05f 100644 --- a/server/driver/wivrn_session.cpp +++ b/server/driver/wivrn_session.cpp @@ -1018,8 +1018,15 @@ void wivrn_session::run_net(std::stop_token stop) if (stop.stop_requested()) break; - resume_session(); - U_LOG_I("Headset connected, Session resumed."); + try + { + resume_session(); + U_LOG_I("Headset connected, Session resumed."); + } + catch (const std::exception & e) + { + U_LOG_E("Exception on session resume: %s", e.what()); + } } } }