Button Click Takes Long to Launch ZBar Scanner

Hey guys, could you please help m out. I’m currntly facing an issue where I have a button which a user click which launches the zbar scanner . it takes about 1.5 s for the scanner to launch after clicking the button. I’ve tried a lot of things suggested ranging from even adding crosswalk and adding tappable but nothing works, Here’s my code:

<div text-center class=“footer”>

<ion-row>

<button ion-button block outline round icon-start (click)=“addProduct()” style=“border-color:#5DA913;color:#5DA913;height: 50px;font-size:18px;”>

<ion-icon name=“md-qr-scanner”></ion-icon>

ADD PRODUCT

</button>

</ion-row>

</div>

Can you show the code in addProduct()?

Hi MattE

here’s my addProduct()

addProduct() {
this.scanItem();
}

scanItem() {
let options: ZBarOptions = {
text_title: “SCAN”,
text_instructions: “”,
drawSight: false,
flash: “off”
};

this.zbar
  .scan(options)
  .then(result => {
    console.log("scanned code", result); // Scanned code
    this.showLoading();
    this.getProductByCode(result);
  })
  .catch(error => {
    this.dismissLoading();
    console.log(error); // Error message
    if (error.toLowerCase() !== "cancelled") {
      let modal = this.modalCtrl.create(CustomModalPage, {
        buttonText: "OK",
        message: "Error occured while scanning",
        title: "SCAN UNSUCCESSFUL!"
      });
      modal.present();
    }
  });

}

This all looks pretty good.

The only issue I can think of is that the Zbar plugin isn’t really optimised to start quickly.
Maybe Zbar needs some time to start their stuff and that’s why it’s taking so long.

Do you notice any improvements when launching the scanner for a second time in the same session?

Ahh makes . Funny enough there’s no improvement even when launching it the second or third time around it still takes as long