question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoid setting a device during auto-start.

See original GitHub issue

Describe the bug When using the camera, I get an error saying: ‘Avoid setting a device during auto-start.’

To Reproduce Steps to reproduce the behavior:

  1. Open a page using the camera and the <zxing-scanner> tag.

Expected behavior The feedback of the camera should appear

Desktop (please complete the following information):

  • OS: MacOs Cataline 10.15.5
  • Browser Chrome
  • Version 84.0.4147.135

Additional context According to source code, we are setting the device during auto start:

private autostartScanner(devices: MediaDeviceInfo[]) {

    const matcher = ({ label }) => /back|trás|rear|traseira|environment|ambiente/gi.test(label);

    // select the rear camera by default, otherwise take the last camera.
    const device = devices.find(matcher) || devices.pop();

    if (!device) {
      throw new Error('Impossible to autostart, no input devices available.');
    }

    this.device = device; // HERE!
    // @note when listening to this change, callback code will sometimes run before the previous line.
    this.deviceChange.emit(device);

    this.isAutostarting = false;
    this.autostarted.next();
  }

IMPORTANT: This might help you debug my issue: I had ^3.0.0 as a package dependency. while facing the issue I was on v 3.0.1 with your latest commit. Fixing version to 3.0.0 solved my issue.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
coffeymattcommented, Sep 30, 2020

I’ve got this working via

html:

<zxing-scanner
          #webScanner
          *ngIf="scanning"
          [(device)]="currentDevice"
          (camerasFound)="onCamerasFound($event)"
          (scanSuccess)="webScanFoundItem($event)"
          [tryHarder]="true">        
        </zxing-scanner>

and in the ts code

  availableDevices: MediaDeviceInfo[];
  currentDevice: MediaDeviceInfo = null;

  onCamerasFound(devices: MediaDeviceInfo[]): void {
    this.availableDevices = devices;

    if (this.availableDevices && this.availableDevices.length > 0) {
      this.currentDevice = this.availableDevices[0];
    }
  }
2reactions
r3plicacommented, Apr 1, 2021

If you set the autostart="false" how do you start once you have set the device? All I get is this warning:

Feature ‘autostart’ disabled. Permissions and devices recovery has to be run manually.

The permissions have been requested and accepted, what is devices recorvery?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent programs from starting automatically in Windows - IU KB
Some startup items have no shortcut in the Startup folder. You can disable these with either the Startup apps/tasks tool in Settings or...
Read more >
How to Enable and Disable Android Auto-start App in Android ...
Method 1: Turning off the doze feature · Go to settings and then Battery. · On the upper right-hand corner, tap on three...
Read more >
Basic Computer Skills: Disable Applications from Running on ...
Disabling certain applications on startup is possible. Learn how to disable apps on startup in this free lesson.
Read more >
Device Manager automatically opens on startup
NOTE: to do this, you must be logged in as an Admin user. A standard user does not have the necessary privileges to...
Read more >
How to Stop Windows Apps From Launching at Startup - PCMag
Disable Startup Apps in Windows Settings ... Go to Settings > Apps > Startup to view a list of all apps that can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found