Snippet Slows Down in subsequent runs - very weird

  • 1
  • Problem
  • Updated 6 months ago
  • Solved
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb

Posted 6 months ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I think I may know what's going on. The chart, I think, is attempting to rerender after each adopted row.

Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Yup. Confirmed. Adding/removing rows in chart snippet is problematic.
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Hi Pat,

If I understand what you're saying is the cause, it sounds like the chart is re-rendering every time its model's contents change. Since you're making many sequential updates, this is causing many re-renders of the chart. Is there any way you could modify your snippet to consolidate all the row updates into an array, and bundle them into one updateRows()? In Skuid's API documentation for updateRow() there's a note that explains "If updating several rows within a loop, it is much more efficient to use the updateRows( ) function."
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Making all my changes in one model and adopting into the final chart model when done.
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
My sense is that the changes to the model are causing a refresh to happen, and that's triggering your before-render snippet. Is there a way to separate the update actions so that the before-render snippet doesn't update models that are relevant to the chart? I am not sure there is a way to prevent the chart from trying to re-render itself if its models are updated, since that's built-in / intended functionality.