Code Monkey home page Code Monkey logo

Comments (8)

werthdavid avatar werthdavid commented on August 10, 2024 1

the fix is indeed not addressing the root of the problem. with my upcoming vacation I'm not sure when I will find time to look deeper into it that's why I keep the issue open.

from ngx-scanner.

werthdavid avatar werthdavid commented on August 10, 2024

Is this still the case with the version from today? From looking at the code this should be resolved via #557

from ngx-scanner.

RafalOddslife avatar RafalOddslife commented on August 10, 2024

Is this still the case with the version from today?

Yes, your PR fixed problem with disposing scanning process on component destroy.

This issue is caused by initializing scanning process twice when enable input is set to true. Stackblitz repro is based on the newest version 17.0.2

from ngx-scanner.

werthdavid avatar werthdavid commented on August 10, 2024

Damnit, as setting enable to false calls the reset method I was hoping this would be resolved. I'll take a look then. Thanks

from ngx-scanner.

RafalOddslife avatar RafalOddslife commented on August 10, 2024

If you setup breakpoint in ZXingScannerComponent.scanFromDevice you'll see it's called twice on component creation and this._scanSubscription is overwritten.

from ngx-scanner.

werthdavid avatar werthdavid commented on August 10, 2024

Good point! Thank you

from ngx-scanner.

werthdavid avatar werthdavid commented on August 10, 2024

plz test 17.0.3

from ngx-scanner.

RafalOddslife avatar RafalOddslife commented on August 10, 2024

I'm afraid it solves my repro but the root of the problem is more complicated

IMO these leaks are caused by:

  • calling async methods from sync context (ngOnInit and enable setter)
  • parent component/template can toggle enable flag many times which leads to multiple ZxingScannerComponent.init calls without clearing previously created scanning processes

Simple example:

<button (click)="scannerEnable = !scannerEnable">Toggle scanner enable</button>
<zxing-scanner [enable]="scannerEnable"></zxing-scanner>

it causes leak when you toggle enable flag few times quickly

from ngx-scanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.