Skip to content

Commit

Permalink
improve waiting for image when only one image received (rustdesk#7340)
Browse files Browse the repository at this point in the history
* fix padding of mobile server page PopupMenuItem

Signed-off-by: 21pages <[email protected]>

* 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 <[email protected]>

---------

Signed-off-by: 21pages <[email protected]>
  • Loading branch information
21pages authored Mar 8, 2024
1 parent 2628143 commit dcbe280
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
9 changes: 0 additions & 9 deletions flutter/lib/mobile/pages/server_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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',
Expand Down
1 change: 1 addition & 0 deletions flutter/lib/models/desktop_render_texture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 5 additions & 1 deletion flutter/lib/models/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ class FfiModel with ChangeNotifier {

onUrlSchemeReceived(Map<String, dynamic> 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) {
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 6 additions & 2 deletions src/flutter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: ({},{}) != ({},{})",
Expand All @@ -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 {
Expand Down Expand Up @@ -763,6 +766,7 @@ impl InvokeUiSession for FlutterHandler {
} else {
let mut rgba_data = RgbaData::default();
std::mem::swap::<Vec<u8>>(&mut rgba.raw, &mut rgba_data.data);
rgba_data.valid = true;
rgba_write_lock.insert(display, rgba_data);
}
drop(rgba_write_lock);
Expand Down

0 comments on commit dcbe280

Please sign in to comment.