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

Wayland support (Linux)? #6

Open
moonpiedumplings opened this issue Jun 21, 2022 · 25 comments
Open

Wayland support (Linux)? #6

moonpiedumplings opened this issue Jun 21, 2022 · 25 comments

Comments

@moonpiedumplings
Copy link

I am having this weird issue where whenever games are played on xwayland or on x11, ping increases a lot and players teleport everywhere.

More info --> https://www.reddit.com/r/archlinux/comments/vh42lx/how_do_i_set_up_reverse_prime_for_an_amd_igpu_and/

Is there any way to run this client natively on wayland, rather than on xwayland? I believe that that would solve my issues.

@KraXen72
Copy link
Owner

i mean
if you can find some chromium flag(s) that make it run on xwayland, i can add a setting to enable them

@KraXen72
Copy link
Owner

or cli arguments

@moonpiedumplings
Copy link
Author

According to the arch wiki, the electron flags are

--enable-features=UseOzonePlatform --ozone-platform=wayland

And the chromium flag (for chromium 97+) is

--ozone-platform-hint=auto

@moonpiedumplings
Copy link
Author

I tried running the client with these flags, and had no luck

@KraXen72
Copy link
Owner

try clonning the repo, editing switches.ts to add your flags and then run the client

@moonpiedumplings
Copy link
Author

moonpiedumplings commented Jun 21, 2022

I know how to clone the repo, and i figured out how to edit switches.ts, but I dunno how to run the client.

npm run start spits an error, as does npm run dev

I have no programming experience.

@KraXen72
Copy link
Owner

it is okay. there are instructions on how to build from source in the readme, but run npm i and then after that's done run npm run dev. in the switches.ts, make sure the flags you want are not in an if so they get applied every time. if they work I'll add a setting to add them

@asger-finding
Copy link
Collaborator

@moonpiedumplings Make sure you have Node installed. npm comes with node.

@moonpiedumplings
Copy link
Author

moonpiedumplings commented Jun 24, 2022

export function applyCommandLineSwitches(userPrefs: UserPrefs) {

	app.commandLine.appendSwitch('disable-gpu-sandbox');
	app.commandLine.appendSwitch('use-global', 'egl');
	app.commandLine.appendSwitch('enable-features', 'UseOzonePlatform');
	app.commandLine.appendSwitch('ozone-platform', 'wayland');

	if (userPrefs.safeFlags_removeUselessFeatures) {
		app.commandLine.appendSwitch('disable-breakpad');

etc, etc, from switches.ts. 

Is this right? I get an error. 

@moonpiedumplings
Copy link
Author

Ignore the previous comment


/// <reference path="global.d.ts" />

/** applies command line switches to the app based on the passed userprefs */
export function applyCommandLineSwitches(userPrefs: UserPrefs) {

	app.commandLine.appendSwitch('disable-gpu-sandbox');
	app.commandLine.appendSwitch('use-global', 'egl');
	app.commandLine.appendSwitch('enable-features', 'UseOzonePlatform');
	app.commandLine.appendSwitch('ozone-platform', 'wayland');

	if (userPrefs.safeFlags_removeUselessFeatures) {
		app.commandLine.appendSwitch('disable-breakpad');
		app.commandLine.appendSwitch('disable-print-preview');
		app.commandLine.appendSwitch('disable-metrics-repo');
		app.commandLine.appendSwitch('disable-metrics');
		app.commandLine.appendSwitch('disable-2d-canvas-clip-aa');
		app.commandLine.appendSwitch('disable-bundled-ppapi-flash');
		app.commandLine.appendSwitch('disable-logging');
		app.commandLine.appendSwitch('disable-hang-monitor');

		console.log('Removed useless features');
	}
	if (userPrefs.safeFlags_helpfulFlags) {
		app.commandLine.appendSwitch('enable-javascript-harmony');
		app.commandLine.appendSwitch('enable-future-v8-vm-features');
		app.commandLine.appendSwitch('enable-webgl2-compute-context');

		console.log('Applied helpful flags');
	}
	if (userPrefs.experimentalFlags_increaseLimits) {
		app.commandLine.appendSwitch('renderer-process-limit', '100');
		app.commandLine.appendSwitch('max-active-webgl-contexts', '100');
		app.commandLine.appendSwitch('webrtc-max-cpu-consumption-percentage=100');
		app.commandLine.appendSwitch('ignore-gpu-blacklist');

		console.log('Applied flags to increase limits');
	}
	if (userPrefs.experimentalFlags_lowLatency) {
		app.commandLine.appendSwitch('enable-highres-timer'); // supposedly lowers latency
		app.commandLine.appendSwitch('enable-quic'); // enables an experimental low-latency protocol that might or might not be used, who knows
		app.commandLine.appendSwitch('enable-accelerated-2d-canvas');

		console.log('Applied latency-reducing flags');
	}
	//if (userPrefs.experimentalFlags_experimental) {--disable-gpu-sandbox --ignore-gpu-blocklist --enable-gpu-rasterization --enable-zero-copy --disable-gpu-driver-bug-workarounds --use-gl=egl --enable-features=UseOzonePlatform --ozone-platform=wayland)
	// do they crash the game? not for me. do they actually help? ¯\_(ツ)_/¯
		app.commandLine.appendSwitch('disable-low-end-device-mode');
		app.commandLine.appendSwitch('high-dpi-support', '1');
		app.commandLine.appendSwitch('ignore-gpu-blacklist');
		app.commandLine.appendSwitch('no-pings');
		app.commandLine.appendSwitch('no-proxy-server');

		console.log('Enabled Experiments');
	}
	if (userPrefs.safeFlags_gpuRasterizing) {
	// do they crash the game? not for me. do they actually help? yeah kind of. depending on your gpu etc.
		app.commandLine.appendSwitch('enable-gpu-rasterization');
		app.commandLine.appendSwitch('disable-zero-copy'); // this is really important, otherwise the game crashes.
		console.log('GPU rasterization active');
	}

	if (userPrefs.fpsUncap) {
		app.commandLine.appendSwitch('disable-frame-rate-limit');
		app.commandLine.appendSwitch('disable-gpu-vsync');
		console.log('Removed FPS Cap');
	}

	if (userPrefs['angle-backend'] !== 'default') {
		if (userPrefs['angle-backend'] === 'vulkan') {
			app.commandLine.appendSwitch('use-angle', 'vulkan');
			app.commandLine.appendSwitch('use-vulkan');
			app.commandLine.appendSwitch('--enable-features=Vulkan');

			console.log('VULKAN INITIALIZED');
		} else {
			app.commandLine.appendSwitch('use-angle', userPrefs['angle-backend'] as string);

			console.log(`Using Angle: ${ userPrefs['angle-backend']}`);
		}
	}
	if (userPrefs.inProcessGPU) {
		app.commandLine.appendSwitch('in-process-gpu');
		console.log('In Process GPU is active');
	}
}

However, I get an error.

[moonpie@portablepower crankshaft]$ npm run start

> [email protected] start
> npm run build && electron .


> [email protected] build
> tsc

src/switches.ts:87:1 - error TS1128: Declaration or statement expected.

87 }
   ~


Found 1 error in src/switches.ts:87

@moonpiedumplings
Copy link
Author

moonpiedumplings commented Jun 24, 2022

Ignore my comment above, I solved it, it was a stray parenthesis.

I launched the program successfully, but everything is broken. First of all, xwayland is still being used.

Secondly, I get a black screen with a crosshair, the the ping/fps measures in the top program are chaning values wildly. Unplayable. Appending --disable-gpu-sandbox --use-gl=egl to npm run start did nothing.

image

@KraXen72
Copy link
Owner

try changing the ANGLE backend to different values in the settings.json file. the options are ['default', 'gl', 'd3d11', 'd3d9', 'd3d11on12', 'vulkan']

@KraXen72
Copy link
Owner

not sure if npm run start accepts electron command line argumens like this. you should probably add them to switches.ts if you wnat to see them in effect. your modification of the code is correct, you can add flags like you did.

@Mixaz017
Copy link
Collaborator

Yes npm run accepts arguments passed to the actual script with the typical -- separator syntax. For example to launch crankshaft with OpenGL backend: npm start -- --use-angle=gl

@moonpiedumplings
Copy link
Author

Okay, so I had angle set to vulkan, and after setting it to gl, it works now. 300 fps average. Lag/ping is way better, but occasionally some players teleport. Annoying, but better than players always teleporting.

No wayland though, and 300 fps is pitiful because I can get 700 fps when using the amd integrated gpu on the actual laptop screen, rather than on an external monitor.

Is there any way I can run this program with the nvidia gpu? prime-run doesn't work. There must be some kind of electron/chromium flag to select gpu...

@KraXen72
Copy link
Owner

@KraXen72
Copy link
Owner

did you manage to solve this? or?

@KraXen72
Copy link
Owner

i do not have linux installed but i do care about good linux support. If there is anything else i can do, please let me know

@Mixaz017
Copy link
Collaborator

Mixaz017 commented May 30, 2023

This must be another Electron version related issue, native Wayland works on Electron 17 or above (its supposed to work on 12 or above but didn't work on my machine).

@groggone
Copy link

groggone commented Sep 5, 2023

So is mine, tried to do the above ("pnpm i", "npm run dist", and "npm run dev") but it doesn't work and it keeps saying things like this:

> [email protected] dev
> concurrently --kill-others "node esbuilder.js --watch" "electron ."

[0] building(minifying): false watching: true
[0] build completed with 0 errors
[1] Removed useless features
[1] Applied helpful flags
[1] Applied flags to increase limits
[1] Applied latency-reducing flags
[1] Enabled Experiments
[1] Removed FPS Cap
[1] Using Angle: gl
[1] The futex facility returned an unexpected error code.
[1] /home/lines/Downloads/Entertainment/Games/Krunker/crankshaft/node_modules/.pnpm/[email protected]/node_modules/electron/dist/electron exited with signal SIGABRT
[1] electron . exited with code 1
--> Sending SIGTERM to other processes..
[0] node esbuilder.js --watch exited with code SIGTERM

@KraXen72
Copy link
Owner

KraXen72 commented Sep 5, 2023

most likely an electron problem. also, pnpm dev starts a dev server of sorts (esbuild watch mode), so for building & testing i'd recommend using pnpm start

@KraXen72
Copy link
Owner

KraXen72 commented Sep 5, 2023

try the wayland flags for electron? (ozone layer or something, not particularly sure)

@groggone
Copy link

groggone commented Sep 29, 2023

What you were suggesting didn't work at all, maybe it's because the electron version of the client is very old. What version of Electron is the Crankshaft client using?

@Mixaz017
Copy link
Collaborator

maybe it's because the electron version of the client is very old. What version of Electron is the Crankshaft client using?

#6 (comment)

Yes it is because of old Electron. Crankshaft uses v10.

@KraXen72
Copy link
Owner

KraXen72 commented Oct 8, 2024

after 2 years, i am now using linux with wayland. so if i run into any issues, i'll try to fix them.

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

No branches or pull requests

5 participants