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.
This commit is contained in:
Prateek Sunal
2025-08-29 12:22:08 +00:00
parent 67d7f586b2
commit fd963a1c8e
2 changed files with 7 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -1135,6 +1135,7 @@ class VideoPreviewService {
computeController.requestCompute(
stream: true,
bypassInteractionCheck: true,
bypassMLWaiting: true,
);
}