Guard lookups when adding/deleting cameras at runtime (#23994)

* Guard object processor queue handlers against unknown cameras

* Skip embeddings post processing for removed cameras

* End review segments for removed cameras

* Drop queued autotracker moves for removed cameras

* Release tracked event thumbnails when skipping a removed camera

* Add locked accessors for camera states

* Read camera states through the processor accessors

* Guard output and recording paths against cameras not yet known

* Resolve camera state once in ONVIF, notification, and transcription paths
This commit is contained in:
Josh Hawkins
2026-09-12 07:30:04 -06:00
committed by Nicolas Mowen
parent d6a18e79aa
commit d78f6a7a98
16 changed files with 463 additions and 128 deletions
+9 -5
View File
@@ -747,25 +747,29 @@ class BirdsEyeFrameManager:
return False, False
force_update = False
camera_state = self.cameras.get(camera)
if camera_state is None:
return False, False
# disabling birdseye is a little tricky
if not camera_config.birdseye.enabled or not camera_config.enabled:
# if we've rendered a frame (we have a value for last_active_frame)
# then we need to set it to zero
if self.cameras[camera]["last_active_frame"] > 0:
self.cameras[camera]["last_active_frame"] = 0
if camera_state["last_active_frame"] > 0:
camera_state["last_active_frame"] = 0
force_update = True
else:
return False, False
# update the last active frame for the camera
self.cameras[camera]["current_frame"] = frame.copy()
self.cameras[camera]["current_frame_time"] = frame_time
camera_state["current_frame"] = frame.copy()
camera_state["current_frame_time"] = frame_time
if self.camera_active(
camera_config.birdseye.mode,
activity,
):
self.cameras[camera]["last_active_frame"] = frame_time
camera_state["last_active_frame"] = frame_time
now = datetime.datetime.now().timestamp()
+12 -7
View File
@@ -51,8 +51,12 @@ def check_disabled_camera_update(
for camera, last_update in write_times.items():
offline_time = now - last_update
camera_config = config.cameras.get(camera)
if config.cameras[camera].enabled:
if camera_config is None:
continue
if camera_config.enabled:
has_enabled_camera = True
else:
# flag camera as offline when it is disabled
@@ -62,8 +66,8 @@ def check_disabled_camera_update(
# last camera update was more than 1 second ago
# need to send empty data to birdseye because current
# frame is now out of date
cam_width = config.cameras[camera].detect.width
cam_height = config.cameras[camera].detect.height
cam_width = camera_config.detect.width
cam_height = camera_config.detect.height
if cam_width is None or cam_height is None:
raise ValueError(f"Camera {camera} detect dimensions not configured")
@@ -309,10 +313,11 @@ class OutputProcess(FrigateProcess):
regions,
) = data
frame = frame_manager.get(
frame_name, self.config.cameras[camera].frame_shape_yuv
)
frame_manager.close(frame_name)
camera_config = self.config.cameras.get(camera)
if camera_config is not None:
frame_manager.get(frame_name, camera_config.frame_shape_yuv)
frame_manager.close(frame_name)
detection_subscriber.stop()