Run the embedded XServer as a foreground service - #614
Open
TheoneK423 wants to merge 1 commit into
Open
Conversation
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.
Background
Tiny Container provides two ways to access the graphical desktop: AVNC and X11 (
Termux:X11). On a Xiaomi Pad 6S Pro running HyperOS 3 with 8 GB of RAM, X11 would frequently disconnect and display “not connected”. This issue did not occur when using AVNC.Investigation showed that the container itself continued running, but the
com.fct.tc4:xserverprocess had anoom_score_adjvalue of800. Android could terminate it under increased background memory pressure, leaving X11 unable to reconnect to the graphical desktop.Changes
XServerServicebased on the existingCmdEntryPointService.specialUseforeground-service type for recent Android versions.Results
The XServer's
oom_score_adjwas reduced from800to200, and Android now recognizes it as a foreground-service process.During testing with multiple background applications and elevated memory pressure, neither XServer termination nor X11 disconnection was reproduced. Stopping and restarting the container also restarted the XServer and graphical desktop normally.
背景
Tiny Container 提供 AVNC 和 X11(
Termux:X11)两种图形桌面连接方式。在搭载澎湃 OS 3、8 GB 内存的小米平板 6S Pro 上,使用 X11 时会在运行过程中频繁断联并显示“未连接”,而使用 AVNC 时没有出现该断联问题。排查发现,容器本身仍在正常运行,但
com.fct.tc4:xserver进程的oom_score_adj为800,在后台内存压力增大时容易被 Android 系统终止,导致 X11 无法重新连接图形桌面。修改
CmdEntryPointService的XServerService。specialUse前台服务类型。效果
修改前,XServer 的
oom_score_adj为800;修改后降至200,Android 将其识别为前台服务进程。在开启多个后台应用并制造较高内存压力后,测试期间未再复现 XServer 被系统终止或 X11 断联的问题。停止并重新启动容器后,XServer 和图形桌面也能正常重新启动。