Repository navigation
PTZ calibration failure during startup prevents the API from starting #24969
Replies: 2 comments
|
I can't confirm the internal startup-ordering behavior you describe or the proposed code changes from what's documented, so I can't validate or quote that implementation here. What is documented covers the configuration side:
For your Note that your setup uses a custom ONVIF proxy in front of a TAPO C210, which is outside what the autotracking documentation covers. For the startup-sequencing behavior and the per-camera exception isolation you're proposing, the right place is the project tracker: GitHub. I can give a general, non-documentation-based answer about the described failure path if you want it. 📚 Sources: Have another question? Just tag @inkeep. |
|
Please review our AI policy: https://github.com/blakeblackshear/frigate/blob/dev/AI_POLICY.md Calibration is not a background activity. Frigate's UI and API being unavailable during calibration is expected and noted in the docs: https://docs.frigate.video/configuration/autotracking#calibration The failure here was caused by your ONVIF proxy closing the connection without sending any response, which a real camera doesn't do. A camera that can't complete a move returns a proper ONVIF error instead. Also, since your |
Uh oh!
There was an error while loading. Please reload this page.
Checklist
Describe the problem you are having
When a PTZ camera has
onvif.autotracking.calibrate_on_startup: true, an ONVIF error during startup calibration can abort Frigate startup before the API/auth server is available.In our case, a camera/proxy connection closed without returning an HTTP response during a PTZ operation. After the proxy was changed to return a valid SOAP 1.2 Fault for upstream failures, Frigate still needs to handle that ONVIF Fault without taking down the whole API.
Observed behavior
The exception propagates from
_autotracker_setup()throughfuture.result()inPtzAutoTracker.__init__().FrigateApp.start()invokesstart_ptz_autotracker()before initializing auth and starting the API server on127.0.0.1:5001.As a result, nginx cannot reach its
/authupstream and API requests return HTTP 500. The container healthcheck also fails.Expected behavior
A calibration failure for one camera should be logged and handled per camera—for example, by disabling autotracking for that camera—while allowing the rest of Frigate and its API to start.
Steps to reproduce
calibrate_on_startup: truefor one camera.The UI being temporarily unavailable during a successful calibration is documented behavior; the issue here is that a calibration error prevents API startup.
Version
0.18.2-cfa08c5
In which browser(s) are you experiencing the issue with?
No response
Frigate config file
docker-compose file or Docker CLI command
Relevant Frigate log output
Relevant go2rtc log output
Operating system
Proxmox
Install method
Docker Compose
Network connection
Wired
Camera make and model
TAPO C210 + custom ONVIF Proxy
Screenshots of the Frigate UI's System metrics pages
Any other information that may be helpful
Technical analysis and proposed change
In Frigate v0.18.2,
PtzAutoTrackerThread.__init__()constructsPtzAutoTrackersynchronously. DuringPtzAutoTracker.__init__(), setup for each enabled camera is submitted to the ONVIF event loop, thenfuture.result()waits for it to finish. If ONVIF setup or startup calibration raises an exception, it escapes the constructor.FrigateApp.start()callsstart_ptz_autotracker()beforeinit_auth()and beforeuvicorn.run()starts the API server, so a camera-specific error can abort application startup.References:
PtzAutoTrackerThreadandPtzAutoTracker.__init__(), startup ordering inapp.py.The exception path is in
[_autotracker_setup()](https://github.com/blakeblackshear/frigate/blob/v0.18.2/frigate/ptz/autotrack.py#L2650-L2834): whencalibrate_on_startupis enabled, it awaits[_calibrate_camera()](https://github.com/blakeblackshear/frigate/blob/v0.18.2/frigate/ptz/autotrack.py#L2861). That function performs ONVIF operations while the camera is marked as calibrating. A SOAP Fault, malformed SOAP response, or transport exception can propagate through the setup future.References:
_autotracker_setup(),_calibrate_camera().Proposed implementation
Make setup asynchronous from the application’s perspective and handle failures per camera:
The completion handler should consume the future’s exception, log the traceback with the camera name, and disable autotracking for that camera without stopping Frigate or other cameras:
The calibration routine should reset transient state in a
finallyblock so a failed attempt cannot leave the camera marked as calibrating. This is illustrative pseudocode; the cleanup should fit the existing calibration implementation:Setup should be marked complete only after success. On failure, the camera should remain explicitly disabled or in an error state, and calibration coefficients should only be saved after a complete successful calibration.
The same per-camera exception isolation could also be applied to the maintenance loop, which waits on a future for each camera. That would keep a runtime ONVIF exception from stopping maintenance for all cameras (
[PtzAutoTrackerThread.run()](https://github.com/blakeblackshear/frigate/blob/v0.18.2/frigate/ptz/autotrack.py#L2479-L2513)).Expected behavior
If startup calibration fails for one camera, Frigate should log the exception and disable autotracking for that camera while continuing API startup and initializing other cameras. Frigate may retry later with bounded backoff, but the retry should not block startup.
Suggested regression coverage
Simulate a SOAP Fault and a transport disconnect during
_calibrate_camera(). Verify that the API starts, the failed camera’s autotracking is disabled, other cameras initialize, and the failed camera’scalibratingstate is cleared.All reactions