Skip to content

Fix DAP sample async and event-handling robustness issues#196

Open
alafleur-genetec wants to merge 1 commit into
mainfrom
fix/sample-robustness-issues-189-195
Open

Fix DAP sample async and event-handling robustness issues#196
alafleur-genetec wants to merge 1 commit into
mainfrom
fix/sample-robustness-issues-189-195

Conversation

@alafleur-genetec

@alafleur-genetec alafleur-genetec commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix AsyncEnumerableExtensions.Buffer<T> so consecutive batches do not skip records.
  • Harden event-driven TaskCompletionSource usage in video unit, overlay, and video source filter samples.
  • Load doors explicitly in AccessVerifierSample before querying access results.
  • Log and complete fire-and-forget timeline report queries on failure.
  • Fix the MediaPlayerSample .g64x open-file dialog filter.

Fix batching, event completion, entity loading, timeline query failure handling, and file dialog filtering across DAP samples.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Door entities explicitly, log and signal completion on timeline report query failures, and correct the MediaPlayer .g64x file 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants