Compare commits

...
4 Commits
Author SHA1 Message Date
VallierDevandClaude Opus 5.5 7a86fab340 Release v0.2.34
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 13:10:49 +08:00
VallierDevandClaude Opus 5.5 d631849f1d Viewer: map the desktop window before the first decoded frame (#118)
Wayland shows a toplevel only after its first buffer, so a stream that never
yields a picture left no window at all. Present a black buffer on creation and
on resize/expose while no frame has arrived.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 12:10:35 +08:00
VallierDevandClaude Opus 5.5 d04d241411 Viewer: repaint the last frame after a compositor resize (#118)
Tiling or maximizing the SDL viewer resized the surface, but nothing was
drawn until the next decoded frame, so a static remote desktop stayed blank.
Repaint the last frame on SizeChanged/Resized/Exposed/Maximized/Restored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 11:10:53 +08:00
VallierDevandClaude Opus 5.5 2eece30287 Signaling: bound the WebSocket handshake so reconnect retries after a stall (#115)
After a network change the DNS/TCP/TLS/upgrade could stall forever after
room credentials were acquired; the reconnect loop never retried. The
handshake now fails after 20s and the existing 5s retry takes over.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 20:03:54 +08:00
5 changed files with 85 additions and 18 deletions

No files matched your search

Generated
+1 -1
View File
@@ -2741,7 +2741,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "uu-remote-linux"
version = "0.2.33"
version = "0.2.34"
dependencies = [
"async-trait",
"base64 0.22.1",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "uu-remote-linux"
version = "0.2.33"
version = "0.2.34"
edition = "2021"
default-run = "uuremote-server"
authors = ["uu-remote-linux contributors"]
+15
View File
@@ -0,0 +1,15 @@
修复网络波动后信令重连卡住,以及 Linux 控制端在平铺窗口管理器下画面空白。/ Fixes signaling reconnect stalling after a network hiccup, and the Linux viewer showing a blank window under tiling compositors.
### 修复 / Fixed
- **网络异常后停在 Acquired room signaling credentials(#115,感谢 @Changxi-M)**:信令 WebSocket 握手没有超时,网络半断时会无限等待,重连不再重试。现在握手限时 20 秒,超时后按原有退避重试。
The signaling WebSocket handshake is now bounded to 20 s, so a stalled handshake falls back to the normal reconnect retry instead of hanging forever.
- **控制端窗口平铺后画面空白(#118,感谢 @shao-zhijie)**:Linux 控制端只在收到新解码帧时绘制,合成器调整窗口尺寸后静止画面不会重绘;在尚未收到首帧时,Wayland 也不会映射没有提交缓冲的窗口。现在窗口尺寸变化/重新显示时用最后一帧重绘,无帧时先画黑底。
The Linux viewer now repaints the last frame after a compositor resize/expose, and paints a black frame before the first decoded frame so Wayland maps the window.
### 验证范围 / Validation
单元测试与 CI;#115、#118 的场景尚未实机复现,欢迎反馈。
### 下载 / Download
`uu-remote-linux_0.2.34_<amd64|arm64>.deb`,或 `uu-remote-linux-v0.2.34-<x86_64|aarch64>-linux.tar.gz`(解压后运行 `./install.sh`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.34`(x86_64)。
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
+32 -3
View File
@@ -14,6 +14,9 @@ use tokio_tungstenite::tungstenite::Message;
/// A peer that stops reading must not park the heartbeat loop on a full queue.
/// Kept below the Engine.IO window so the protocol deadline still fires.
const SEND_STALL_TIMEOUT: Duration = Duration::from_secs(10);
// DNS/TCP/TLS/WebSocket upgrade must finish in bounded time: after a network
// change the handshake can stall forever and the reconnect loop never retries.
const CONNECT_TIMEOUT: Duration = Duration::from_secs(20);
/// How often the watchdog checks the last inbound frame.
const WATCHDOG_TICK: Duration = Duration::from_secs(1);
@@ -177,6 +180,21 @@ mod refresh_tests {
let closed=tokio::time::timeout(std::time::Duration::from_secs(15),closed_rx).await;
assert!(closed.is_ok(),"a blocked consumer must not keep a dead signaling socket open");
}
#[tokio::test]
async fn stalled_handshake_times_out() {
use tokio_tungstenite::tungstenite::client::IntoClientRequest;
// Accepts TCP but never answers the upgrade, like a stalled path after a network change.
let listener=tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
let address=listener.local_addr().unwrap();
tokio::spawn(async move {
let (_tcp,_)=listener.accept().await.unwrap();
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
});
let req=format!("ws://{address}/socket.io/").into_client_request().unwrap();
let result=tokio::time::timeout(std::time::Duration::from_secs(5),super::open_socket(req,std::time::Duration::from_secs(1))).await;
assert!(matches!(result,Ok(Err(_))),"a stalled handshake must fail within the connect timeout");
}
#[tokio::test]
async fn stalled_event_delivery_still_reports_disconnected() {
use futures_util::{SinkExt,StreamExt};
@@ -210,6 +228,19 @@ mod refresh_tests {
}
}
async fn open_socket(
req: tokio_tungstenite::tungstenite::handshake::client::Request,
limit: Duration,
) -> Result<tokio_tungstenite::WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>, String> {
match tokio::time::timeout(limit, connect_async(req)).await {
Ok(result) => result.map(|(ws, _)| ws).map_err(|e| format!("WS connect failed: {}", e)),
Err(_) => {
log::warn!("Signaling connect timed out after {}s", limit.as_secs());
Err("WS connect timed out".into())
}
}
}
impl SignalingClient {
pub async fn connect(
url: &str,
@@ -231,9 +262,7 @@ impl SignalingClient {
room_token.parse().map_err(|_| "Invalid token header")?,
);
let (ws_stream, _) = connect_async(req)
.await
.map_err(|e| format!("WS connect failed: {}", e))?;
let ws_stream = open_socket(req, CONNECT_TIMEOUT).await?;
log::info!("Connected to Engine.IO / Socket.IO");
let (mut write, mut read) = ws_stream.split();
+36 -13
View File
@@ -8,7 +8,10 @@ impl Window {
pub fn new()->Result<Self,String>{
let sdl=sdl2::init()?;let video=sdl.video()?;
let window=video.window("Native viewer (experimental)",1280,720).position_centered().resizable().build().map_err(|_|"Window creation failed")?;
let canvas=window.into_canvas().build().map_err(|_|"Renderer creation failed")?;
let mut canvas=window.into_canvas().build().map_err(|_|"Renderer creation failed")?;
// Wayland maps a toplevel only after its first buffer; without this the window stays
// invisible until the first decoded frame, which a stalled stream never delivers.
canvas.set_draw_color(sdl2::pixels::Color::BLACK);canvas.clear();canvas.present();
let events=sdl.event_pump()?;let clipboard=video.clipboard();
let(clipboard_tx,clipboard_requests)=tokio::sync::mpsc::channel(16);
Ok(Self{canvas,events,_sdl:sdl,frame:(1920,1080),focused:true,files:false,mac:false,clipboard,clipboard_dirty:true,clipboard_tx,clipboard_requests,last_frame:None})
@@ -38,11 +41,32 @@ impl Window {
}
pub fn poll(&mut self,input:&mut Input)->(bool,Vec<serde_json::Value>){
let viewport=self.viewport();
let dirty=&mut self.clipboard_dirty;
let dirty=&mut self.clipboard_dirty;let mut redraw=false;
let events=self.events.poll_iter().inspect(|event|{
if matches!(event,Event::ClipboardUpdate{..}|Event::Window{win_event:WindowEvent::FocusGained,..}){*dirty=true;}
redraw|=needs_redraw(event);
});
translate_actions(events,input,viewport,&mut self.focused,&mut self.files)
let result=translate_actions(events,input,viewport,&mut self.focused,&mut self.files);
// A compositor resize (tiling, maximize) leaves the surface without a buffer of the new size
// until the next frame; a static remote desktop sends none, so repaint the last frame now.
if redraw {if let Some(frame)=self.last_frame.take(){
log::debug!("Viewer window resized: {:?}",self.canvas.window().size());
if let Err(e)=self.draw(&frame){log::warn!("Viewer redraw failed: {e}");}
self.last_frame=Some(frame);
}else{self.canvas.set_draw_color(sdl2::pixels::Color::BLACK);self.canvas.clear();self.canvas.present();}}
result
}
fn draw(&mut self,frame:&Frame)->Result<(),String>{
// Pad bars belong to the decoded canvas, not the remote picture: viewport and input use the
// content aspect, and only the content sub-rectangle of the texture is drawn.
let content=frame.content.unwrap_or((frame.width,frame.height));
self.frame=content;let v=self.viewport();let creator=self.canvas.texture_creator();
let mut texture=creator.create_texture_streaming(PixelFormatEnum::RGB24,frame.width,frame.height).map_err(|_|"Texture creation failed")?;
texture.update(None,&frame.rgb,frame.width as usize*3).map_err(|_|"Texture update failed")?;
self.canvas.set_draw_color(sdl2::pixels::Color::BLACK);self.canvas.clear();
let src=super::input::content_rect((frame.width,frame.height),content)
.map(|(x,y,w,h)|Rect::new(x.round() as i32,y.round() as i32,w.round().max(1.) as u32,h.round().max(1.) as u32));
self.canvas.copy(&texture,src,Some(Rect::new(v.x.round() as i32,v.y.round() as i32,v.width.round().max(1.) as u32,v.height.round().max(1.) as u32)))?;self.canvas.present();Ok(())
}
}
fn clipboard_text(bytes:&[u8])->Option<String>{
@@ -91,20 +115,14 @@ fn translate_actions(events:impl IntoIterator<Item=Event>,input:&mut Input,viewp
} (quit,messages)
}
fn needs_redraw(event:&Event)->bool{
matches!(event,Event::Window{win_event:WindowEvent::SizeChanged(..)|WindowEvent::Resized(..)|WindowEvent::Exposed|WindowEvent::Maximized|WindowEvent::Restored,..})
}
fn button(b:MouseButton)->Option<i32>{match b{MouseButton::Left=>Some(1),MouseButton::Right=>Some(2),MouseButton::Middle=>Some(4),_=>None}}
impl FrameSink for Window {
fn present(&mut self,frame:&Frame)->Result<(),String>{
self.last_frame=Some(Frame{width:frame.width,height:frame.height,rgb:frame.rgb.clone(),content:frame.content});
// Pad bars belong to the decoded canvas, not the remote picture: viewport and input use the
// content aspect, and only the content sub-rectangle of the texture is drawn.
let content=frame.content.unwrap_or((frame.width,frame.height));
self.frame=content;let v=self.viewport();let creator=self.canvas.texture_creator();
let mut texture=creator.create_texture_streaming(PixelFormatEnum::RGB24,frame.width,frame.height).map_err(|_|"Texture creation failed")?;
texture.update(None,&frame.rgb,frame.width as usize*3).map_err(|_|"Texture update failed")?;
self.canvas.set_draw_color(sdl2::pixels::Color::BLACK);self.canvas.clear();
let src=super::input::content_rect((frame.width,frame.height),content)
.map(|(x,y,w,h)|Rect::new(x.round() as i32,y.round() as i32,w.round().max(1.) as u32,h.round().max(1.) as u32));
self.canvas.copy(&texture,src,Some(Rect::new(v.x.round() as i32,v.y.round() as i32,v.width.round().max(1.) as u32,v.height.round().max(1.) as u32)))?;self.canvas.present();Ok(())
self.draw(frame)
}
}
pub async fn run(session:&mut Session,window:&mut Window,decoder:&mut dyn super::desktop::Decoder,view_only:bool,device:&str)->Result<(),String>{
@@ -442,6 +460,11 @@ async fn pump_type_job(job: &mut TypeJob, session: &mut Session, window: &mut Wi
assert!(input.release_all().is_empty());
}
}
#[test] fn compositor_resize_and_expose_repaint_the_last_frame(){
let w=|win_event|Event::Window{timestamp:0,window_id:1,win_event};
for e in [WindowEvent::SizeChanged(1280,800),WindowEvent::Resized(1280,800),WindowEvent::Exposed,WindowEvent::Maximized,WindowEvent::Restored]{assert!(needs_redraw(&w(e)));}
for e in [WindowEvent::FocusGained,WindowEvent::Moved(0,0)]{assert!(!needs_redraw(&w(e)));}
}
#[test] fn wheel_events_become_scroll_messages(){
use sdl2::mouse::MouseWheelDirection;
let mut input=Input::default();let mut focused=true;