Fix DAP sample async and event-handling robustness issues#196
Open
alafleur-genetec wants to merge 1 commit into
Open
Fix DAP sample async and event-handling robustness issues#196alafleur-genetec wants to merge 1 commit into
alafleur-genetec wants to merge 1 commit into
Conversation
Fix batching, event completion, entity loading, timeline query failure handling, and file dialog filtering across DAP samples.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the correctness and robustness of multiple DAP/SDK samples by fixing an async buffering bug, hardening event-driven TaskCompletionSource patterns against race conditions, and addressing a few sample-specific reliability issues (entity loading, logging on failure, and a file dialog filter typo).
Changes:
- Fix
AsyncEnumerableExtensions.Buffer<T>batching to avoid silently skipping records, and simplify report handler batching to consume materialized batches. - Harden event-driven sample flows by using
TrySet*+RunContinuationsAsynchronously, adding cancellation support for overlay readiness waits, and ensuring event handlers are unsubscribed symmetrically. - Improve sample behavior in edge cases (load
Doorentities explicitly, log and signal completion on timeline report query failures, and correct the MediaPlayer.g64xfile filter).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Samples/Workspace SDK/TimelineProviderSample/AlarmTimelineProvider.cs | Adds logging + try/catch/finally around fire-and-forget queries and ensures OnQueryCompleted() is always called; makes event removal safe via .ToList(). |
| Samples/Workspace SDK/TimelineProviderSample/AccessControlTimelineProvider.cs | Same robustness pattern as alarm provider: logs failures and always completes queries. |
| Samples/Plugin SDK/CustomReportSample/Server/ReportHandlers/ReportHandler.cs | Switches buffered batches to IReadOnlyList<T> and makes ProcessBatch synchronous to match materialized buffering. |
| Samples/Plugin SDK/CustomReportSample/Server/ReportHandlers/AuditTrailsReportHandler.cs | Updates override to match new ProcessBatch signature and batch type. |
| Samples/Plugin SDK/CustomReportSample/Server/ReportHandlers/ActivityTrailsReportHandler.cs | Updates override to match new ProcessBatch signature and batch type. |
| Samples/Plugin SDK/CustomReportSample/AsyncEnumerableExtensions.cs | Replaces the previous nested-iterator buffering (which dropped records) with a straightforward materialized batching implementation. |
| Samples/Platform SDK/VideoUnitSample/VideoUnitSample.cs | Makes enrollment completion safer (TrySet*, async continuations) and adds basic event correlation to avoid completing from unrelated enrollments. |
| Samples/Platform SDK/AccessVerifierSample/AccessVerifierSample.cs | Ensures doors are loaded before querying and provides a clear message/early return when none are found. |
| Samples/Media SDK/VideoSourceFilterSample/VideoSourceFilterSample.cs | Prevents exceptions on SDK threads by using TrySetException, returning after failure, and unsubscribing both event handlers. |
| Samples/Media SDK/OverlaySample/OverlaySample.cs | Passes the sample cancellation token through overlay initialization to avoid indefinite waits. |
| Samples/Media SDK/OverlaySample/OverlayExtensions.cs | Adds cancellation support and avoids repeated-event crashes via TrySetResult + RunContinuationsAsynchronously. |
| Samples/Media SDK/MediaPlayerSample/MediaPlayerSample.cs | Fixes the open-file dialog filter so *.g64x files match correctly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
AsyncEnumerableExtensions.Buffer<T>so consecutive batches do not skip records.TaskCompletionSourceusage in video unit, overlay, and video source filter samples.AccessVerifierSamplebefore querying access results..g64xopen-file dialog filter.