Repository navigation
fix(scrcpy): omit server-default options from scrcpy-server command line (Samsung ACodec 255-byte crash) - #8
Merged
Conversation
…ine (Samsung ACodec 255-byte crash) Samsung's ACodec::reconfigEncoder4OtherApps copies /proc/<pid>/cmdline into a ~255-byte stack buffer (Genymobile/scrcpy#7169). ClickZen sent every option explicitly (~295 bytes), tripping -fstack-protector and killing scrcpy-server on Galaxy devices (issue #7). Mirror upstream scrcpy server.c: only send values that differ from the scrcpy-server defaults (Options.java v4.1). Typical command drops from ~295 to ~153 bytes; worst realistic combination stays at 228 bytes. - Omit when equal to server default: video/control=true, tunnel_forward/ show_touches/power_off_on_close=false, video_codec=h264, cleanup=true, max_size/max_fps=0, video_bit_rate=8000000, log_level=debug. - Keep sending non-defaults: scid, log_level=info, audio=false, clipboard_autosync=false, stay_awake=true, max_size/max_fps/video_bit_rate when non-default, tunnel_forward=true, display_id>0. - Tests: exact default command, non-default emission, <255-byte argv guard. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题(Issue #7)
三星 Galaxy S20+(SM-G9860,Android 13)投屏反复重连:
connected on display 0后约 0.3 秒即断开,手机端scrcpy-server发生 native 崩溃:三星系统底层
ACodec::reconfigEncoder4OtherApps会把/proc/<pid>/cmdline读入约 255 字节的栈缓冲区(Genymobile/scrcpy#7169)。ClickZen 原先把所有参数(含大量与服务端默认值相同的项)都显式拼进命令行,总长约 295 字节,直接触发栈保护导致CodecLooper被SIGABRT杀掉。修复
对齐上游 scrcpy
server.c的做法:只发送与 scrcpy-server 默认值(Options.javav4.1)不同的参数,其余省略,服务端自动使用默认值。video/controltruetrue时省略tunnel_forward/show_touches/power_off_on_closefalsefalse时省略video_codech264h264,不再发送cleanuptruetrue,不再发送max_size/max_fps00时省略video_bit_rate8000000log_leveldebugdebug时省略(默认info仍发送,保持原日志级别)scidaudio/clipboard_autosynctruefalse,仍发送stay_awakefalsetrue时发送display_id0> 0时发送效果(
app_processargv 长度):display_id+ 非默认码率/分辨率/帧率 + 显示触摸):228 字节CLASSPATH=...是环境变量,不在/proc/<pid>/cmdline中,不计入 255 字节限制。测试
tests/ClickZen.Device.Tests/Scrcpy/ProtocolTests.cs(ScrcpyServerOptionsTests):video=true、control=true、video_codec、cleanup、tunnel_forward、show_touches、power_off_on_close、video_bit_rate、display_id);video_bit_rate=4000000、show_touches=true、power_off_on_close=true、control=false,以及stay_awake/log_level/max_size/max_fps的省略);< 255断言(三星限制回归防护)。Closes #7