Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass server arguments over socket #1358

Closed
rom1v opened this issue May 5, 2020 · 8 comments
Closed

Pass server arguments over socket #1358

rom1v opened this issue May 5, 2020 · 8 comments
Labels

Comments

@rom1v
Copy link
Collaborator

rom1v commented May 5, 2020

I tried to improve readability/robustness of configuration passed from the client ot the server: 870ced0 (branch name_params)

But on Windows, it failed:

ERROR: Command too long (255 chars)
ERROR: Failed to execute: [adb], [shell], [CLASSPATH=/data/local/tmp/scrcpy-server.jar], [app_process], [/], [com.genymobile.scrcpy.Server], [1.13], [max_size=0], [bit_rate=8000000], [max_fps=0], [lock_video_orientation=-1], [tunnel_forward=false], [crop=], [send_frame_meta=true], [control=true], [display_id=0], [show_touches=false], [stay_awake=false] 

I think many of these key=value pairs should be passed over the socket (not tunnel_forward because the socket creation depends on it).

Or maybe you have a better idea?

@rom1v rom1v added the todo label May 5, 2020
@berniegp
Copy link

berniegp commented Feb 6, 2021

I got redirected here by this Google search: "scrcpy Command too long (255 chars)"

My problem is that I set this

ADB="C:\Program Files\Unity\Hub\Editor\2020.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\adb.exe"

and got this:

C:\Builds>scrcpy --max-size 720 --bit-rate 1M --max-fps 30 --show-touches --always-on-top
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
C:\ProgramData\chocolatey\lib\scrcpy\tools\scrcpy-server: 1 file pushed. 2.3 MB/s (34930 bytes in 0.014s)
ERROR: Command too long (255 chars)
ERROR: Failed to execute: [C:\Program Files\Unity\Hub\Editor\2020.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\adb.exe], [shell], [CLASSPATH=/data/local/tmp/scrcpy-server.jar], [app_process], [/], [com.genymobile.scrcpy.Server], [1.17], [info], [720], [1000000], [30], [-1], [false], [-], [true], [true], [0], [true], [false], [-], [-]

I get this error even if I enable long path support in Windows 10 via

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled

I was able to get around this problem with subst:

subst x: "C:\Program Files\Unity\Hub\Editor\2020.2.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools"
ADB="x:\adb.exe"

# to unmap x: drive
subst x: /D

So it looks like something in the scrcpy pipeline is limiting the path length.

@rom1v
Copy link
Collaborator Author

rom1v commented Feb 6, 2021

It's only limited on Windows releases by mingw. If you know a solution to extand this limit on mingw, please help.

@Biswa96
Copy link
Contributor

Biswa96 commented Feb 6, 2021

Though it will be a misery to deal with, did you try using Unicode Win32 functions i.e. CreateProcessW? Also try with prepending \\?\ before the command line, e.g. L"\\\\?\\MyFiles\\adb.exe". CreateFileW has that kind of trickery.

@berniegp
Copy link

berniegp commented Feb 6, 2021

I don't know the actual solution unfortunately. I mostly wanted to post the workaround as reference.

However, I did a bit of digging based on how Git for Windows (it uses mingw) handles long paths (the core.longpaths option) and found interesting sources that match what @Biswa96 mentions:

handle_long_path() in
https://github.com/git-for-windows/git/blob/main/compat/mingw.h
https://github.com/git-for-windows/git/blob/main/compat/mingw.c

A blog that discusses this:
https://www.brycevandyk.com/of-too-long-file-names-in-windows-and-git/

Hopefully this can help!

@rom1v
Copy link
Collaborator Author

rom1v commented Feb 6, 2021

Thank you for the links.

Note that here the problem is that the command (including the arguments) is too long, not the path of the executable.

@Biswa96
Copy link
Contributor

Biswa96 commented Feb 7, 2021

Yes, I also mean the command line, the second argument in CreateProcessW, the lpCommandLine. Off-topic, see my little experiment here as an example.

@rom1v
Copy link
Collaborator Author

rom1v commented Jun 17, 2021

Oh, but I'm stupid, the error Command too long comes from scrcpy:

LOGE("Command too long (%" PRIsizet " chars)", len - 1);

char cmd[256];

🤦

rom1v pushed a commit that referenced this issue Jun 19, 2021
And increase the command buffer size.

Refs #1358 <#1358 (comment)>
PR #2405 <#2405>

Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v pushed a commit that referenced this issue Jun 20, 2021
And increase the command buffer size.

Refs #1358 <#1358 (comment)>
PR #2405 <#2405>

Signed-off-by: Romain Vimont <rom@rom1v.com>
@rom1v
Copy link
Collaborator Author

rom1v commented Nov 28, 2021

Not relevant anymore. See a9d9cbf.

Also refs:

@rom1v rom1v closed this as completed Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants