Fix phantom accelerating state after reboot (autostart shows running but never starts) - #25
Open
showtimewwx wants to merge 4 commits into
Open
Fix phantom accelerating state after reboot (autostart shows running but never starts)#25showtimewwx wants to merge 4 commits into
showtimewwx wants to merge 4 commits into
Conversation
…ting a live pid as our daemon
Add state refresh logic to clean up stale running state after reboot.
…stop the full-speed repaint loop
Author
|
Pushed two more commits that fix a CPU spike reported after running the patched build for a while:
Measured on the reporting machine: GUI CPU drops from 83% to ~0.5%, both idle and with acceleration running. |
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.
Problem
On macOS, when "开机自启" (launch-at-login) is enabled, after a reboot the GUI shows "加速中" (accelerating) but acceleration is actually not working. Toggling acceleration off/on fixes it until the next reboot.
Root cause (verified with logs)
Timeline from
operations.logof an affected boot:Chain of events:
handle_helper_startwrites the helper process's own pid into the pid file (state::write_pid+state::mark_running). The helper is started very early by the root LaunchDaemon, so its pid is small.running: truesurvives the reboot.platform::is_process_runningonly probes withkill -0(a root-owned pid also succeeds via the EPERM branch) and never checks which process owns the pid, sostate::refresh()rewrites the stale state intorunning: true, "加速中,PID <reused pid>".gui.rs::maybe_autostartseesself.status.running == trueand returns early, never sending the real start request.Black-box reproduction without rebooting: write
1(launchd) into the pid file, setrunning: trueinservice-state.json, runlinuxdo-accelerator status— v0.1.16 reports"running": true, "status_text": "加速中,PID 1".Fix
platform.rs— after the liveness probe succeeds, verify the pid actually belongs to this application viaps -p <pid> -o comm=matching thelinuxdo-accelerprefix (15-char comm truncation on Linux compatible). A recycled pid owned by an unrelated process is now treated as not running.service.rs—run_privileged_helperreconciles state once at startup viastate::refresh(). At that point this helper has not started any proxy, so any leftover running state is guaranteed stale; this fixes it before the GUI reads it.Verification
running: true; this patch reportsrunning: false, "已停止"and cleans the state file.--autostart gui, with the forged stale state) — the patched GUI correctly starts acceleration (helper-start fires, DNS takeover applies, UI shows 加速已生效) instead of being fooled by the stale state.