Skip to content

Commit

Permalink
remove restriction on running parallel decodeSingle
Browse files Browse the repository at this point in the history
- surprisingly, this seems to work
  • Loading branch information
ericblade committed Apr 16, 2020
1 parent 2bfe9cf commit f66dec9
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/quagga.js
Expand Up @@ -7,7 +7,6 @@ import ImageDebug from './common/image_debug';
import ResultCollector from './analytics/result_collector';
import Config from './config/config';
import { merge } from 'lodash';
import * as QWorkers from './quagga/qworker.ts';

import Quagga from './quagga/quagga';

Expand Down Expand Up @@ -66,21 +65,6 @@ export default {
canvas: _context.canvasContainer,
decodeSingle: function (config, resultCallback) {
const quaggaInstance = new Quagga();
if (this.inDecodeSingle) {
// force multiple calls to decodeSingle to run in serial, because presently
// simultaneous running breaks things.
if (resultCallback) {
setTimeout(() => this.decodeSingle(config, resultCallback), 300);
} else {
return new Promise((resolve) => {
setTimeout(() => this.decodeSingle(config, (res) => {
resolve(res);
}, 300));
});
}
return null;
}
// this.inDecodeSingle = true;
config = merge({
inputStream: {
type: 'ImageStream',
Expand Down Expand Up @@ -108,7 +92,6 @@ export default {
try {
this.init(config, () => {
Events.once('processed', (result) => {
this.inDecodeSingle = false;
quaggaInstance.stop();
if (resultCallback) {
resultCallback.call(null, result);
Expand All @@ -118,7 +101,6 @@ export default {
quaggaInstance.start();
}, null, quaggaInstance);
} catch (err) {
this.inDecodeSingle = false;
reject(err);
}
});
Expand Down

0 comments on commit f66dec9

Please sign in to comment.