An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
refact: rust backtrace logs (#13467)
fufesou934d6c3987d4
diff --git a/src/common.rs b/src/common.rsindex 5d6d2ba7d..4ac3b6cd9 100644--- a/src/common.rs+++ b/src/common.rs@@ -115,50 +115,6 @@ pub fn global_init() -> bool {crate::server::wayland::init();}}- // Install panic hook to log backtrace on all platforms- std::env::set_var("RUST_BACKTRACE", "1");- std::panic::set_hook(Box::new(|info| {- let thread = std::thread::current().name().unwrap_or("unnamed");- let location = info- .location()- .map(|l| format!("{}:{}:{}", l.file(), l.line(), l.column()))- .unwrap_or_else(|| "unknown".into());- let msg = if let Some(s) = info.payload().downcast_ref::<&str>() {- *s- } else if let Some(s) = info.payload().downcast_ref::<String>() {- s.as_str()- } else {- "Box<Any>"- };- let bt = std::backtrace::Backtrace::force_capture();- let out = format!("thread '{}' panicked at '{}', {}\nBacktrace:\n{bt:?}", thread, msg, location);- eprintln!("{}", out);- log::error!("{}", out);- }));- // Native crash handlers- #[cfg(unix)]- unsafe {- extern "C" fn crash_signal_handler(sig: libc::c_int) {- let bt = std::backtrace::Backtrace::force_capture();- eprintln!("native crash signal {}\nBacktrace:\n{bt:?}", sig);- log::error!("native crash signal {}\nBacktrace:\n{bt:?}", sig);- }- for &s in &[libc::SIGSEGV, libc::SIGABRT, libc::SIGILL, libc::SIGFPE, libc::SIGBUS] {- libc::signal(s, crash_signal_handler as usize);- }- }- #[cfg(windows)]- unsafe {- use winapi::um::{errhandlingapi::SetUnhandledExceptionFilter, minwinbase::EXCEPTION_POINTERS};- extern "system" fn unhandled_exception_filter(_: *mut EXCEPTION_POINTERS) -> i32 {- let bt = std::backtrace::Backtrace::force_capture();- eprintln!("native unhandled exception\nBacktrace:\n{bt:?}");- log::error!("native unhandled exception\nBacktrace:\n{bt:?}");- // EXCEPTION_EXECUTE_HANDLER = 1- 1- }- SetUnhandledExceptionFilter(Some(unhandled_exception_filter));- }true}diff --git a/src/core_main.rs b/src/core_main.rsindex 7347c1895..ecef5a45a 100644--- a/src/core_main.rs+++ b/src/core_main.rs@@ -29,6 +29,9 @@ macro_rules! my_println{/// If it returns [`Some`], then the process will continue, and flutter gui will be started.#[cfg(not(any(target_os = "android", target_os = "ios")))]pub fn core_main() -> Option<Vec<String>> {+ if !crate::common::global_init() {+ return None;+ }crate::load_custom_client();#[cfg(windows)]if !crate::platform::windows::bootstrap() {diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rsindex 15ffd52b8..ce9954b14 100644--- a/src/flutter_ffi.rs+++ b/src/flutter_ffi.rs@@ -70,6 +70,10 @@ fn initialize(app_dir: &str, custom_client_config: &str) {init_from_env(Env::default().filter_or(DEFAULT_FILTER_ENV, "debug"));crate::common::test_nat_type();}+ #[cfg(any(target_os = "android", target_os = "ios"))]+ {+ let _ = crate::common::global_init();+ }#[cfg(not(any(target_os = "android", target_os = "ios")))]{// core_main's init_log does not work for flutter since it is only applied to its load_library in main.cdiff --git a/src/main.rs b/src/main.rsindex 274d7735c..9bc90a8fa 100644--- a/src/main.rs+++ b/src/main.rs@@ -23,9 +23,6 @@ fn main() {feature = "flutter")))]fn main() {- if !common::global_init() {- return;- }#[cfg(all(windows, not(feature = "inline")))]unsafe {winapi::um::shellscalingapi::SetProcessDpiAwareness(2);