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

fix(dashboard): 🐛 Fix SteamVR launch fail for dangling ADB process #2757

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zmerp
Copy link
Member

@zmerp zmerp commented Mar 15, 2025

No description provided.

@zmerp zmerp changed the title fix(dashboard): 🐛 Fix SteamVR fail to launch for dangling ADB process fix(dashboard): 🐛 Fix SteamVR launch fail for dangling ADB process Mar 15, 2025
@zmerp zmerp force-pushed the kill-adb-on-launch branch 3 times, most recently from abe54d8 to 79ddef4 Compare March 15, 2025 18:52
@zmerp zmerp force-pushed the kill-adb-on-launch branch from 79ddef4 to 3ea68c4 Compare March 15, 2025 19:16
@zmerp
Copy link
Member Author

zmerp commented Mar 16, 2025

Tested by @0JXI0, ready to review

Comment on lines +118 to +129
// The ADB server might be left running because of a unclean termination of SteamVR
let local_adb_path = crate::get_filesystem_layout().local_adb_exe();
for proc in
sysinfo::System::new_all().processes_by_name(OsStr::new(&afs::exec_fname("adb")))
{
if let Some(proc_path) = proc.exe() {
if proc_path == local_adb_path {
proc.kill();
}
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean adb intentionally has the server architecture, I find killing it to be a bit of a meh thing, but I guess we're already doing it in case of a normal shutdown, so what gives.
But what happens when alvr picks up/launches a system wide installed adb server? This wouldn't handle that and in that scenario killing adb is a bad option and the logic to unregister the old port forwardings would work for both local and system wide adb (tho that would probably require quite a bit of more adb specific logic).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also adb kill-server does the same thing but more cleanly, so maybe that's a better option?

Copy link
Member Author

@zmerp zmerp Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@E1int What do you think? Would you be willing to work on this?

Comment on lines -264 to 280
fn get_adb_path(layout: &Layout) -> Option<String> {
fn get_adb_path(layout: &afs::Layout) -> Option<String> {
get_os_adb_path().or(get_local_adb_path(layout))
}

fn get_os_adb_path() -> Option<String> {
let name = get_executable_name().to_owned();
let name = afs::exec_fname("adb").to_owned();

get_command(&name, &[]).output().is_ok().then_some(name)
}

fn get_local_adb_path(layout: &Layout) -> Option<String> {
let path = get_platform_tools_path(layout).join(get_executable_name());
fn get_local_adb_path(layout: &afs::Layout) -> Option<String> {
let path = layout.local_adb_exe();

path.try_exists()
.is_ok_and(|e| e)
.unwrap_or(false)
.then(|| path.to_string_lossy().to_string())
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ik this isn't your code but these should probably be consolidated into one function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yeah

Comment on lines +202 to +204
pub fn local_adb_dir(&self) -> PathBuf {
self.executables_dir.join("platform-tools")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this function should exist, it's only used locally and what it's amounting to is a hard-coded path part anyway ("platform-tools/adb") and thus will likely also never be used in any other capacity, which should only really be one function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

@zmerp
Copy link
Member Author

zmerp commented Mar 19, 2025

As things stand, probably this PR shouldn't be merged. I could get some help making another PR fixing this the proper way, as suggested by @The-personified-devil

@The-personified-devil
Copy link
Collaborator

I mean I can take a look at it tmrw, but I'm not entirely sure how to ideally handle this yet

@zmerp zmerp marked this pull request as draft March 19, 2025 14:21
@zmerp
Copy link
Member Author

zmerp commented Mar 19, 2025

@The-personified-devil We would need to detect if the current alive adb server is spawned from the current process or not. if it's the local ADB installation it's always spawned by the driver, if not then it's safe to let the ADB instance live because it will not block SteamVR. the crate sysinfo should be able to tell if the parent process is SteamVR (check if adb is spawned by the current process)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants