From f2aeff974cbc4e9cc7ce3e53e5064e96b2110c0f Mon Sep 17 00:00:00 2001 From: 21pages Date: Tue, 4 Apr 2023 20:35:04 +0800 Subject: [PATCH] disable hwcodec if causing crash Signed-off-by: 21pages --- libs/hbb_common/src/platform/mod.rs | 10 ++++++++++ libs/scrap/src/common/codec.rs | 23 +++++++++++++---------- src/ui_session_interface.rs | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libs/hbb_common/src/platform/mod.rs b/libs/hbb_common/src/platform/mod.rs index c37c8aaf5..c1c766753 100644 --- a/libs/hbb_common/src/platform/mod.rs +++ b/libs/hbb_common/src/platform/mod.rs @@ -29,6 +29,16 @@ extern "C" fn breakdown_signal_handler(sig: i32) { info = "Always use software rendering will be set.".to_string(); log::info!("{}", info); } + if stack.iter().any(|s| { + s.to_lowercase().contains("nvidia") + || s.to_lowercase().contains("amf") + || s.to_lowercase().contains("mfx") + || s.contains("cuProfilerStop") + }) { + Config::set_option("enable-hwcodec".to_string(), "N".to_string()); + info = "Perhaps hwcodec causing the crash, disable it first".to_string(); + log::info!("{}", info); + } log::error!( "Got signal {} and exit. stack:\n{}", sig, diff --git a/libs/scrap/src/common/codec.rs b/libs/scrap/src/common/codec.rs index 3209933b4..a3d8a0696 100644 --- a/libs/scrap/src/common/codec.rs +++ b/libs/scrap/src/common/codec.rs @@ -109,6 +109,7 @@ impl Encoder { }), Err(e) => { check_config_process(true); + *CODEC_NAME.lock().unwrap() = CodecName::VP9; Err(e) } }, @@ -144,16 +145,18 @@ impl Encoder { let mut h265_name = None; #[cfg(feature = "hwcodec")] { - let best = HwEncoder::best(); - let h264_useable = - decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h264 > 0); - let h265_useable = - decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h265 > 0); - if h264_useable { - h264_name = best.h264.map_or(None, |c| Some(c.name)); - } - if h265_useable { - h265_name = best.h265.map_or(None, |c| Some(c.name)); + if enable_hwcodec_option() { + let best = HwEncoder::best(); + let h264_useable = + decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h264 > 0); + let h265_useable = + decodings.len() > 0 && decodings.iter().all(|(_, s)| s.ability_h265 > 0); + if h264_useable { + h264_name = best.h264.map_or(None, |c| Some(c.name)); + } + if h265_useable { + h265_name = best.h265.map_or(None, |c| Some(c.name)); + } } } diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index f7a4a7334..18ef27cc0 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -544,7 +544,7 @@ impl Session { let key = rdev::key_from_code(position_code) as rdev::Key; // Windows requires special handling #[cfg(target_os = "windows")] - let key = rdev::get_win_key(keycode, scancode); + let key = rdev::get_win_key(platform_code, position_code); let event_type = if down_or_up { KeyPress(key)