From 69999fa6cce36a20994cefefe91fc5048da0cbe6 Mon Sep 17 00:00:00 2001 From: natehuby76 <86365949+natehuby76@users.noreply.github.com> Date: Fri, 9 Oct 2026 12:59:18 -0400 Subject: [PATCH] fix live view authentication and encoder errors --- tools/galaxy_bluetooth/companion.py | 7 ++++++- .../ios/GalaxyBluetooth/CompanionDiagnostics.swift | 3 +++ .../ios/GalaxyBluetooth/PrivateLANHTTP.swift | 2 +- tools/galaxy_bluetooth/tests/test_companion.py | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/galaxy_bluetooth/companion.py b/tools/galaxy_bluetooth/companion.py index d048a1fbf9..6693312766 100644 --- a/tools/galaxy_bluetooth/companion.py +++ b/tools/galaxy_bluetooth/companion.py @@ -156,6 +156,7 @@ class CompanionPublisher: self.last_encoded = 0.0 self.capture_error = None self.encoder_error = None + self.encoder_stderr = None def update(self, ui, gui): if not ENABLED.exists(): @@ -197,6 +198,9 @@ class CompanionPublisher: 'frameAgeSeconds': round(now - self.last_encoded, 2) if self.last_encoded else None, 'queuedImages': self.images.qsize(), 'captureError': self.capture_error, 'encoderError': self.encoder_error, + 'encoderStderr': self.encoder_stderr, + 'encoderExitCode': self.process.poll() if self.process is not None else None, + 'videoSize': list(self.video_size) if self.video_size else None, 'encoderRunning': self.process is not None and self.process.poll() is None, } atomic_write('capture-status.json', json.dumps(capture_status).encode()) @@ -323,6 +327,7 @@ class CompanionPublisher: '-flush_packets', '1', 'pipe:1'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.video_size = dimensions self.encoder_error = None + self.encoder_stderr = None threading.Thread(target=self.read_encoder_errors, args=(self.process,), daemon=True).start() threading.Thread(target=self.read_encoded, args=(self.process, self.sent_times), daemon=True).start() rl.image_format(image, rl.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) @@ -344,7 +349,7 @@ class CompanionPublisher: try: for line in process.stderr: if process is self.process: - self.encoder_error = line.decode(errors='replace').strip()[:500] + self.encoder_stderr = line.decode(errors='replace').strip()[:500] except (OSError, ValueError): pass diff --git a/tools/galaxy_bluetooth/ios/GalaxyBluetooth/CompanionDiagnostics.swift b/tools/galaxy_bluetooth/ios/GalaxyBluetooth/CompanionDiagnostics.swift index 5526337c85..6fc6c7ea66 100644 --- a/tools/galaxy_bluetooth/ios/GalaxyBluetooth/CompanionDiagnostics.swift +++ b/tools/galaxy_bluetooth/ios/GalaxyBluetooth/CompanionDiagnostics.swift @@ -24,6 +24,9 @@ struct CaptureStatus: Codable { let queuedImages: Int? let captureError: String? let encoderError: String? + let encoderStderr: String? + let encoderExitCode: Int? + let videoSize: [Int]? let encoderRunning: Bool? } diff --git a/tools/galaxy_bluetooth/ios/GalaxyBluetooth/PrivateLANHTTP.swift b/tools/galaxy_bluetooth/ios/GalaxyBluetooth/PrivateLANHTTP.swift index 85a31b6d46..4b7f95b1e9 100644 --- a/tools/galaxy_bluetooth/ios/GalaxyBluetooth/PrivateLANHTTP.swift +++ b/tools/galaxy_bluetooth/ios/GalaxyBluetooth/PrivateLANHTTP.swift @@ -59,7 +59,7 @@ final class PrivateLANHTTP { let target = components.percentEncodedPath + (components.percentEncodedQuery.map { "?" + $0 } ?? "") let body = request.httpBody ?? Data() var text = "\(request.httpMethod ?? "GET") \(target) HTTP/1.1\r\nHost: \(url.host!):8082\r\nConnection: close\r\nAccept-Encoding: identity\r\nContent-Length: \(body.count)\r\n" - for (name, value) in request.allHTTPHeaderFields ?? [:] where ["content-type", "accept", "cookie", "range"].contains(name.lowercased()) { + for (name, value) in request.allHTTPHeaderFields ?? [:] where ["content-type", "accept", "cookie", "range", "x-companion-nonce", "x-companion-mac"].contains(name.lowercased()) { guard !value.contains("\r"), !value.contains("\n") else { finish(.failure(BridgeError.message("Invalid request header."))); return } text += "\(name): \(value)\r\n" } diff --git a/tools/galaxy_bluetooth/tests/test_companion.py b/tools/galaxy_bluetooth/tests/test_companion.py index 3a9763d41f..ceb2b26684 100644 --- a/tools/galaxy_bluetooth/tests/test_companion.py +++ b/tools/galaxy_bluetooth/tests/test_companion.py @@ -118,11 +118,11 @@ class CompanionTests(unittest.TestCase): process = types.SimpleNamespace(stderr=io.BytesIO(b'encoder unavailable\n' + b'x' * 1000 + b'\n')) publisher.process = process publisher.read_encoder_errors(process) - self.assertEqual(publisher.encoder_error, 'x' * 500) + self.assertEqual(publisher.encoder_stderr, 'x' * 500) publisher.process = None process.stderr = io.BytesIO(b'old encoder error\n') publisher.read_encoder_errors(process) - self.assertEqual(publisher.encoder_error, 'x' * 500) + self.assertEqual(publisher.encoder_stderr, 'x' * 500) def test_capture_queue_is_bounded_and_preserves_aspect(self): companion.ENABLED.touch()