Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions opennow-stable/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ async function createMainWindow(): Promise<void> {
contextIsolation: true,
nodeIntegration: false,
sandbox: false,
backgroundThrottling: false,
},
});

Expand All @@ -524,6 +525,22 @@ async function createMainWindow(): Promise<void> {
});
}

if (process.platform === "darwin") {
// On macOS, sync native window fullscreen with HTML fullscreen to prevent
// the compositor hiccup that causes frame drop bursts on fullscreen transitions.
mainWindow.webContents.on("enter-html-full-screen", () => {
if (mainWindow && !mainWindow.isDestroyed() && !mainWindow.isFullScreen()) {
mainWindow.setFullScreen(true);
}
});

mainWindow.webContents.on("leave-html-full-screen", () => {
if (mainWindow && !mainWindow.isDestroyed() && mainWindow.isFullScreen()) {
mainWindow.setFullScreen(false);
}
});
}

if (process.env.ELECTRON_RENDERER_URL) {
await mainWindow.loadURL(process.env.ELECTRON_RENDERER_URL);
} else {
Expand Down
26 changes: 22 additions & 4 deletions opennow-stable/src/renderer/src/gfn/webrtcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ import {
} from "./sdp";
import { MicrophoneManager, type MicState, type MicStateChange } from "./microphoneManager";

/** Returns true when running on macOS (Electron/Chromium userAgent). */
function isMacOS(): boolean {
const ua = navigator.userAgent?.toLowerCase() ?? "";
const platform = navigator.platform?.toLowerCase() ?? "";
return platform.includes("mac") || ua.includes("macintosh");
}

interface OfferSettings {
codec: VideoCodec;
colorQuality: ColorQuality;
Expand Down Expand Up @@ -478,8 +485,10 @@ export class GfnWebRtcClient {
private static readonly RELIABLE_MOUSE_BACKPRESSURE_BYTES = 64 * 1024;
private static readonly BACKPRESSURE_LOG_INTERVAL_MS = 2000;
private static readonly VIDEO_BASE_JITTER_TARGET_MS = 12;
private static readonly VIDEO_BASE_JITTER_TARGET_MAC_MS = 20;
private static readonly AUDIO_BASE_JITTER_TARGET_MS = 20;
private static readonly VIDEO_PRESSURE_JITTER_TARGET_MS = 30;
private static readonly VIDEO_PRESSURE_JITTER_TARGET_MAC_MS = 38;
private static readonly AUDIO_PRESSURE_JITTER_TARGET_MS = 32;
private static readonly DECODER_PRESSURE_CONSECUTIVE_POLLS = 3;
private static readonly DECODER_STABLE_CONSECUTIVE_POLLS = 6;
Expand Down Expand Up @@ -538,6 +547,7 @@ export class GfnWebRtcClient {
private inputQueueMaxSchedulingDelayMsWindow = 0;
private inputQueuePressureLoggedAtMs = 0;
private inputQueueDropCount = 0;
private readonly platformIsMac: boolean = isMacOS();

// Decoder pressure detection + recovery state.
private decoderPressureActive = false;
Expand All @@ -549,7 +559,9 @@ export class GfnWebRtcClient {
private negotiatedMaxBitrateKbps = 0;
private currentBitrateCeilingKbps = 0;
private receiverLatencyTargets = {
video: GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MS,
video: isMacOS()
? GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MAC_MS
: GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MS,
audio: GfnWebRtcClient.AUDIO_BASE_JITTER_TARGET_MS,
};
private activeReceivers: Array<{ receiver: RTCRtpReceiver; kind: "audio" | "video" }> = [];
Expand Down Expand Up @@ -782,8 +794,12 @@ export class GfnWebRtcClient {
this.decoderPressureActive = active;
this.diagnostics.decoderPressureActive = active;
this.receiverLatencyTargets.video = active
? GfnWebRtcClient.VIDEO_PRESSURE_JITTER_TARGET_MS
: GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MS;
? (this.platformIsMac
? GfnWebRtcClient.VIDEO_PRESSURE_JITTER_TARGET_MAC_MS
: GfnWebRtcClient.VIDEO_PRESSURE_JITTER_TARGET_MS)
: (this.platformIsMac
? GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MAC_MS
: GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MS);
this.receiverLatencyTargets.audio = active
? GfnWebRtcClient.AUDIO_PRESSURE_JITTER_TARGET_MS
: GfnWebRtcClient.AUDIO_BASE_JITTER_TARGET_MS;
Expand Down Expand Up @@ -812,7 +828,9 @@ export class GfnWebRtcClient {
this.lastDecoderKeyframeRequestAtMs = 0;
this.negotiatedMaxBitrateKbps = 0;
this.currentBitrateCeilingKbps = 0;
this.receiverLatencyTargets.video = GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MS;
this.receiverLatencyTargets.video = this.platformIsMac
? GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MAC_MS
: GfnWebRtcClient.VIDEO_BASE_JITTER_TARGET_MS;
this.receiverLatencyTargets.audio = GfnWebRtcClient.AUDIO_BASE_JITTER_TARGET_MS;
this.activeReceivers = [];
this.diagnostics.decoderPressureActive = false;
Expand Down
Loading