Performance and Many warns "binarySearchThreshold option is deprecated since 1.1"

Tags: #<Tag:0x00007f8b1d91a2f8>

Hi :slight_smile: hope you’re fine.
I have a problem when using handsontable. I was working with

Angular 10.1
Handsontable 8.2.0
I used “formulas : true” in hotSettings.

I had a list of projects in the top of the page and when I selected a project, it created 5 handsontables. The first time everything worked well. But when I already had a selected project with the 5 tables and clicked in another project, the page always got frozen for about 3 to 4 seconds.

We thought the performance maybe will improve updating the versions, so update:

Angular 12.2.13
Handsontable: 11.0.1
Hyperformula: 1.3.0

And I changed formulas for
formulas: { engine: HyperFormula}

importing: import { HyperFormula } from ‘hyperformula’;

I have majority of hotSettings with:

  • readOnly
  • columnSorting
  • colHeaders
  • formulas
  • licenseKey
  • manualColumnsResize
  • comments
  • contextMenu
  • fixedColumnsLeft
  • afterGetColHeader
  • afterChange
  • cells
  • afterInit

And in the html

But it still freezing about 3-4 seconds. And now I’ve got a lot of warns:

What can I do to improve the performance and no warnings display?

Thank you so much for your help! :slight_smile:

Camila

Hi @camiilavillamizar

These warnings are mentioned here https://github.com/handsontable/handsontable/issues/8771
It is a regression from version 10.0.0 and it will be fixed soon.

When it comes to performance issues we would need some samples of your code.

Hi @aleksandra_budnik

This is one of the hotSettings:

/*********************

   * HOTSETTINGS TABLA 1

   *********************/

  hotSettings1: Handsontable.GridSettings = {

    formulas: true,

    rowHeights: 30,

    contextMenu: {items:{

      "Añadir Comentario":{

        name: 'Añadir Comentario',

        callback:(key, options) =>{

          let col = options[0].end.col;

          let row = options[0].end.row;

          this.hotRegisterer.getInstance(this.tableId1).getPlugin('comments').showAtCell(row, col);  

        },

        hidden: ()=>{

          // Se obtiene la fila y la columna que ha sido clickeada. (indice de estas)

          let row = this.hotRegisterer.getInstance(this.tableId1).getSelectedLast()[0];

          let col = this.hotRegisterer.getInstance(this.tableId1).getSelectedLast()[1];

          let listOfNumber: number[] = [];

          for(let i=0; i<this.limitOfHeaders; i++){

            listOfNumber.push(i);

          }

          if(listOfNumber.includes(col)||[0,8,7].includes(row) || this.rOnly){

            return true;

         

          }else{

            return false

          }

        }

      }

    }},

    manualColumnResize: true,

    comments: true,

    licenseKey: 'non-commercial-and-evaluation',

    fixedColumnsLeft: 7,      

    //Para asignar colores a los headers

    afterGetColHeader: (col, TH) => {

      this.colHeadersColor(col, TH)

    },

    //AFTERCHANGE Se activa cuando se realiza algún cambio a cualquier celda

    afterChange: (changes) => {

      this.afterChangeTable1(changes);

    },

    cells(row, column) {

     

      if (column != 0 && row != 8) {

        return {

          renderer(instance, td, row, col, prop, value, cellProperties) {

            Handsontable.renderers.TextRenderer.apply(this, arguments)

            if(td.className == "isDirty"){

              td.style.background = "#E2D6F3"

            }

            try {

              /**

               * Se convierte al formato de número para que las fórmulas

               * funcionen

               */

              td.className = "htRight"

              value = Number(value.toString().replace(",", ".")).toFixed(2)

              td.textContent = value.toString().replace(".", ",").replace(/\B(?=(\d{3})+(?!\d))/g, ".");

              if (row == 0) {

                td.style.backgroundColor = "#E2F6DA";

              }

              if (row == 7) {

                cellProperties.readOnly = true

                td.style.backgroundColor = "#FFE699"

                if (col == instance.countSourceCols() - 1 && value > 0) {

                  td.style.color = '#C74687'

                }

              }

              if (col == instance.countSourceCols() - 1 && row != 7) {

                if (value < 0) {

                  td.style.color = 'red'

                }

              }

            } catch (error) {

              console.log(error)

            }

          }

        }

      }

      else if (row == 8) {

        return {

          renderer(instance, td, row, col, prop, value, cellProperties) {

            Handsontable.renderers.TextRenderer.apply(this, arguments)

            if (col != 0) {

              td.className = "htRight"

            }

            if (col == 0) {

              td.style.backgroundColor = "#E2EFDA";

            } else {

              td.style.backgroundColor = "#FFE699";

            }

            if (col != 0) {

              if (td.textContent == "#VALUE!") {

                td.innerHTML = "0%";

                cellProperties.readOnly = true;

              }

              else {

                td.textContent = Number(td.textContent).toFixed(2) + "%";

              }

            }

            if (col == instance.countSourceCols() - 1 && value > 0) {

              td.style.color = '#C74687'

            }

            cellProperties.readOnly = true;

          }

        }

      }

      else {

        return {

          renderer(instance, td, row, col, prop, value, cellProperties) {

            Handsontable.renderers.TextRenderer.apply(this, arguments)

            if (col == 0) {

              td.style.backgroundColor = "#E2EFDA";

            } else {

              td.style.backgroundColor = "#FFE699";

              cellProperties.readOnly = true;

            }

          }

        }

      }

    },

    afterInit : () => {

      this.setComents(this.tableId1);

      this.interactiveService.sett1(true);

      this.interactiveService.setT1Aux(true);

      this.interactiveService.setT1Aux2(true);

      for(let i = 0; i < this.columnsToMap.length; i ++){

        this.inicialWidths.push(this.hotRegisterer.getInstance(this.tableId1).getColWidth(i))

      }

    }

  }

colHeadersColor function:

colHeadersColor(col, TH){

    if (col == 0 || col == 1 || col == 2 || col == 6) {

      TH.style.backgroundColor = "#44546A";

      TH.style.color = "#ffff";

    }

    else if (col == 3) {

      TH.style.backgroundColor = "#92D050";

    }

    else if (TH.textContent.search("Real") != -1) {

      TH.style.backgroundColor = "#00B050";

    }

    else if (TH.textContent.search("Prevision") != -1 || col == 5 || col > this.columnNames.length - 3) {

      TH.style.backgroundColor = "#FFFF00";

    }

    else if (TH.textContent.search("Prev ") != -1 && col < 19) {

      TH.style.backgroundColor = "#FFF2CC";

    }

    else if(col >= 19){

      TH.style.backgroundColor = "#FFDFCC";

    }

  }

And AfterChangeTable1:

afterChangeTable1(changes) {

    try {

      changes.forEach((changes, src) => {

        let row = changes[0]

        let col = changes[1]

        let newValue = changes[3]

        /**

         * Asigna el valor real de la celda en formato número

         */

        if (newValue.includes(",")) {

          let indexCol = this.columnsToMap.indexOf(col.toString());

          let value = Number(newValue.toString().replace(".", "").replace(",", ".")).toFixed(2)

          this.hotRegisterer.getInstance(this.tableId1).setDataAtCell(row, indexCol, value);

        }

        if (!newValue) {

          let indexCol = this.columnsToMap.indexOf(col.toString());

          this.hotRegisterer.getInstance(this.tableId1).setDataAtCell(row, indexCol, "0.00");

        }

        let indexCol = this.columnsToMap.indexOf(col.toString());

        this.hotRegisterer.getInstance(this.tableId1).setCellMeta(row, indexCol, 'className', 'isDirty');

        this.hotRegisterer.getInstance(this.tableId1).render();

        this.getHandsontable3();

        this.getHandsontableIndicators1();

      });

    } catch (error) {

      console.error();

    }

  }

Most tables look like this

Thank you

Hi @camiilavillamizar

Sorry for keeping you waiting. We tried to build the same code sample but it was throwing many errors. Could you please load your code into JSFiddle or Codesanbox? That will also allow us to debug the code and share fixes easier in exchange.

1 Like

Hi @aleksandra_budnik,

Sorry for the delay, is a big project so I made a new one only with one screen to simulate the behaviour.
Additionally, I have some restrictions, so I can’t upload the project to codesandbox or push to gitHub by cli.

I compacted all files in a zip, here is: https://github.com/camiilavillamizar/handsontables

There are 2 projects, when I select one everything works fine. But when I select another, there are a lot of warnings and the screen is frozen for about 3 seconds.

Could you please tell me how to improve the performance?
Thank you :slight_smile:

Hi @camiilavillamizar

Thank you for the code. We will check it and get back to you soon.

1 Like

Hi @adrian.szymanski,

I’m really sorry, I forgot to tell you you have to go to the path /central to see the buttons that show the tables.

I’ve been looking the performance tool that chrome has. It’s always lingers in the same function: core.updateSettings

In the new project:

In the original project:

Thank you for your help

Hi @camiilavillamizar

Thank you for sharing you repo. It would require the code review from our side which is a service reserved for commercial license users only. If you have the license, please e-mail us at support@handsontable.com with the information about your license and or license owner.

1 Like

Hi @camiilavillamizar

I just wanted to let you know that we fixed the following issue in Handsontable v11.1.0 https://github.com/handsontable/handsontable/issues/8771

If you use the CDN you might not see all of the changes right away as the full.js package still uses the older version of Handsontable. But if you use npm you will already have the HyperFormula updated to 1.3.1 where this issue is solved.

Please let me know if it works for you.

1 Like