diff --git a/containerfiles/runner-builder.Containerfile b/containerfiles/runner-builder.Containerfile index 1a074c43..71784349 100644 --- a/containerfiles/runner-builder.Containerfile +++ b/containerfiles/runner-builder.Containerfile @@ -130,7 +130,7 @@ RUN --mount=type=cache,target=${CARGO_HOME}/registry \ cargo install cargo-c # Clone repository -RUN git clone --depth 1 --rev "e4c70b64dad3cd8bbf5eec011f419386adf737ee" https://github.com/games-on-whales/gst-wayland-display.git +RUN git clone --depth 1 --rev "67b1183997fd7aaf57398e4b01bd64c4d2433c45" https://github.com/games-on-whales/gst-wayland-display.git #-------------------------------------------------------------------- FROM gst-wayland-deps AS gst-wayland-planner diff --git a/containerfiles/runner-common.Containerfile b/containerfiles/runner-common.Containerfile index 56d0431c..9ed3bf35 100644 --- a/containerfiles/runner-common.Containerfile +++ b/containerfiles/runner-common.Containerfile @@ -15,7 +15,7 @@ RUN --mount=type=cache,target=/var/cache/pacman/pkg \ pacman -S --needed --noconfirm \ vulkan-intel lib32-vulkan-intel vpl-gpu-rt \ vulkan-radeon lib32-vulkan-radeon \ - mesa lib32-mesa \ + mesa lib32-mesa vulkan-mesa-layers lib32-vulkan-mesa-layers \ gtk3 lib32-gtk3 \ sudo xorg-xwayland seatd libinput gamescope mangohud wlr-randr \ pipewire pipewire-pulse pipewire-alsa wireplumber \ @@ -68,9 +68,7 @@ COPY packages/configs/wireplumber.conf.d/* /etc/wireplumber/wireplumber.conf.d/ COPY packages/configs/pipewire.conf.d/* /etc/pipewire/pipewire.conf.d/ ## MangoHud Config ## -RUN mkdir -p "${NESTRI_HOME}/.config/MangoHud" - -COPY packages/configs/MangoHud/MangoHud.conf "${NESTRI_HOME}/.config/MangoHud/" +COPY packages/configs/MangoHud/MangoHud.conf /etc/nestri/configs/MangoHud/ ### Artifacts from Builder ### COPY --from=builder /artifacts/bin/nestri-server /usr/bin/ diff --git a/packages/input/src/keyboard.ts b/packages/input/src/keyboard.ts index 15918ea2..c7242a0a 100644 --- a/packages/input/src/keyboard.ts +++ b/packages/input/src/keyboard.ts @@ -36,10 +36,8 @@ export class Keyboard { if (this.connected) this.stop(); this.connected = true; - document.addEventListener("keydown", this.keydownListener, { - passive: false, - }); - document.addEventListener("keyup", this.keyupListener, { passive: false }); + document.addEventListener("keydown", this.keydownListener); + document.addEventListener("keyup", this.keyupListener); } private stop() { @@ -73,6 +71,6 @@ export class Keyboard { private keyToVirtualKeyCode(code: string) { // Treat Home key as Escape - TODO: Make user-configurable if (code === "Home") return 1; - return keyCodeToLinuxEventCode[code] || undefined; + return keyCodeToLinuxEventCode[code] || 0; } } diff --git a/packages/input/src/mouse.ts b/packages/input/src/mouse.ts index a709c53c..ea3d43e8 100644 --- a/packages/input/src/mouse.ts +++ b/packages/input/src/mouse.ts @@ -35,8 +35,6 @@ export class Mouse { this.wrtc = webrtc; this.canvas = canvas; - this.sendInterval = 1000 / webrtc.currentFrameRate; - this.mousemoveListener = (e: MouseEvent) => { e.preventDefault(); e.stopPropagation(); @@ -77,18 +75,10 @@ export class Mouse { if (document.pointerLockElement == this.canvas) { this.connected = true; - this.canvas.addEventListener("mousemove", this.mousemoveListener, { - passive: false, - }); - this.canvas.addEventListener("mousedown", this.mousedownListener, { - passive: false, - }); - this.canvas.addEventListener("mouseup", this.mouseupListener, { - passive: false, - }); - this.canvas.addEventListener("wheel", this.mousewheelListener, { - passive: false, - }); + this.canvas.addEventListener("mousemove", this.mousemoveListener); + this.canvas.addEventListener("mousedown", this.mousedownListener); + this.canvas.addEventListener("mouseup", this.mouseupListener); + this.canvas.addEventListener("wheel", this.mousewheelListener); } else { if (this.connected) { this.stop(); @@ -106,7 +96,7 @@ export class Mouse { private startProcessing() { setInterval(() => { - if (this.connected && (this.movementX !== 0 || this.movementY !== 0)) { + if (this.connected) { this.sendAggregatedMouseMove(); this.movementX = 0; this.movementY = 0; diff --git a/packages/input/src/webrtc-stream.ts b/packages/input/src/webrtc-stream.ts index 8d202034..211371f6 100644 --- a/packages/input/src/webrtc-stream.ts +++ b/packages/input/src/webrtc-stream.ts @@ -13,9 +13,10 @@ import { ProtoClientRequestRoomStream, ProtoClientRequestRoomStreamSchema, ProtoICE, - ProtoICESchema, ProtoRaw, + ProtoICESchema, + ProtoRaw, ProtoSDP, - ProtoSDPSchema + ProtoSDPSchema, } from "./proto/types_pb"; import { P2PMessageStream } from "./streamwrapper"; @@ -38,7 +39,6 @@ export class WebRTCStream { private _roomName: string | undefined = undefined; private _isConnected: boolean = false; private _dataChannelCallbacks: Array<(data: any) => void> = []; - currentFrameRate: number = 100; constructor( serverURL: string, @@ -126,11 +126,19 @@ export class WebRTCStream { } }); - this._msgStream.on("session-assigned", (data: ProtoClientRequestRoomStream) => { - this._sessionId = data.sessionId; - localStorage.setItem("nestri-session-id", this._sessionId); - console.log("Session ID assigned:", this._sessionId, "for room:", data.roomName); - }); + this._msgStream.on( + "session-assigned", + (data: ProtoClientRequestRoomStream) => { + this._sessionId = data.sessionId; + localStorage.setItem("nestri-session-id", this._sessionId); + console.log( + "Session ID assigned:", + this._sessionId, + "for room:", + data.roomName, + ); + }, + ); this._msgStream.on("offer", async (data: ProtoSDP) => { if (!this._pc) { @@ -293,26 +301,8 @@ export class WebRTCStream { this._onConnected( new MediaStream([this._audioTrack, this._videoTrack]), ); - - // Continuously set low-latency target - this._pc.getReceivers().forEach((receiver: RTCRtpReceiver) => { - let intervalLoop = setInterval(async () => { - if ( - receiver.track.readyState !== "live" || - (receiver.transport && receiver.transport.state !== "connected") - ) { - clearInterval(intervalLoop); - return; - } else { - // @ts-ignore - receiver.jitterBufferTarget = receiver.jitterBufferDelayHint = receiver.playoutDelayHint = 0; - } - }, 50); - }); } } - - this._gatherFrameRate(); } else if ( this._pc.connectionState === "failed" || this._pc.connectionState === "closed" || @@ -412,11 +402,16 @@ export class WebRTCStream { }; } - private _gatherFrameRate() { - if (this._pc === undefined || this._videoTrack === undefined) return; + private async _gatherStats(): Promise { + if ( + this._pc === undefined || + this._videoTrack === undefined || + !this._isConnected + ) + return null; - const videoInfoPromise = new Promise<{ fps: number }>((resolve) => { - // Keep trying to get fps until it's found + return new Promise((resolve) => { + // Keep trying to get stats until gotten const interval = setInterval(async () => { if (this._pc === undefined) { clearInterval(interval); @@ -428,15 +423,11 @@ export class WebRTCStream { if (report.type === "inbound-rtp") { clearInterval(interval); - resolve({ fps: report.framesPerSecond }); + resolve({ pli: report.pliCount, nack: report.nackCount }); } }); }, 250); }); - - videoInfoPromise.then((value) => { - this.currentFrameRate = value.fps; - }); } // Send binary message through the data channel diff --git a/packages/scripts/envs.sh b/packages/scripts/envs.sh index 0da74354..7c89902f 100644 --- a/packages/scripts/envs.sh +++ b/packages/scripts/envs.sh @@ -13,4 +13,4 @@ export GST_GL_API=gles2 export GST_GL_WINDOW=surfaceless # Gamescope does not respect MangoHud default config location -export MANGOHUD_CONFIGFILE=${NESTRI_HOME}/.config/MangoHud/MangoHud.conf +export MANGOHUD_CONFIGFILE=/etc/nestri/configs/MangoHud/MangoHud.conf diff --git a/packages/server/rust-toolchain.toml b/packages/server/rust-toolchain.toml index 5099b481..3313c633 100644 --- a/packages/server/rust-toolchain.toml +++ b/packages/server/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.90" \ No newline at end of file +channel = "1.91" \ No newline at end of file