cornerstonejs / cornerstoneTools

A framework for tools built on top of Cornerstone.
https://tools.cornerstonejs.org/
MIT License
579 stars 456 forks source link

Segmentation is not running smoothly (lag, pauses, jumps), maybe because of Garbage Collection or requestAnimationFrame #1360

Open vsaase opened 3 years ago

vsaase commented 3 years ago

Prerequisites

using the example https://tools.cornerstonejs.org/examples/tools/circle-scissors.html

Description

See this peformance issue: Screenshot from 2021-03-04 09-51-56

Steps to Reproduce the issue

  1. create some segmentation
  2. hold the mouse pressed down and draw a second circle

Expected behavior: (What you expected to happen) smooth drawing

Actual behavior: (What actually happened) pauses, about half a second on my machine This is a real problem because if I am drawing a segmentation and a pause happens the segmentation is not done correctly and has to be corrected. This happens with all segmentation tools and is aggravated when there is already some segmentation on the screen.

vsaase commented 3 years ago

on investigating this I found two things that are inefficient :

vsaase commented 3 years ago

here is an example of how to speed up the segmentation drawing with caching the canvas element: https://github.com/vsaase/cornerstoneTools/tree/vsaase_segmentationlag This is not ready to be merged, at the moment it breaks the brush tool and does not work with segmentation outlines. Similar caching could be done with the outlines. Any suggestions? Are there preferred ways to implement it?

faustmann commented 3 years ago

@vsaase Thank you for investigating this issue. I also depend on it. Although I started to use this library just recently if there is anything I can help please let me know.