Skip to content

Commit

Permalink
Merge pull request #558 from zxing-js/bugfix/557-leak
Browse files Browse the repository at this point in the history
#557 ZxingScannerComponent is not releasing all resources - BrowserCo…
  • Loading branch information
werthdavid authored Apr 25, 2024
2 parents 31dca28 + 9ba1adb commit e2d0e4d
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 e2d0e4d

Please sign in to comment.