Skip to content

Instantly share code, notes, and snippets.

@Meister1593
Last active April 7, 2024 17:07
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Meister1593/b574b399d85770abc2368f4d5af9df42 to your computer and use it in GitHub Desktop.
Save Meister1593/b574b399d85770abc2368f4d5af9df42 to your computer and use it in GitHub Desktop.
Updated for steamvr 2.3.5
#!/bin/bash
echo "Latest known working version for patching: 2.3.5"
if [[ -z "$1" ]]; then
echo 'Enter absolute path to SteamVR (for example, /home/user/.local/share/Steam/steamapps/common/SteamVR)'
read STEAMVR_PATH
else
STEAMVR_PATH="$1"
fi
PATH_TO_PATCHING_FILE="$STEAMVR_PATH/resources/webinterface/dashboard/vrwebui_shared.js"
if [[ ! -f $PATH_TO_PATCHING_FILE ]]; then
echo "Couldn't find required file for patch, aborting"
exit 1
fi
echo 'In case of failed patching, please re-validate SteamVR files to make sure they stay unchanged'
echo Deleting SteamVR html cache
rm -r ~/.cache/SteamVR
CHANGED_OUT=$(sed -i 's/m=n(1380),g=n(9809);/m=n(1380),g=n(9809),refresh_counter=0,refresh_counter_max=75;/g w /dev/stdout' $PATH_TO_PATCHING_FILE)
if [[ -z $CHANGED_OUT ]]; then
echo "Couldn't patch, exiting"
exit 1
else
echo "patched 1"
fi
CHANGED_OUT=$(sed -i 's/case"action_bindings_reloaded":this.OnActionBindingsReloaded(n);break;/case"action_bindings_reloaded":if(refresh_counter%refresh_counter_max==0){this.OnActionBindingsReloaded(n);}refresh_counter++;break;/g w /dev/stdout' $PATH_TO_PATCHING_FILE)
if [[ -z $CHANGED_OUT ]]; then
echo "Couldn't patch, exiting"
exit 1
else
echo "patched 2"
fi
CHANGED_OUT=$(sed -i 's/l=n(3568),c=n(1569);/l=n(3568),c=n(1569),refresh_counter_v2=0,refresh_counter_max_v2=75;/g w /dev/stdout' $PATH_TO_PATCHING_FILE)
if [[ -z $CHANGED_OUT ]]; then
echo "Couldn't patch, exiting"
exit 1
else
echo "patched 3"
fi
CHANGED_OUT=$(sed -i 's/OnActionBindingsReloaded(){this.GetInputState()}/OnActionBindingsReloaded(){if(refresh_counter_v2%refresh_counter_max_v2==0){this.GetInputState();}refresh_counter_v2++;}/g w /dev/stdout' $PATH_TO_PATCHING_FILE)
if [[ -z $CHANGED_OUT ]]; then
echo "Couldn't patch, exiting"
exit 1
else
echo "patched 4"
fi
echo Successfully patched web file.
@Meister1593
Copy link
Author

This patcher "fixes" (work-arounds) issue with binding spam on linux steamvr which causes steamvr CEF to collapse and not open a single video or binding settings, possibly resulting in other issues too.

@Meister1593
Copy link
Author

@Atemu
Copy link

Atemu commented Mar 26, 2023

Wouldn't an actual patch be simpler?

@Meister1593
Copy link
Author

Wouldn't an actual patch be simpler?

Minfied single-line files and unix patches aren't the best combination :)

@Atemu
Copy link

Atemu commented Mar 26, 2023

Ah, I see. Perhaps you could run it through an auto-formatter and make the patch for that.

@Meister1593
Copy link
Author

i made script so pretty much everyone could run it without dependencies, and without re-formatting minified file

@joshperry
Copy link

joshperry commented May 13, 2023

Updated for steamvr beta 1.26.2 because I need OpenXR on Linux.

#!/usr/bin/env bash

echo 'Enter absolute path to SteamVR (for example, /home/user/.local/share/Steam/steamapps/common/SteamVR)'
read STEAMVR_PATH
PATH_TO_PATCHING_FILE="$STEAMVR_PATH/resources/webinterface/dashboard/vrwebui_shared.js"
if [[ ! -f $PATH_TO_PATCHING_FILE ]]; then
	echo "Couldn't find required file for patch, aborting"
	exit 1
fi

echo 'In case of failed patching, please re-validate SteamVR files to make sure they stay unchanged'

echo Deleting SteamVR html cache
rm -r ~/.cache/SteamVR

CHANGED_OUT=$(sed -i 's/m=n(1380),g=n(9809);/m=n(1380),g=n(9809),refresh_counter=0,refresh_counter_max=25;/g w /dev/stdout' $PATH_TO_PATCHING_FILE )
if [[ -z $CHANGED_OUT ]]; then
	echo "Couldn't patch, exiting"
	exit 1
fi
CHANGED_OUT=$(sed -i 's/case"action_bindings_reloaded":this.OnActionBindingsReloaded(n);break;/case"action_bindings_reloaded":if(refresh_counter%refresh_counter_max==0){this.OnActionBindingsReloaded(n);}refresh_counter++;break;/g w /dev/stdout' $PATH_TO_PATCHING_FILE)
if [[ -z $CHANGED_OUT ]]; then
	echo "Couldn't patch, exiting"
	exit 1
fi
CHANGED_OUT=$(sed -i 's/l=n(3568),c=n(1569);/l=n(3568),c=n(1569),refresh_counter_v2=0,refresh_counter_max_v2=25;/g w /dev/stdout' $PATH_TO_PATCHING_FILE)
if [[ -z $CHANGED_OUT ]]; then
	echo "Couldn't patch, exiting"
	exit 1
fi
CHANGED_OUT=$(sed -i 's/OnActionBindingsReloaded(){this.GetInputState()}/OnActionBindingsReloaded(){if(refresh_counter_v2%refresh_counter_max_v2==0){this.GetInputState();}refresh_counter_v2++;}/g w /dev/stdout' $PATH_TO_PATCHING_FILE)
if [[ -z $CHANGED_OUT ]]; then
	echo "Couldn't patch, exiting"
	exit 1
fi
echo Successfully patched file. Please restart SteamVR if it was running

@Meister1593
Copy link
Author

Meister1593 commented May 13, 2023

@joshperry Thank you! 👍
Though i think openxr is already a thing even in 1.25.7/8?... (at least bonelab, even beta branch works)
Or theres more changes to openxr in 1.26?
Once 1.26+ hits stable i might update the script in gist to the one you provided, if it's okay with you?

@joshperry
Copy link

@Meister1593 absolutely, feel free (if updates to the beta don't rebuild the webpack project). I was under the impression that OpenXR on Linux was only installed with the beta release, but I must admit that my information may be stale and I didn't attempt using the release version before switching... I'll give the release version a try when I have a few minutes to reinstall it.

@Meister1593
Copy link
Author

Meister1593 commented Jul 9, 2023

It seems like this patcher is redundant now, steam beta is out into stable and there is no spam in console anymore

@joshperry
Copy link

Horray! Appreciate the work to create this bridge in the meantime, it unblocked me from creating things in VR purely in Linux.

@Meister1593
Copy link
Author

Meister1593 commented Jul 13, 2023

Horray! Appreciate the work to create this bridge in the meantime, it unblocked me from creating things in VR purely in Linux.

I take my words back, for some reason it still spams, for some reason only in some more specific scenarios it starts to spam and never recover, so i think i will apply newer patch and update it there

@Meister1593
Copy link
Author

Updated for latest steamvr version, it still spams, and this still greatly reduces amount of cpu usage from vrwebhelper (as well as, well, fix issues with bindings)

@vsTerminus
Copy link

Seems to be failing on line 30 now, both with SteamVR Stable (2.2.3) and Beta (2.3.3). Any chance we could either get an update or more info/instructions on how to update it ourselves as new versions come out?

Thanks!

@Meister1593
Copy link
Author

Weird, i still can patch it just fine?... And in another distrobox script it works fine

@Meister1593
Copy link
Author

There is no easy guide on how to do it, i can just say that you can try checking out what exactly got failed patching and see what needs to be changed in that area

Try verifying your steamvr files and applying script again

@Meister1593
Copy link
Author

2.2.3 definitely can be patched
2.3.3 however fails on patching

@vsTerminus
Copy link

My bad - Not sure why it failed the first time but I was able to patch 2.2.3 successfully. Thank you!

@steffenWi
Copy link

steffenWi commented Feb 17, 2024

2.3.5 Patch 3 fails
Though just having patch 1 and 2 applied allows one to open the controller binding UI. Thank you for providing this script!

@Meister1593
Copy link
Author

Updated, one variable on patch 3 was changed and needed to be updated.
If anyone wants patching later manually, just try to look for second part of patches with actual code, and see what lines has been changed - those variables are used only as anchors, to place own variables.
Format minified code and look around patching area.

@soybeansavior
Copy link

I am sure you are busy, and I am happy to contribute code changes if pointed in the correct direction. As of 2024/04/04 | 2.4.4 (I think) the script doesn't seem to fix the problem? It previously worked for me in an older steamVR version. My issues were always around VRChat. Anyway, The script patches everything properly, I've done a manual modify before to fix some pathing problems. Now the patching just doesn't seem to affect any behavior in game, I still get the controller binding spam and the resultant late start frames in game. I am happy to pay for advice or an update, thanks.

@Meister1593
Copy link
Author

I just checked and it is not spamming, not causing major cpu usage.
I don't think vrchat issue is related to this...

@Meister1593
Copy link
Author

Verify integrity of files on latest stable and try re-patching it
Check in F9 of SteamVR settings - Network if getstates are spammed every frame (and not each 2 seconds)

@soybeansavior
Copy link

soybeansavior commented Apr 6, 2024

This is the type of logspam I'm getting, after verifying integrity and re-patching. Checking the getstate.json requests, it seems to be happening every few seconds, not every frame for sure, but this log spamming is happening much faster than every few seconds, seems detached from the cadence of the getstate, if they were supposed to be related.

Sat Apr 06 2024 10:46:56.885661 [Info] - Unable to find input 'z' in filter click_button_actions_legacy_17_user_hand_left_input_thumbstick Sat Apr 06 2024 10:46:56.885693 [Info] - Unable to find input 'z' in filter click_button_actions_legacy_18_user_hand_right_input_thumbstick Sat Apr 06 2024 10:46:56.934814 [Info] - Determined this is a legacy app. Sat Apr 06 2024 10:46:56.935793 [Info] - Determined this is a legacy app. Sat Apr 06 2024 10:46:56.935916 [Info] - Unable to find input 'z' in filter click_button_actions_legacy_17_user_hand_left_input_thumbstick Sat Apr 06 2024 10:46:56.935966 [Info] - Unable to find input 'z' in filter click_button_actions_legacy_18_user_hand_right_input_thumbstick Sat Apr 06 2024 10:46:56.984074 [Info] - Determined this is a legacy app. Sat Apr 06 2024 10:46:56.984921 [Info] - Determined this is a legacy app. Sat Apr 06 2024 10:46:56.985033 [Info] - Unable to find input 'z' in filter click_button_actions_legacy_17_user_hand_left_input_thumbstick Sat Apr 06 2024 10:46:56.985069 [Info] - Unable to find input 'z' in filter click_button_actions_legacy_18_user_hand_right_input_thumbstick Sat Apr 06 2024 10:46:57.034032 [Info] - Determined this is a legacy app.

@Meister1593
Copy link
Author

Pretty sure it's unrelated/different issue... issue that this patch fixes is just binding reload spam

@soybeansavior
Copy link

soybeansavior commented Apr 6, 2024

Actually, as it turns out, its definitely not VRChat related. The log spam happens even in VR Home which is being seen as a legacy application. It is checking for legacy bindings every frame, and once I turn on controllers, it adds in that message about the left and right thumbs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment