Refactor barcode scanner; fix detection not resuming after pause#870
Open
Vetle444 wants to merge 5 commits into
Open
Refactor barcode scanner; fix detection not resuming after pause#870Vetle444 wants to merge 5 commits into
Vetle444 wants to merge 5 commits into
Conversation
- Document the barcode scanner refactor, the breaking Strategy API change, and the removal of CameraPreview.IsInFullscreen - Add a playground entry that opens BarcodeScanResumeRepro inside a modal to verify the pause/resume fix across navigation hosts Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Move barcode confirmation logic into IBarcodeConfirmationHandler with TimerBarcodeConfirmationHandler and OverlayBarcodeConfirmationHandler. The scanner dispatches polymorphically — no if/else or type-check fallback in InvokeBarcodeFound. Remove internal-only refactoring entry from changelog.
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the BarcodeScanner session lifecycle and detection/confirmation pipeline to fix the issue where scanning could fail to resume after a pause/resume cycle. The PR also introduces a new strategy-based configuration API (breaking change) and removes CameraPreview.IsInFullscreen (breaking change) while updating samples and wiki documentation accordingly.
Changes:
- Fixes resume reliability by making the scanner session lifecycle cancellation-token based and by capturing
scanRunIdper detection on iOS. - Replaces
BarcodeScannerStartOptions.ScanRectangle+BarcodeDetectionTimewithBarcodeScannerStartOptions.Strategy : BarcodeScanStrategy, splitting confirmation logic into strategy-specific handlers. - Adds scan-count progress/completion support (progress counter + completion callback) and updates docs/samples; removes unused Android implementation files.
Reviewed changes
Copilot reviewed 30 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
wiki/Media/Camera.md |
Updates documentation to use Strategy instead of ScanRectangle. |
src/library/DIPS.Mobile.UI/API/Camera/Preview/CameraPreview.Properties.cs |
Removes IsInFullscreen property (breaking change). |
src/library/DIPS.Mobile.UI/API/Camera/Preview/CameraPreview.cs |
Always applies iOS safe-area padding (no fullscreen toggle). |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/TimerBarcodeConfirmationHandler.cs |
Adds timer-based confirmation handler for TimerBarcodeScanStrategy. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Progress/BarcodeScanProgressView.cs |
Adds progress counter UI and animations. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Progress/BarcodeScanProgressController.cs |
Controls showing/updating/removing the progress counter view. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Progress/BarcodeScanProgress.cs |
Introduces progress state for required scan count. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Progress/BarcodeScanCompletionOptions.cs |
Public options for required count + completion callback. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/OverlayBarcodeConfirmationHandler.cs |
Adds overlay-based confirmation handler for rectangle strategy. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Overlay/BarcodeScanResultView.xaml.cs |
Adds result view code-behind + bindable property. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Overlay/BarcodeScanResultView.xaml |
Adds result view UI for debugging scan results/observations. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Overlay/BarcodeScanRectangleOverlay.cs |
Makes overlay animation timings configurable; refactors animation keys and dimming behavior. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/iOS/BarcodeScanner.cs |
Adjusts iOS detection callback to capture scanRunId per detection; strategy-based rect-of-interest config. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/IBarcodeConfirmationHandler.cs |
Introduces interface for strategy-specific confirmation logic. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Detection/BarcodeScanValidationResult.cs |
Adds structured validation result (valid/invalid + error/reason/state). |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Detection/BarcodeScanResult.cs |
Updates scan result model + docs; carries validation result/state. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Detection/BarcodeObservation.cs |
Adds observation model for detected barcodes + detection counts. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Detection/BarcodeDetectionAggregator.cs |
Extracts detection aggregation into a dedicated class. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Detection/Barcode.cs |
Introduces barcode value model (raw value + format). |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/BarcodeScanStrategy.cs |
Adds new strategy API (TimerBarcodeScanStrategy, ScanRectangleBarcodeScanStrategy). |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/BarcodeScanRectangleOptions.cs |
Removes old ScanRectangle options type (breaking change). |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/BarcodeScannerStartOptions.cs |
Replaces rectangle/time properties with Strategy (breaking change). |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/BarcodeScanner.cs |
Refactors session lifecycle, detection pipeline, cooldown, and confirmation dispatch; adds CTS-based session cancellation. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Android/QrCodeDrawable.cs |
Removes unused Android drawable. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Android/CaptureStateCallback.cs |
Removes unused Android camera callback wrapper. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Android/CaptureSessionCallBack.cs |
Removes unused Android capture callback/state machine. |
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Android/BarcodeScanner.cs |
Updates Android scan-rectangle filtering to use new strategy API. |
src/app/Playground/MainPage.xaml.cs |
Adds navigation actions for resume repro sample pages. |
src/app/Playground/MainPage.xaml |
Adds UI entries to launch resume repro sample pages. |
src/app/Playground/EirikSamples/BarcodeScanResumeRepro.xaml.cs |
Adds repro page code-behind to exercise pause/resume behavior. |
src/app/Playground/EirikSamples/BarcodeScanResumeRepro.xaml |
Adds repro page UI hosting a CameraPreview. |
src/app/Components/ComponentsSamples/BarcodeScanning/BarcodeTooltipSample.xaml.cs |
Updates sample to use Strategy. |
src/app/Components/ComponentsSamples/BarcodeScanning/BarcodeTooltipSample.xaml |
Removes IsInFullscreen usage in sample. |
src/app/Components/ComponentsSamples/BarcodeScanning/BarcodeScanningSample.xaml |
Removes IsInFullscreen usage in sample. |
src/app/Components/ComponentsSamples/BarcodeScanning/BarcodeOverlaySample.xaml.cs |
Updates overlay sample to use Strategy. |
src/app/Components/ComponentsSamples/BarcodeScanning/BarcodeOverlaySample.xaml |
Removes IsInFullscreen usage in sample. |
src/app/Components/ComponentsSamples/BarcodeScanning/BarcodeCounterSample.xaml.cs |
Updates counter sample to use Strategy. |
src/app/Components/ComponentsSamples/BarcodeScanning/BarcodeCounterSample.xaml |
Removes IsInFullscreen usage in sample. |
CHANGELOG.md |
Adds 60.0.0 entry documenting bugfix + breaking changes; also includes formatting cleanup in older entries. |
Comments suppressed due to low confidence (1)
src/library/DIPS.Mobile.UI/API/Camera/BarcodeScanning/Overlay/BarcodeScanRectangleOverlay.cs:52
- The animation lengths are derived by casting
TimeSpan.TotalMillisecondsdirectly touint. If a consumer sets a negative duration (or a very large duration), this cast will underflow/overflow and produce an unintended animation length. Validate/clampbracketsTravelDurationandformingDuration(e.g.,<= 0→ 0/throw;> uint.MaxValue→ cap) before assigningm_bracketsTravelLength/m_formingLength.
VegardHV
reviewed
May 22, 2026
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.
Description of Change
Refactors the barcode scanner's session lifecycle, detection pipeline, and configuration API. Fixes the bug where detection no longer resumed after the result bottom sheet was dismissed (Arena.Mobile#1415).
Fix
CancellationTokenSourcereplaces the previousm_isDisposedchecks so a staleStartcallback can no longer leave the scanner in an inactive state.scanRunIdis captured per detection instead of per session, so the platform delegate no longer drops detections after a resume.Breaking changes
BarcodeScannerStartOptions:ScanRectangle(BarcodeScanRectangleOptions) andBarcodeDetectionTimeare replaced by a singleStrategyproperty of typeBarcodeScanStrategy:TimerBarcodeScanStrategy { DetectionTime }— timer-based confirmation, no overlay (default, 500 ms)ScanRectangleBarcodeScanStrategy { WidthFraction, HeightFraction, BracketsTravelDuration, FormingDuration }— animated scan rectangle overlayCameraPreview.IsInFullscreen: removed. The preview always applies safe-area padding on iOS.Migration
Refactor
IBarcodeConfirmationHandlerwithTimerBarcodeConfirmationHandlerandOverlayBarcodeConfirmationHandler. The scanner dispatches polymorphically via the handler — no if/else or type-check fallback inInvokeBarcodeFound.BarcodeDetectionAggregator.Detection/,Overlay/, andProgress/subfolders.IsSessionActive/CanResumeSessionhelpers.m_startOptionsfields from iOS and Android platform partials.CaptureSessionCallBack,CaptureStateCallback,QrCodeDrawable.Playground
BarcodeScanResumeRepropage reproducing the resume bug.Todos