Skip to content

ZxingScannerComponen.init method called twice when enable flag is set to true (leak once again) #559

@RafalOddslife

Description

@RafalOddslife

Hi, it's me again. I didn't notice this earlier. Issue which gives similar effect as #557 but now it's caused by [enable]="true" flag.

Describe the bug

ZxingScannerComponen.init method is called twice when enable flag is set to true which causes to run scanning twice (leak). onDestroy stops only one of scanning processes.
Affected version: "@zxing/ngx-scanner": "^17.0.2"

Code

<button (click)="scannerVisible = !scannerVisible">Toggle scanner</button>
<zxing-scanner [enable]="true" *ngIf="scannerVisible"></zxing-scanner>

To Reproduce

Steps to reproduce the behavior:

  1. Go to simple repro
  2. Use toggle button to init and destroy zxing-scanner component (the more you do this, the bigger the leakage)
  3. Each time scanner component is initialized it's calling 'init' method twice
  4. Open chrome devtools, open Performance tab and capture new recording
  5. BrowserCodeReader is still trying to decode even after destroying component

Expected behavior
Component should start only one scanning process.

Screenshots
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions