From 82b597506b9f1fbdcf49bd48c5498555135e7bb6 Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 12 Mar 2026 08:46:18 +0100 Subject: [PATCH] debug: add IPC logging from capture window to main process Capture window logs now forwarded to main process via IPC to diagnose why video tracks are missing from the WebRTC answer SDP. Co-Authored-By: Claude Opus 4.6 --- lib/remote-capture-preload.js | 5 ++++- lib/remote-capture.html | 42 ++++++++++++++++++++++------------- main.js | 5 +++++ package.json | 2 +- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/lib/remote-capture-preload.js b/lib/remote-capture-preload.js index 5ba32fe..c32fa96 100644 --- a/lib/remote-capture-preload.js +++ b/lib/remote-capture-preload.js @@ -16,5 +16,8 @@ contextBridge.exposeInMainWorld('capture', { sendInput: (data) => ipcRenderer.send('remote:input-event', data), // Notify main process of client connection/disconnection - notifyClientCount: (count) => ipcRenderer.send('remote:client-count', count) + notifyClientCount: (count) => ipcRenderer.send('remote:client-count', count), + + // Debug logging to main process + log: (...args) => ipcRenderer.send('remote:capture-log', args.join(' ')) }); diff --git a/lib/remote-capture.html b/lib/remote-capture.html index 89cd076..47337cc 100644 --- a/lib/remote-capture.html +++ b/lib/remote-capture.html @@ -12,26 +12,35 @@ async function getCaptureStream() { // desktopCapturer runs in main process (Electron 33+), we get the source ID via IPC const sourceId = await window.capture.getSourceId(); + window.capture.log('getSourceId returned:', sourceId || 'NULL'); if (!sourceId) throw new Error('No capture source ID from main process'); - captureStream = await navigator.mediaDevices.getUserMedia({ - audio: false, - video: { - mandatory: { - chromeMediaSource: 'desktop', - chromeMediaSourceId: sourceId, - minWidth: 1280, - maxWidth: 1920, - minHeight: 720, - maxHeight: 1080, - maxFrameRate: 30 + try { + captureStream = await navigator.mediaDevices.getUserMedia({ + audio: false, + video: { + mandatory: { + chromeMediaSource: 'desktop', + chromeMediaSourceId: sourceId, + minWidth: 1280, + maxWidth: 1920, + minHeight: 720, + maxHeight: 1080, + maxFrameRate: 30 + } } - } - }); - return captureStream; + }); + const tracks = captureStream.getTracks(); + window.capture.log('getUserMedia OK, tracks:', tracks.length, tracks.map(t => `${t.kind}:${t.readyState}`).join(',')); + return captureStream; + } catch (err) { + window.capture.log('getUserMedia FAILED:', err.message); + throw err; + } } async function handleOffer(clientId, offer, role) { + window.capture.log('handleOffer called for', clientId); const stream = await getCaptureStream(); const pc = new RTCPeerConnection({ @@ -40,9 +49,12 @@ async function handleOffer(clientId, offer, role) { clients.set(clientId, { pc, role }); // Add video tracks - for (const track of stream.getTracks()) { + const tracks = stream.getTracks(); + window.capture.log('Adding', tracks.length, 'tracks to peer connection'); + for (const track of tracks) { pc.addTrack(track, stream); } + window.capture.log('Senders after addTrack:', pc.getSenders().length); // Handle DataChannel from dashboard (dashboard creates it as offerer) pc.ondatachannel = (event) => { diff --git a/main.js b/main.js index 856f605..be5d1a1 100644 --- a/main.js +++ b/main.js @@ -1009,6 +1009,11 @@ ipcMain.on('remote:signaling-from-capture', (_event, data) => { } }); +// IPC: Debug logging from capture window +ipcMain.on('remote:capture-log', (_event, msg) => { + debugLog('remote-capture:', msg); +}); + // IPC: Input events from capture window ipcMain.on('remote:input-event', (_event, data) => { if (!mainWindow || mainWindow.isDestroyed()) return; diff --git a/package.json b/package.json index 7075e7d..1a64d12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "multi-hoster-uploader", - "version": "2.1.4", + "version": "2.1.5", "description": "Upload files to doodstream, voe, vidmoly, byse simultaneously", "main": "main.js", "scripts": {