optional software render to fix flutter render problem on some nvidia

card

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-01-05 14:27:28 +08:00
parent 9117d6956c
commit 5f6a264278
36 changed files with 175 additions and 2 deletions

1
Cargo.lock generated
View File

@ -4562,6 +4562,7 @@ dependencies = [
"arboard",
"async-process",
"async-trait",
"backtrace",
"base64",
"bytes",
"cc",

View File

@ -119,6 +119,7 @@ dbus-crossroads = "0.5"
gtk = "0.15"
libappindicator = "0.7"
glib = "0.16.5"
backtrace = "0.3"
[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.11"

View File

@ -274,6 +274,15 @@ class _GeneralState extends State<_General> {
_OptionCheckBox(context, 'Confirm before closing multiple tabs',
'enable-confirm-closing-tabs'),
_OptionCheckBox(context, 'Adaptive Bitrate', 'enable-abr'),
if (Platform.isLinux)
Tooltip(
message: translate('software_render_tip'),
child: _OptionCheckBox(
context,
"Always use software rendering",
'allow-always-software-render',
),
)
]);
}
@ -1223,7 +1232,7 @@ Widget _OptionCheckBox(BuildContext context, String label, String key,
ref.value = option;
if (reverse) option = !option;
String value = bool2option(key, option);
bind.mainSetOption(key: key, value: value);
await bind.mainSetOption(key: key, value: value);
update?.call();
}
}

View File

@ -38,6 +38,17 @@ pub fn core_main() -> Option<Vec<String>> {
}
i += 1;
}
#[cfg(target_os = "linux")]
#[cfg(feature = "flutter")]
{
crate::platform::linux::register_breakdown_handler();
let (k, v) = ("LIBGL_ALWAYS_SOFTWARE", "true");
if !hbb_common::config::Config::get_option("allow-always-software-render").is_empty() {
std::env::set_var(k, v);
} else {
std::env::remove_var(k);
}
}
#[cfg(feature = "flutter")]
if _is_flutter_connect {
return core_main_invoke_new_connection(std::env::args());

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", "被web控制台手动关闭"),
("Local keyboard type", "本地键盘类型"),
("Select local keyboard type", "请选择本地键盘类型"),
("software_render_tip", "如果你使用英伟达显卡, 并且远程窗口在会话建立后会立刻关闭, 那么安装nouveau驱动并且选择使用软件渲染可能会有帮助。重启软件后生效。"),
("Always use software rendering", "使用软件渲染"),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", "Manuell über die Webkonsole beendet"),
("Local keyboard type", "Lokaler Tastaturtyp"),
("Select local keyboard type", "Lokalen Tastaturtyp auswählen"),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -36,5 +36,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("hide_cm_tip", "Allow hiding only if accepting sessions via password and using permanent password"),
("wayland_experiment_tip", "Wayland support is in experimental stage, please use X11 if you require unattended access."),
("Slogan_tip", "Made with heart in this chaotic world!"),
("software_render_tip", "If you have an Nvidia graphics card and the remote window closes immediately after connecting, installing the nouveau driver and choosing to use software rendering may help. A software restart is required.")
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", "Cerrado manualmente por la consola web"),
("Local keyboard type", "Tipo de teclado local"),
("Select local keyboard type", "Seleccionar tipo de teclado local"),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", "Fermé manuellement par la console Web"),
("Local keyboard type", "Disposition du clavier local"),
("Select local keyboard type", "Selectionner la disposition du clavier local"),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", "Chiudi manualmente dalla console Web"),
("Local keyboard type", "Tipo di tastiera locale"),
("Select local keyboard type", "Seleziona il tipo di tastiera locale"),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", "Закрыто вручную через веб-консоль"),
("Local keyboard type", "Тип локальной клавиатуры"),
("Select local keyboard type", "Выберите тип локальной клавиатуры"),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -280,7 +280,6 @@ lazy_static::lazy_static! {
("android_stop_service_tip", "การปิดการใช้งานเซอร์วิสจะปิดการเชื่อมต่อทั้งหมดโดยอัตโนมัติ"),
("android_version_audio_tip", "เวอร์ชั่นแอนดรอยด์ปัจจุบันของคุณไม่รองรับการบันทึกข้อมูลเสียง กรุณาอัปเกรดเป็นแอนดรอยด์เวอร์ชั่น 10 หรือสูงกว่า"),
("android_start_service_tip", "แตะ [เริ่มต้นใช้งานเซอร์วิส] หรือเปิดสิทธิ์ [การบันทึกหน้าจอ] เพื่อเริ่มเซอร์วิสการแชร์หน้าจอ"),
("Account", "บัญชี"),
("Overwrite", "เขียนทับ"),
("This file exists, skip or overwrite this file?", "พบไฟล์ที่มีอยู่แล้ว ต้องการเขียนทับหรือไม่?"),
("Quit", "ออก"),
@ -334,6 +333,7 @@ lazy_static::lazy_static! {
("Scale adaptive", "ขนาดยืดหยุ่น"),
("General", "ทั่วไป"),
("Security", "ความปลอดภัย"),
("Account", "บัญชี"),
("Theme", "ธีม"),
("Dark Theme", "ธีมมืด"),
("Dark", "มืด"),
@ -405,5 +405,8 @@ lazy_static::lazy_static! {
("Closed manually by the web console", "ถูกปิดโดยเว็บคอนโซล"),
("Local keyboard type", "ประเภทคีย์บอร์ด"),
("Select local keyboard type", "เลือกประเภทคีย์บอร์ด"),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", "被web控制台手動關閉"),
("Local keyboard type", "本地鍵盤類型"),
("Select local keyboard type", "請選擇本地鍵盤類型"),
("software_render_tip", "如果你使用英偉達顯卡, 並且遠程窗口在會話建立後會立刻關閉, 那麼安裝nouveau驅動並且選擇使用軟件渲染可能會有幫助。重啟軟件後生效。"),
("Always use software rendering", "使用軟件渲染"),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -405,5 +405,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Closed manually by the web console", ""),
("Local keyboard type", ""),
("Select local keyboard type", ""),
("software_render_tip", ""),
("Always use software rendering", ""),
].iter().cloned().collect();
}

View File

@ -717,3 +717,92 @@ pub fn get_double_click_time() -> u32 {
}
}
/// forever: may not work
pub fn system_message(title: &str, msg: &str, forever: bool) -> ResultType<()> {
if std::process::Command::new("notify-send")
.arg(title)
.arg(msg)
.spawn()
.is_ok()
{
return Ok(());
}
if std::process::Command::new("zenity")
.arg("--info")
.arg("--timeout")
.arg(if forever { "0" } else { "3" })
.arg("--title")
.arg(title)
.arg("--text")
.arg(msg)
.spawn()
.is_ok()
{
return Ok(());
}
if std::process::Command::new("kdialog")
.arg("--title")
.arg(title)
.arg("--msgbox")
.arg(msg)
.spawn()
.is_ok()
{
return Ok(());
}
if std::process::Command::new("xmessage")
.arg("-center")
.arg("-timeout")
.arg(if forever { "0" } else { "3" })
.arg(title)
.arg(msg)
.spawn()
.is_ok()
{
return Ok(());
}
bail!("failed to post system message");
}
extern "C" fn breakdown_signal_handler(sig: i32) {
let mut stack = vec![];
backtrace::trace(|frame| {
backtrace::resolve_frame(frame, |symbol| {
if let Some(name) = symbol.name() {
stack.push(name.to_string());
}
});
true // keep going to the next frame
});
let mut info = String::default();
if stack.iter().any(|s| {
s.contains(&"nouveau_pushbuf_kick")
|| s.to_lowercase().contains("nvidia")
|| s.contains("gdk_window_end_draw_frame")
}) {
hbb_common::config::Config::set_option(
"allow-always-software-render".to_string(),
"Y".to_string(),
);
info = "Always use software rendering will be set.".to_string();
log::info!("{}", info);
}
log::error!(
"Got signal {} and exit. stack:\n{}",
sig,
stack.join("\n").to_string()
);
system_message(
"RustDesk",
&format!("Got signal {} and exit.{}", sig, info),
true,
)
.ok();
std::process::exit(0);
}
pub fn register_breakdown_handler() {
unsafe {
libc::signal(libc::SIGSEGV, breakdown_signal_handler as _);
}
}