Jump to content

The Linux Thread!


Recommended Posts

Tested 1.2.9.

Strangely, with all the localization work, decimal delimiter settings resetting bug is still present. So, LC_ALL=C still needed. Bad window size bug is still in place.

Fresh version of my launcher script:

Spoiler

#!/bin/sh

WIN_WIDTH=1366
WIN_HEIGHT=768
BINARY=KSP.x86_64
GEOM_GUARD_TIME="180 seconds"

[ ! -x "$(which xwininfo)" ] && printf "\e[31mWarning: xwininfo not found or is not an executable!\n         Geometry guard will not work!\e[39m\n" >&2

# change dir to script location
cd "$(dirname "$(readlink -f "$0")")"

printf "Still can not learn localized fraction delimiters? setting LC_ALL=C\n"
LANG=C
LC_ALL=C
export LC_ALL
export LANG
unset LANGUAGE

printf "Fixing weird permissions from game archive.\n"
find . -type d -exec chmod 755 "{}" \;
find . -type f -exec chmod 644 "{}" \;
chmod 755 KSP.x86  KSP.x86_64  Launcher.x86  Launcher.x86_64 "${BINARY}" "$(basename "$0")"

# trap for child process cleanup
trap 'kill $KSPPID 2> /dev/null ; exit' EXIT HUP INT TERM

GEOMKILL="2"
COUNT="0"

until [ "$GEOMKILL" = "0" ]
do
	[ "$GEOMKILL" = "1" ] && printf "\nHere we go again...\n"

	printf "Clearing unity3d config dir\n"
	[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/unity3d/" ] && rm -r "${XDG_CONFIG_HOME:-$HOME/.config}/unity3d/"

	GEOMKILL="0"
	COUNT=$(( $COUNT + 1 ))

	printf "\n\e[32mLaunching KSP, attempt ${COUNT}... Hold on to your helmets and pray the Kraken!\e[39m\n\n"

	## multiple variants, some work better than others.
	#./"${BINARY}" -screen-fullscreen 0 -screen-width $WIN_WIDTH -screen-height $WIN_HEIGHT &
	./"${BINARY}" -screen-fullscreen 0 -popupwindow -screen-width $WIN_WIDTH -screen-height $WIN_HEIGHT &
	#./"${BINARY}" -popupwindow -screen-fullscreen &
	KSPPID=$!

	printf "\e[32mLaunched with PID ${KSPPID}.\e[39m\n\n"

	printf "\e[33mBumping KSP OOM killer score in case it goes berserk and chews up all the memory at once.\nCurrent OOM score: $(cat /proc/${KSPPID}/oom_score)\e[39m\n"
	echo 15 > "/proc/${KSPPID}/oom_adj"
	printf "\e[33mNew OOM score: $(cat /proc/${KSPPID}/oom_score)\e[39m\n"

	if [ -x "$(which xwininfo)" ]
	then
		printf "Starting window geometry guard...\n"
		STOPDATE="$(date +%s -d "$GEOM_GUARD_TIME")"
		while [ "$(date +%s)" -lt "$STOPDATE" ] && kill -0 "$KSPPID" 2> /dev/null
		do
			GEOM="$(xwininfo -name "Kerbal Space Program" 2>/dev/null)"
			HEIGHT="${GEOM##*Height:}"
			HEIGHT="${GEOM##*[[:space:]]}"
			HEIGHT="${HEIGHT%%[^0-9]*}"
			WIDTH="${GEOM##*Width:}"
			WIDTH="${GEOM##*[[:space:]]}"
			WIDTH="${WIDTH%%[^0-9]*}"

			if [ "${WIDTH:-0}" -gt "$(( $WIN_WIDTH * 2 ))" -o "${HEIGHT:-0}" -gt "$(( $WIN_HEIGHT * 2 ))" -o "${WIDTH:-10000}" -lt "$(( $WIN_WIDTH / 2 ))" -o "${HEIGHT:-10000}" -lt "$(( $WIN_HEIGHT / 2 ))" ]
			then
				kill -9 "$KSPPID"
				GEOMKILL=1
				printf "\n\e[31mWindow geometry is freaky (${WIDTH:-NA}x${HEIGHT:-NA}), killed KSP!\e[39m\n\n" >&2
				sleep 1
				break
			else
				GEOMKILL=0
			fi
			[ "$WIDTH" != "$PREVWIDTH" -o "$HEIGHT" != "$PREVHEIGHT" ] && printf "\e[33mWindow geometry changed from ${PREVWIDTH:-NA}x${PREVHEIGHT:-NA} to ${WIDTH:-NA}x${HEIGHT:-NA}\e[39m\n"
			PREVWIDTH=$WIDTH
			PREVHEIGHT=$HEIGHT
		done
		[ "$GEOMKILL" = "0" ] && printf "\e[33mWindow geometry guard is (hopefully) no longer needed.\e[39m\n"
	else
		printf "\e[31mxwininfo not found, aborting window geometry guard!\nYou're on your own with OOM.\e[39m\n" >&2
	fi
done

wait

 

Note: Geometry guard might eat up some CPU.

Edited by Psycho_zs
Link to comment
Share on other sites

6 minutes ago, Psycho_zs said:

decimal delimiter settings resetting bug is still present. So, LC_ALL=C still needed. Bad window size bug is still in place.

Still waiting on Unity for a fix for these, the locale fix stopped working a while ago, and overriding the prefs doesn't seem to work, it's parsed before KSP starts and its values are set after KSP ends and Unity is shutting down.

Not that deleting the prefs helps much, it still sends a bad window size to Cinnamon when I run KSP.x86_64 after deleting the prefs.

Thanks for the new script though, that will help.

Link to comment
Share on other sites

This is my little shell script, might wanna take a look and/or share advise/suggest things for improvements. For me it runs perfectly on Ubuntu 16.04 (latest Kernel 4.4.0-67)

without

export LD_PRELOAD="libpthread.so.0 libGL.so.1"
export __GL_THREADED_OPTIMIZATIONS=1

I would have issues using the part highlighting

runKSP.sh

regards

Link to comment
Share on other sites

Just curious if someone encountered poor performance of Linux build vs Windows build?

I have laptop with 8 gigs of RAM and Intel HD4000. Winduz build under WINE works pretty dam good. I have 140 mods installed and framerate rarely drops below 15. At the same time Linux build of the game has ~4 FPS right from the start (loading screen and main menu) with zero mods installed.

Sounds familiar?

PS: Arch Linux x64, 64 bit WINE prefix.

Edited by RealGecko
Link to comment
Share on other sites

5 hours ago, azander said:

I have, but it was the improperly installed nVIDIA drive.

The WINE emulator was emulating DirectX so bypassed the openGL interface with the nVidia driver.

 

did you tried using wine-staging (current is v2.3)?

Edited by LatiMacciato
Link to comment
Share on other sites

15 hours ago, azander said:

I have, but it was the improperly installed nVIDIA drive.

The WINE emulator was emulating DirectX so bypassed the openGL interface with the nVidia driver.

Hmmm, I have only Mesa installed and no official Intel driver. Might be the case :)

Link to comment
Share on other sites

29 minutes ago, RealGecko said:

Hmmm, I have only Mesa installed and no official Intel driver. Might be the case :)

https://www-ssl.intel.com/content/www/us/en/support/graphics-drivers/000005520.html

Quote

Graphics Drivers for Linux*

 

Last Reviewed: 03-Nov-2016
Article ID: 000005520

 

Most versions of the Linux* operating system include Intel® graphics drivers. We recommend that you check with your Linux* distribution vendor or computer manufacturer for updated graphics drivers.

Intel® graphics drivers for Linux are available on the Linux and Intel® graphics downloads section.

Support is available through the open-source community. See the Community section.

 

Note to Linux developers

We provide development drivers for Intel® graphics to the open-source community. The development drivers give the Linux developer community an opportunity to provide feedback on the driver and participate in development.

You can get development driver source code from public repositories found in the downloads section.

Development driver support is only available through the open-source community. See the Community section.

 

Intel drivers should be built-in, I guess you can try the oibaf ppa for newer drivers, but unfortunately we're kinda stuck with the performance of the Unity3D Linux builds.

As the Unity3D Linux editor and exporting matures we'll likely see better performance, and I'm sad to say but KSP runs best on Linux with the proprietary Nvidia drivers, I'd love to hear from anyone with a AMD RX 480 about performance numbers.

Link to comment
Share on other sites

By the way I tried native Doomsday 2 and it works pretty good without official Intel driver and with only Mesa. As far as I can remember from reading a post on some Linux dedicated forum official Intel driver is used only for 2D acceleration. I guess that's why I do not have it installed :)

Anyway I'm totally happy with playing KSP with WINE. Just curious why native build is so slow.

Link to comment
Share on other sites

My new and improved launcher script. I've been using this version for a week or so. It can now attempt to recover from some non-lethal resolution jumps like 2048x1 window. If the game itself survives that, loading will continue with proper size.

Spoiler

#!/bin/sh

# http://forum.kerbalspaceprogram.com/index.php?/profile/137644-psycho_zs/
# v201703.2
# WTFPL

BINARY=KSP.x86_64

WIN_WIDTH=1366
WIN_HEIGHT=768

GEOM_GUARD_TIME="180 seconds"

ALLOW_WIDTH_MAX=$(( $WIN_WIDTH * 3 ))
ALLOW_HEIGHT_MAX=$(( $WIN_HEIGHT * 3 ))

GUARD=1
[ ! -x "$(which xwininfo)" ] && { GUARD=0 ; printf "\e[31mWarning: xwininfo not found or is not an executable!\n         Geometry guard will not work!\e[39m\n" >&2 ; }
[ ! -x "$(which xprop)" ] && { GUARD=0 ; printf "\e[31mWarning: xprop not found or is not an executable!\n         Geometry guard will not work!\e[39m\n" >&2 ; }


# change dir to script location
cd "$(dirname "$(readlink -f "$0")")"

printf "Still can not learn localized fraction delimiters? setting LC_ALL=C\n"
LANG=C
LC_ALL=C
export LC_ALL
export LANG
unset LANGUAGE

printf "Fixing weird permissions from game archive.\n"
find . -type d -exec chmod 755 "{}" \;
find . -type f -exec chmod 644 "{}" \;
chmod 755 KSP.x86  KSP.x86_64  Launcher.x86  Launcher.x86_64 "${BINARY}" "$(basename "$0")"

# trap for child process cleanup
trap 'kill $KSP_PID 2> /dev/null' EXIT HUP INT TERM

GEOMKILL="2"
COUNT="0"

until [ "$GEOMKILL" = "0" ]
do
	[ "$GEOMKILL" = "1" ] && printf "\nHere we go again...\n"

	printf "Clearing unity3d config dir\n"
	[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/unity3d/" ] && rm -r "${XDG_CONFIG_HOME:-$HOME/.config}/unity3d/"

	GEOMKILL="0"
	COUNT=$(( $COUNT + 1 ))

	printf "\n\e[32mLaunching KSP, attempt ${COUNT}... Hold on to your helmets and pray the Kraken!\e[39m\n\n"
	./"${BINARY}" -screen-fullscreen 0 -popupwindow -screen-width $WIN_WIDTH -screen-height $WIN_HEIGHT &
	KSP_PID=$!

	printf "\e[32mLaunched with PID ${KSP_PID}.\e[39m\n\n"

	printf "\e[33mBumping KSP OOM killer score in case it goes berserk and chews up all the memory at once.\nCurrent OOM score: $(cat /proc/${KSP_PID}/oom_score)\e[39m\n"
	echo 15 > "/proc/${KSP_PID}/oom_adj"
	printf "\e[33mNew OOM score: $(cat /proc/${KSP_PID}/oom_score)\e[39m\n"

	if [ "$GUARD" = "1" ]
	then

		printf "Starting window geometry repairer...\n"

		while kill -0 "$KSP_PID" 2> /dev/null
		do
			# drop potentially corrupted window hints including size and increment restrictions
			# and force window size
			xprop -name "Kerbal Space Program" -remove WM_NORMAL_HINTS 2>/dev/null
			wmctrl -Fr "Kerbal Space Program" -e "0,-1,-1,${WIN_WIDTH},${WIN_HEIGHT}" 2>/dev/null
			# do this once in 3 seconds, we're not rushing anywhere
			sleep 3
		done &

		printf "Starting window geometry guard...\n"
		STOPDATE="$(date +%s -d "$GEOM_GUARD_TIME")"

		while kill -0 "$KSP_PID" 2> /dev/null && [ "$(date +%s)" -lt "$STOPDATE" ]
		do
			# this should be fast, only one subprocess per iteration, the rest is shell
			GEOM="$(xwininfo -name "Kerbal Space Program" 2>/dev/null)"
			HEIGHT="${GEOM##*Height:}"
			HEIGHT="${GEOM##*[[:space:]]}"
			HEIGHT="${HEIGHT%%[^0-9]*}"
			WIDTH="${GEOM##*Width:}"
			WIDTH="${GEOM##*[[:space:]]}"
			WIDTH="${WIDTH%%[^0-9]*}"

			# Check if geometry goes too far up.
			if [ "${WIDTH:-0}" -gt "$ALLOW_WIDTH_MAX" -o "${HEIGHT:-0}" -gt "$ALLOW_HEIGHT_MAX" ]
			then
				kill -9 "$KSP_PID"
				GEOMKILL=1
				printf "\n\e[31mWindow geometry is freaky (${WIDTH:-NA}x${HEIGHT:-NA}), killed KSP!\e[39m\n\n" >&2
				sleep 1
				break
			else
				GEOMKILL=0
			fi
			[ "$WIDTH" != "$PREVWIDTH" -o "$HEIGHT" != "$PREVHEIGHT" ] && printf "\e[33mWindow geometry changed from ${PREVWIDTH:-NA}x${PREVHEIGHT:-NA} to ${WIDTH:-NA}x${HEIGHT:-NA}\e[39m\n"
			PREVWIDTH=$WIDTH
			PREVHEIGHT=$HEIGHT
		done
		[ "$GEOMKILL" = "0" ] && printf "\e[33mWindow geometry guard is (hopefully) no longer needed.\e[39m\n"
	else
		printf "\e[31mWindow geometry guard is missing its tools!\nYou're on your own with OOM.\e[39m\n" >&2
	fi
done

wait

 

 

Link to comment
Share on other sites

On 01/04/2017 at 2:49 AM, sal_vager said:

Bug #11382, "Bad resolution calls crash X window manager", should now be fixed in the 1.2.9 pre-release!

Please test it on as many Linux desktops as you can :)

So far so good. :)
That said, this appears to be a workaround (not using Unitys size restriction) and the real fix (using SDL like a sensible person) is landing in 5.6. Why Unity decided to reinvent the wheel (badly) in the first place boggles the mind.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...