From fd963a1c8ecd6da369df3e5fb913caa5a0e5dc0d Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Fri, 29 Aug 2025 12:22:08 +0000 Subject: [PATCH] fix: allow manual video stream creation when ML is waiting When ML is enabled but not running, the compute controller blocks all stream requests due to _waitingToRunML flag. This prevents users from manually creating video streams even though ML isn't actively using resources. Add bypassMLWaiting parameter to allow manual stream creation to proceed regardless of ML waiting state, improving UX. --- .../services/machine_learning/compute_controller.dart | 11 ++++++----- .../photos/lib/services/video_preview_service.dart | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart index 32ff15e352..23e36d6730 100644 --- a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart +++ b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart @@ -74,9 +74,10 @@ class ComputeController { bool ml = false, bool stream = false, bool bypassInteractionCheck = false, + bool bypassMLWaiting = false, }) { _logger.info( - "Requesting compute: ml: $ml, stream: $stream, bypassInteraction: $bypassInteractionCheck", + "Requesting compute: ml: $ml, stream: $stream, bypassInteraction: $bypassInteractionCheck, bypassMLWaiting: $bypassMLWaiting", ); if (!_isDeviceHealthy) { _logger.info("Device not healthy, denying request."); @@ -90,7 +91,7 @@ class ComputeController { if (ml) { result = _requestML(); } else if (stream) { - result = _requestStream(); + result = _requestStream(bypassMLWaiting); } else { _logger.severe("No compute request specified, denying request."); } @@ -117,14 +118,14 @@ class ComputeController { return false; } - bool _requestStream() { - if (_currentRunState == ComputeRunState.idle && !_waitingToRunML) { + bool _requestStream([bool bypassMLWaiting = false]) { + if (_currentRunState == ComputeRunState.idle && (bypassMLWaiting || !_waitingToRunML)) { _logger.info("Stream request granted"); _currentRunState = ComputeRunState.generatingStream; return true; } _logger.info( - "Stream request denied, current state: $_currentRunState, wants to run ML: $_waitingToRunML", + "Stream request denied, current state: $_currentRunState, wants to run ML: $_waitingToRunML, bypassMLWaiting: $bypassMLWaiting", ); return false; } diff --git a/mobile/apps/photos/lib/services/video_preview_service.dart b/mobile/apps/photos/lib/services/video_preview_service.dart index dc46e3db57..b8dfec235a 100644 --- a/mobile/apps/photos/lib/services/video_preview_service.dart +++ b/mobile/apps/photos/lib/services/video_preview_service.dart @@ -1135,6 +1135,7 @@ class VideoPreviewService { computeController.requestCompute( stream: true, bypassInteractionCheck: true, + bypassMLWaiting: true, ); }