Fix HLS cleanup, investigation playback, backup I/O, and ONVIF handling - #606
Open
matteius wants to merge 6 commits into
Open
Fix HLS cleanup, investigation playback, backup I/O, and ONVIF handling#606matteius wants to merge 6 commits into
matteius wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
HLS teardown still accesses potentially freed context memory, and the HLS test fixture does not clean up the global shutdown coordinator.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes HLS cleanup, investigation playback synchronization, backup verification behavior, and ONVIF subscription handling.
Changes:
- Updates HLS lifecycle cleanup and FFmpeg metadata ownership.
- Synchronizes investigation playback controls and validates pre-buffering.
- Improves backup scheduling/cache handling and ONVIF parsing diagnostics.
File summaries
| File | Description |
|---|---|
web/js/components/preact/investigation/InvestigationView.jsx |
Synchronizes native playback controls. |
tests/unit/test_hls_cleanup.c |
Adds concurrent HLS lifecycle coverage. |
tests/unit/test_detection_system_onvif.c |
Adds ONVIF regression tests. |
tests/unit/CMakeLists.txt |
Registers HLS cleanup tests. |
tests/integration/synthetic-onvif-prebuffer.py |
Adds repeatable pre-buffer validation. |
tests/integration/specs/investigation.ui.spec.ts |
Tests investigation playback synchronization. |
tests/database/db_backup_test.c |
Tests backup retry behavior. |
tests/database/benchmark_backup_verification.py |
Benchmarks verification I/O. |
src/video/onvif_detection.c |
Hardens ONVIF parsing and diagnostics. |
src/video/hls/hls_unified_thread.c |
Updates HLS lifecycle cleanup. |
src/video/hls_writer.c |
Removes alarm-based cleanup handling. |
src/video/ffmpeg_utils.c |
Preserves FFmpeg-owned metadata. |
src/database/db_core.c |
Adjusts backup scheduling and success tracking. |
src/database/db_backup.c |
Improves verification cache handling. |
src/core/main.c |
Updates shutdown signal handling. |
src/core/daemon.c |
Updates daemon signal handling comments. |
docs/internal/BACKLOG_RELIABILITY_2026-09-12.md |
Documents validation and findings. |
Review details
Suppressed comments (1)
tests/unit/test_hls_cleanup.c:85
setUpreinitializes the process-global shutdown coordinator for every test, buttearDownnever callsshutdown_coordinator_cleanup(). After the first test, the nextinit_shutdown_coordinator()overwrites live pthread mutex/condition-variable objects withmemset, which is undefined behavior and leaks their resources. Destroy the coordinator intearDownbefore the next test starts.
void tearDown(void) {
cleanup_all_hls_writers();
remove_test_files(test_dir);
}
- Files reviewed: 17/17 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| | Issue | Implemented or verified locally | Remaining evidence | | ||
| | --- | --- | --- | | ||
| | [#600](https://github.com/opensensor/lightNVR/issues/600) | Removed HLS `alarm()` calls and temporary SIGALRM/SIGSEGV dispositions; removed the freed-memory probe. Concurrent writer closure and full stream shutdown/restart pass. Fixed a codec metadata leak exposed by the lifecycle test. | The reported connection to a particular deadlock remains unproven. The system API suite completes. These tests do not establish freedom from every existing HLS context lifetime race. | |
Comment on lines
+229
to
230
| // Never probe memory through a pointer that may already have been freed. | ||
| return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HLS cleanup changes process-wide signal dispositions, native investigation play/pause leaves shared controls out of sync, and backup verification repeatedly evicts pages it needs to reread. This PR fixes those behaviors and hardens ONVIF subscription URL handling and empty-response diagnostics.
SubscriptionReference, support XML prefixes and escaped query strings, escapewsa:To, reject empty HTTP 200 responses, disable curl signal use, and log the action, curl/HTTP codes, and elapsed time.Validation: frontend production build; six targeted C suites (backup, ONVIF, packet buffer, HLS cleanup, MP4 timestamps, and system API); two investigation browser tests; and two existing sub-stream/fullscreen browser tests passed. Concurrent HLS shutdown/restart passed with AddressSanitizer and LeakSanitizer enabled. The synthetic ONVIF test produced a decodable 31.4-second MP4 containing red footage before the trigger and blue footage afterward, with approximately eight seconds of pre-buffer.
The repeatable 82 MB audit fixture read 178 MB with repeated eviction versus 82 MB without it; both integrity checks passed. Verification can use more reclaimable OS page cache until completion. This small local benchmark does not predict production backup duration.
Related: #600, #603, #580, #604, #568, #494, #579. The affected cameras are unavailable, so the Tapo report, camera-specific pre-buffer behavior, and connection instability remain unconfirmed. Persistent SQLite I/O errors still need the extended error code and remain separate from backup performance. The reported HLS deadlock did not reproduce. Existing main-stream reuse behavior was verified without changing stream selection.
Detailed results and reproduction commands: backlog reliability notes.