Skip to content

Feature/perf capture recording optimizations - #134

Merged
dimitar-radenkov merged 18 commits into
masterfrom
feature/perf-capture-recording-optimizations
Jul 15, 2026
Merged

Feature/perf capture recording optimizations#134
dimitar-radenkov merged 18 commits into
masterfrom
feature/perf-capture-recording-optimizations

Conversation

@dimitar-radenkov

Copy link
Copy Markdown
Owner

No description provided.

Implements a Capture Library feature with:
- `CaptureLibraryService` and `ICaptureLibraryService` for managing and searching captures by file name or OCR text, with date filtering and progress reporting.
- `CaptureTextIndex` and `ICaptureTextIndex` for OCR text extraction and LRU caching.
- `LibraryViewModel` for MVVM state, search/filter logic, and commands.
- New `LibraryWindow` (XAML/UI) for browsing, searching, and opening captures.
- Tray menu integration, DI registration, and automation launch support.
- `CaptureItem` and `CaptureSearchProgress` records for modeling.
- `IOcrService` and `WindowsOcrService` updated for cancellation support.
- Comprehensive unit tests for all new components.
- Add IDebounceService with async debounce implementation and DI registration
- Debounce LibraryViewModel search input for better UX
- Add date range presets and sync logic to LibraryViewModel
- Optimize CaptureLibraryService to skip OCR for short queries
- Centralize shared UI styles in Controls.xaml
- Refactor Library and Settings windows to use shared styles
- Improve Library filter bar with range presets and layout tweaks
Replaced MouseBinding for LeftDoubleClick with a MouseDoubleClick event handler in LibraryWindow.xaml. The new handler sets SelectedItem and invokes OpenCommand when a capture is double-clicked. Added FindAncestor<T> helper to locate the ListBoxItem in the visual tree.
Replaces `CaptureTextIndex`/`ICaptureTextIndex` with `CaptureTextLookupService`/`ICaptureTextLookupService` throughout the codebase. The new service uses `IServiceScopeFactory` for proper DbContext lifetime management. Updates all DI registrations and usages. Migrates and renames all related tests. Adds `SQLitePCLRaw.bundle_e_sqlite3` to support SQLite.
LibraryViewModel now tracks search telemetry events ("started", "completed", "short_query", "cancelled") with relevant properties via ITelemetryService. Constructors updated to accept an ITelemetryService, with NullTelemetryService as default. Improved cancellation logic for Refresh command. Added unit tests for telemetry. CaptureTextLookupService now only updates LastAccessedAt if 10+ minutes have passed.
# Conflicts:
#	Pointframe.Tests/Services/CaptureLibraryOcrSearchTests.cs
#	Pointframe/Services/Capture/CaptureLibraryService.cs
Copilot AI review requested due to automatic review settings July 14, 2026 04:46

Copilot AI left a comment

Copy link
Copy Markdown

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 focuses on reducing hot-path allocations and improving responsiveness in two performance-sensitive areas of Pointframe: screen recording frame capture and capture-library searching/previewing.

Changes:

  • Reuse capture resources during recording sessions (e.g., screen DC) and avoid extra buffer copies for stop-time padding.
  • Refactor capture library enumeration into a shared helper and introduce file-system pattern prefiltering for faster searches, with results explicitly sorted newest-first for OCR searches.
  • Reduce per-call allocations in the annotation color picker by reusing a scratch pixel buffer.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Pointframe/Services/Recording/ScreenRecordingService.cs Reuses screen DC and avoids redundant frame buffer copying during stop-time padding.
Pointframe/Services/Capture/CaptureLibraryService.cs Refactors and optimizes capture enumeration/search (including optional filename search patterns) and enforces newest-first sorting for OCR results.
Pointframe/Services/Annotation/AnnotationCanvasRenderer.cs Removes per-sample allocation by reusing a 4-byte scratch buffer for pixel sampling.
Pointframe.Tests/Services/CaptureLibraryOcrSearchTests.cs Adds coverage ensuring OCR search results are sorted newest-first for long queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Pointframe/Services/Capture/CaptureLibraryService.cs
Comment thread Pointframe/Services/Recording/ScreenRecordingService.cs Outdated
…alidate file search patterns in CaptureLibraryService

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment on lines +145 to +167
_cts = new CancellationTokenSource();
IsRecording = true;
_captureLoop = Task.Run(() => CaptureLoop(_cts.Token));
_encodeLoop = Task.Run(EncodeLoop);
_logger.LogInformation("Recording started: {W}x{H} @ {Fps}fps (MP4) → {Path}", width, height, fps, outputPath);
}
catch
{
_screenDc?.Dispose();
_screenDc = null;
_captureGraphics?.Dispose();
_captureGraphics = null;
_captureBitmap?.Dispose();
_captureBitmap = null;
_writer?.Dispose();
_writer = null;
_captureLoop = null;
_encodeLoop = null;
_encodeChannel = null;
_cts?.Dispose();
_cts = null;
throw;
}
Comment thread Pointframe/Services/Recording/ScreenRecordingService.cs Outdated
Comment on lines 491 to 499
_logger.LogInformation("Padding recording with {FrameCount} duplicate frames to match elapsed duration", framesToPad);

for (var index = 0; index < framesToPad; index++)
{
var frameCopy = new byte[paddingSource.Length];
Buffer.BlockCopy(paddingSource, 0, frameCopy, 0, frameCopy.Length);
Interlocked.Increment(ref _attemptedFrameCount);
try
{
_writer?.WriteFrame(frameCopy);
_writer?.WriteFrame(paddingSource);
}
@dimitar-radenkov

Copy link
Copy Markdown
Owner Author

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review thread.

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change...

Addressed in e4449d7.

@dimitar-radenkov
dimitar-radenkov merged commit f333fc0 into master Jul 15, 2026
5 checks passed
@dimitar-radenkov
dimitar-radenkov deleted the feature/perf-capture-recording-optimizations branch July 15, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants