-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Poor multi-frame cine loop playback #1756
Comments
we recentely did some performance optimizations for multiframe in OHIF via OHIF/Viewers#4693 and OHIF/Viewers#4560 I will include these in upcoming 3.9.3 can you try with latest and see if it is improved before i go deep into vtk side? |
This doesn't work. The camera (pan, zoom etc), windowlevel etc can be changed during the cineloop which would require a need to re-render. Then we need to have image comparisons etc, it simply gets out of hand. I feel like caching the range, and just change vtk.js to accept those ranges and bypass its range calculation is the easiest way forward |
Initially, I also supported caching the multi-instance metadata instead of recreating it each time, but it seems @wayfarer3130 has some concerns. I think it would be fine, honestly. |
Describe the Bug
Currently rendering multi-frame cine images, such as multi frame ultrasounds, isn't great. Slower machines can drop frames, particularly when multiple multi-frame cine images are rendered at the same time.
Steps to Reproduce
The current behavior
The following tests were run in OHIF demo viewer:
The image below if a performance snapshot, recorded on a Mac M1 Pro, running Mac OX 15.1.1 and Chromium 131.
From this, there appear to be 2 opportunities to improve performance. Other than the time taken to actually render each frame, there are 2 calls that combined take approx 50% of the execution time.
combineFrameInstance
is being called a lot (possible more than once per render). It is called in StackViewport,getFrameOfReferenceUID
(cornerstone3D/packages/core/src/RenderingEngine/StackViewport.ts
Line 534 in 160d80f
ImagePlaneModule
- is it possible to cache theImagePlaneModule
either inStackViewport
or in themetadataProvider
to reduce the time taken to calculate this for every frame?fastComputeRange
which is avtk.js
method is the other opportunity.vtk.js
calculates the range of everyI have spent some time investigating this.
StackViewport
creates an instance ofvtkDataArray
and then callsrender
.vtk.js
eventually callsImageMapper.buildBufferObjects
(https://github.com/Kitware/vtk-js/blob/35a933890f491d419ccfd376efabe6b19c252982/Sources/Rendering/OpenGL/ImageMapper/index.js#L932). This retrieves a reference to thevtkDataArray
instance created in step 1.vtk.js
then creates a newvtkDataArray
on line 1320 (https://github.com/Kitware/vtk-js/blob/35a933890f491d419ccfd376efabe6b19c252982/Sources/Rendering/OpenGL/ImageMapper/index.js#L1320) ready for displaying. It is this new instance that hasgetRange
and subsequentlyfastComputeRange
called on every render.In order to improve performance, we need to find a way to reduce/remove the need to calculate the range of this new
vtkDataArray
on every render.It is possible to pass pre-calculated range in
StackViewport
when creating the imagevtkDataArray
(see https://kitware.github.io/vtk-js/docs/structures_DataArray.html#Scalar-array-in-memory). ie:which could be calculated by the
imageLoader
. However this won't help asvtk.js
doesn't use the range ofimgScalars
when building the texture to render.So the 2 options appear to be:
vtk.js
to recalculate the frame on every render.or
vtk.js
ImageMapper
to use the range ofimgScalars
to reduce the need to calculate the range. For instance, in the cases I examined, theijkMode
===SlicingMode.NONE
(https://github.com/Kitware/vtk-js/blob/35a933890f491d419ccfd376efabe6b19c252982/Sources/Rendering/OpenGL/ImageMapper/index.js#L1296) which then takes a direct copy ofimgScalars
. In this case, is it possible to copy theimgScalars
range and apply them to the constructeddataArray
in lines https://github.com/Kitware/vtk-js/blob/35a933890f491d419ccfd376efabe6b19c252982/Sources/Rendering/OpenGL/ImageMapper/index.js#L1320-L1327The expected behavior
Playback of multi-frame ultrasound images should be smooth on as many devices as possible.
OS
MacOS 15.2
Node version
N/A
Browser
Chromium 131.0 (Brave)
The text was updated successfully, but these errors were encountered: