regl icon indicating copy to clipboard operation
regl copied to clipboard

[Q] how to prevent too frequent draws for the sake of safety?

Open kkdd opened this issue 3 years ago • 0 comments

Hello, I observed that too frequent regl draws freezed/crashed web browsers (tested in Google Chrome 100.0.4896.75(macOS)).

How to prevent too frequent draws for the sake of safety? The following method is admissible or recommended?

for (frequent_loop) {
  setData(newData);
  drawRequested = true
}

let drawRequested = false;
regl.frame(()=>{
  if (drawRequested) {doReglDraw()); drawRequested=false;}
});

rather than

for (frequent_loop) {
  setData(newData);
  doReglDraw()
}

.

Note that the above method is tested in regl + d3.js: Zoomable scatter plot with reading data files dropped-onto (bl.ocks), where frequent_loop is caused by file.stream().getReader();.

kkdd avatar Apr 10 '22 11:04 kkdd