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:
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.
Sample Name
field, use the expression{{ entity_value('Sample Name', generation=-1) }}
. Theentity_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.Assessed Molarity (nM)
field, use the expression{{ cell("Normalized Molarity (nM)", "SEQ Lab: Manual Illumina Dilutions Setup") }}
. Thecell
can be used when a value from any field within the workflow needs to be pulled.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 2cell
expressions) with 200 samples and fields without an impact to performance.