From dcbe2805e65d2ff0cc312c4c8c5c7df358ffda61 Mon Sep 17 00:00:00 2001 From: 21pages Date: Fri, 8 Mar 2024 17:24:02 +0800 Subject: [PATCH] improve waiting for image when only one image received (#7340) * fix padding of mobile server page PopupMenuItem Signed-off-by: 21pages * improve waiting for image when only one image received * For flutter texture late creation: create texture between session add and session start, it works not in principle but in test. * For late PeerInfo handling a. rgba texture render: allow zero size in on_rgba b. gpu texture render and rgba buffer render doesn't check size currently * Fix wrong valid flag of first frame in rgba texture render Other issues: * decodeImageFromPixels may fail on first image * Correct width/height when resolution changes Signed-off-by: 21pages --------- Signed-off-by: 21pages --- flutter/lib/mobile/pages/server_page.dart | 9 --------- flutter/lib/models/desktop_render_texture.dart | 1 + flutter/lib/models/model.dart | 6 +++++- src/flutter.rs | 8 ++++++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flutter/lib/mobile/pages/server_page.dart b/flutter/lib/mobile/pages/server_page.dart index 3bf7ca4499b6..e389d795c86a 100644 --- a/flutter/lib/mobile/pages/server_page.dart +++ b/flutter/lib/mobile/pages/server_page.dart @@ -42,25 +42,21 @@ class ServerPage extends StatefulWidget implements PageShape { return [ PopupMenuItem( enabled: gFFI.serverModel.connectStatus > 0, - padding: const EdgeInsets.symmetric(horizontal: 16.0), value: "changeID", child: Text(translate("Change ID")), ), const PopupMenuDivider(), PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 0.0), value: 'AcceptSessionsViaPassword', child: listTile( 'Accept sessions via password', approveMode == 'password'), ), PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 0.0), value: 'AcceptSessionsViaClick', child: listTile('Accept sessions via click', approveMode == 'click'), ), PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 0.0), value: "AcceptSessionsViaBoth", child: listTile("Accept sessions via both", approveMode != 'password' && approveMode != 'click'), @@ -69,35 +65,30 @@ class ServerPage extends StatefulWidget implements PageShape { if (showPasswordOption && verificationMethod != kUseTemporaryPassword) PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 16.0), value: "setPermanentPassword", child: Text(translate("Set permanent password")), ), if (showPasswordOption && verificationMethod != kUsePermanentPassword) PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 16.0), value: "setTemporaryPasswordLength", child: Text(translate("One-time password length")), ), if (showPasswordOption) const PopupMenuDivider(), if (showPasswordOption) PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 0.0), value: kUseTemporaryPassword, child: listTile('Use one-time password', verificationMethod == kUseTemporaryPassword), ), if (showPasswordOption) PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 0.0), value: kUsePermanentPassword, child: listTile('Use permanent password', verificationMethod == kUsePermanentPassword), ), if (showPasswordOption) PopupMenuItem( - padding: const EdgeInsets.symmetric(horizontal: 0.0), value: kUseBothPasswords, child: listTile( 'Use both passwords', diff --git a/flutter/lib/models/desktop_render_texture.dart b/flutter/lib/models/desktop_render_texture.dart index 640afdd33e5a..a54042f06584 100644 --- a/flutter/lib/models/desktop_render_texture.dart +++ b/flutter/lib/models/desktop_render_texture.dart @@ -8,6 +8,7 @@ import 'package:texture_rgba_renderer/texture_rgba_renderer.dart'; import '../../common.dart'; import './platform_model.dart'; +// Feature flutter_texture_render need to be enabled if feature gpucodec is enabled. final useTextureRender = bind.mainHasPixelbufferTextureRender() || bind.mainHasGpuTextureRender(); diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index beca23fedfc1..79401de3c1b1 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -387,7 +387,8 @@ class FfiModel with ChangeNotifier { onUrlSchemeReceived(Map evt) { final url = evt['url'].toString().trim(); - if (url.startsWith(bind.mainUriPrefixSync()) && handleUriLink(uriString: url)) { + if (url.startsWith(bind.mainUriPrefixSync()) && + handleUriLink(uriString: url)) { return; } switch (url) { @@ -2228,6 +2229,9 @@ class FFI { sessionId: sessionId, displays: Int32List.fromList(displays)); ffiModel.pi.currentDisplay = display; } + if (connType == ConnType.defaultConn && useTextureRender) { + textureModel.updateCurrentDisplay(display ?? 0); + } final stream = bind.sessionStart(sessionId: sessionId, id: id); final cb = ffiModel.startEventListener(sessionId, id); diff --git a/src/flutter.rs b/src/flutter.rs index 7420635d9029..5f52b85d82bb 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -400,7 +400,6 @@ impl VideoRenderer { return false; } - // It is also Ok to skip this check. if info.size.0 != rgba.w || info.size.1 != rgba.h { log::error!( "width/height mismatch: ({},{}) != ({},{})", @@ -409,7 +408,11 @@ impl VideoRenderer { rgba.w, rgba.h ); - return false; + // Peer info's handling is async and may be late than video frame's handling + // Allow peer info not set, but not allow wrong width/height for correct local cursor position + if info.size != (0, 0) { + return false; + } } if let Some(func) = &self.on_rgba_func { unsafe { @@ -763,6 +766,7 @@ impl InvokeUiSession for FlutterHandler { } else { let mut rgba_data = RgbaData::default(); std::mem::swap::>(&mut rgba.raw, &mut rgba_data.data); + rgba_data.valid = true; rgba_write_lock.insert(display, rgba_data); } drop(rgba_write_lock);