library icon indicating copy to clipboard operation
library copied to clipboard

BrowserMultiFormatReader.reader.reset() never called, leaving video resources to consume lots of power.

Open kodecharlie opened this issue 4 years ago • 2 comments

The problem is that an invocation of BrowserMultiFormatReader.reset() never results in a call to BrowserMultiFormatReader.reader.reset().

Here's the current snapshot of BrowserMultiFormatReader:

export class BrowserMultiFormatReader extends BrowserCodeReader {

  protected readonly reader: MultiFormatReader;

  public constructor(
    hints: Map<DecodeHintType, any> = null,
    timeBetweenScansMillis: number = 500
  ) {
    const reader = new MultiFormatReader();
    reader.setHints(hints);
    super(reader, timeBetweenScansMillis);
  }

  /**
   * Overwrite decodeBitmap to call decodeWithState, which will pay
   * attention to the hints set in the constructor function
   */
  public decodeBitmap(binaryBitmap: BinaryBitmap): Result {
    return this.reader.decodeWithState(binaryBitmap);
  }
}

To resolve, I propose overriding BrowserCodeReader.reset()inside BrowserMultiFormatReader like this:

// Overrides BrowserCodeReader
public reset(): void {
  super.reset();
  if (this.reader != null) {
    this.reader.reset();
  }
}

That way, we deactivate any state within the superclass as well as turning off resources allocated by the masked instance of MultiFormatReader.

kodecharlie avatar Oct 09 '21 12:10 kodecharlie

Stale issue message

github-actions[bot] avatar Apr 29 '24 12:04 github-actions[bot]