Skip to main content

Troubleshooting: Issue Using 'api.setDataAt()' in OnRender

Issue:

Customer is creating a custom onrender and introduced a serious performance issue when calling 'api.setDataAt(i, field, val);' that also includes a button for updating the worksheet. After running the onclick handler for the button and updating the worksheet, the browser becomes laggy and the CPU starts spiking at 99% usage. See attached performance screen captures below:

19410493819667-mceclip0.png
19410471046675-mceclip1.png

Solution:

  • The root cause in this specific case was the api.setDataAt(i, field, val); call.

    • Note: For 200 samples, this api would be called 200 times for every field that needs to be populated (for non null values) with the parent value which can cause significant drop in the performance.

      A better alternative for updating worksheets values from exiting parent entity values would be to use datalinks to pull the values from the parent entities.

  • The following datalinks were used in the specific SEQ Lab: Manual Illumina Dilutions Create Dilutions protocol.

    1. Sample Name field, use the expression {{ entity_value('Sample Name', generation=-1) }}. The entity_value can be used when the value of an entry needs to be pulled and by combining it with generation we can target the Parent or grandparent etc.

    2. Assessed Molarity (nM) field, use the expression {{ cell("Normalized Molarity (nM)", "SEQ Lab: Manual Illumina Dilutions Setup") }} . The cell can be used when a value from any field within the workflow needs to be pulled.

    3. Similarly, user would create datalinks for additional fields. Using this approach there is no need for API calls or a handler button. These values for which the datalinks have been set will load automatically in SEQ Lab: Manual Illumina Dilutions Create Dilutions protocol.

  • The solution was tested with 4 datalinks (2 entity_value expressions and 2 cell expressions) with 200 samples and fields without an impact to performance.