Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5 parallel use of decodeSingle, part of #105, restructuring #171

Merged
merged 9 commits into from May 1, 2020

Conversation

ericblade
Copy link
Owner

No description provided.

@ericblade
Copy link
Owner Author

@twsouthwick If you'd like to have a look at this, it seems to, rather surpisingly, fix parallel decode. I expected that we'd also have to do some work in barcode_decoder and/or barcode_locator, but this is giving me correct results with small tests run many times.

I'm feeling a bit hesitant to publish this, since it could break down in a lot of ways (especially barcode_decoder and locator modules) so if you have a use case that can put it through some stress, that'd be fantastic.

Copy link
Contributor

@twsouthwick twsouthwick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to mark the current start/stop/etc methods as deprecated (such as https://stackoverflow.com/questions/19412660/how-should-i-mark-a-method-as-obsolete-in-js).

Are you planning on bumping the major version? If so, it may be just considered a breaking change with details on updating. Not sure how the JS community tends to do this, though. Probably better to mark as deprecated and then remove at some point later.

QWorkers.registerReader(name, reader);
}
const instance = new Quagga();
const _context = instance.context;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to just access everything from instance itself - keeps it easier to reason about where the data is coming from.

Copy link
Owner Author

@ericblade ericblade Apr 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the only suggestion wrt to the change as is, then I feel pretty good about the change itself being good. I'll definitely take that into consideration.

@twsouthwick
Copy link
Contributor

I'm building a blazor component on top of this. I'll try it out.

@ericblade
Copy link
Owner Author

ericblade commented Apr 23, 2020

well, what i haven't done with this, is run it in LiveStream mode, which I think is much more likely where you'll find someone using start/stop. I don't think that's going to change much -- I don't see much use for start/stop for people who are using it to decode on command, but I don't think it should be deprecated, because it is used for LiveStream.

Typical initialization goes like

Quagga.init({ options }, (err) => { if(!err) Quagga.start() })

and then sometime after you'll be needing to use stop to turn it off.

... now, if there are people who are controlling the decoder manually, for some reason, rather than just using decodeSingle, then i might need to expose some way to create a new interface... because this doesn't currently allow you to create multiple Quaggas, it takes care of handling that internally.

also, yes, i do plan to bump major when i add this, initially, i didn't want to be on version 20.2.10 within a few weeks after i started my work on it :) but now that it's much slower, larger changes, and people are for sure using this now, i'm definitely going to bump major. If nothing else, simply because this is a bug fix that could have wide effects on people using it presently -- fixing decodeSingle to do what it should do, after a few years of it not being right, could really break some people's code.

ericblade and others added 8 commits April 27, 2020 16:19
Update snyk to the latest version 🚀
Update snyk to the latest version 🚀
… class

- after this commit, there should be no functional change, but the bulk
  of the code outside the static interface has been moved to a class,
  instead of global variables. An instance of that class is created at the
  top as a global.
- this appears to actually work correctly, all tests are passing
- move stop functionality into the instance
- init accepts an instance parameter to determine which instance to init
- update bound to instance
- add Quagga::setReaders and Quagga::registerReader
- setupInputStream defaults to LiveStream per the TypeScript def for
  inputStream config
- InputStreamType back to optional in input stream config
- surprisingly, this seems to work
@ericblade
Copy link
Owner Author

@twsouthwick and anyone else who might want to test this out .. i've just validated that LiveStream works on it after fixing a small error. Not sure if you're wanting to use that or not, but if anyone can validate that this doesn't break anything for them, I think I'm ready to go to 1.0 with it.

@rollingversions
Copy link

rollingversions bot commented May 1, 2020

Change Log for @ericblade/quagga2 (0.0.21 → 1.0.0)

Breaking Changes

  • Major restructuring, may cause breaking changes

  • Calls to decodeSingle no longer populate values inside the Quagga object

    • I have doubts that anyone is presently using both decodeSingle and start/stop interfaces intended for LiveStream in the same Quagga unit, but if you are -- this will be a functional change.
  • Parallel operation of multiple calls to decodeSingle works

    • In previous versions of quagga, calling decodeSingle several times would result in all callbacks being called with the first result that came back.
    • This has only been tested reasonably thoroughly in Node, not in Browser, so far.

Refactorings

  • Separate much of the global Quagga unit out to a separate class

    • Add src/quagga/quagga.ts
    • This was done to make it significantly easier to make parallel execution and allow for future refactor of multi-threaded execution
  • Minor cleanups to src/common/typedefs

Bug Fixes

  • Remove restriction on making parallel runs of decodeSingle

Edit changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants