Skip to content

Commit

Permalink
#557 ZxingScannerComponent is not releasing all resources - BrowserCo…
Browse files Browse the repository at this point in the history
…deReader still trying to decode after ngDestroy
  • Loading branch information
werthdavid committed Apr 25, 2024
1 parent 31dca28 commit 9ba1adb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions projects/zxing-scanner/src/lib/zxing-scanner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,18 @@ export class ZXingScannerComponent implements OnInit, OnDestroy {
return;
}

this.scanStop();
try {
const videoElement = this.previewElemRef.nativeElement;
BrowserCodeReader.cleanVideoSource(videoElement);
} catch (err) {
}

try {
BrowserCodeReader.releaseAllStreams();
} catch (err) {
}

// clearing codeReader first to prevent setOptions error appearing in several Chromium versions
this._codeReader = undefined;

Expand Down

0 comments on commit 9ba1adb

Please sign in to comment.