feat(rendering): Introduce WebGLContextPool for parallel rendering in ContextPoolRenderingEngine - #2190
Merged
Merged
Conversation
sedghi
reviewed
Jul 10, 2025
sedghi
left a comment
Member
There was a problem hiding this comment.
add this point we need a doc in https://www.cornerstonejs.org/docs/concepts/cornerstone-core/renderingEngine
to talk about each RE
sedghi
reviewed
Jul 10, 2025
sedghi
reviewed
Jul 10, 2025
sedghi
reviewed
Jul 10, 2025
Member
Author
|
Deploy preview: https://remarkable-torrone-d3cd0a.netlify.app/ |
sedghi
approved these changes
Jul 10, 2025
sedghi
left a comment
Member
There was a problem hiding this comment.
Thanks, add the extra tests we discussed, looks good
Member
Author
|
I have tested all examples, and added multiple tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR enhances the
ContextPoolRenderingEngine(previouslySequentialRenderingEngine) by introducing aWebGLContextPoolclass that enables parallel rendering across multiple WebGL contexts. This optimization significantly improves performance when rendering multiple viewports simultaneously while maintaining the core benefits of sequential rendering.WebGL Context Pooling
Following the successful resolution of canvas size limitations in PR #2181, this PR takes the next step in performance optimization. While the sequential approach solved critical issues with viewport cropping and performance degradation on high-resolution displays, it rendered viewports one at a time. This new implementation introduces controlled parallelism to boost performance further.
Key Features
WebGLContextPool
The new
WebGLContextPoolclass manages multiple WebGL contexts (default: 8) that can render viewports in parallel:webGlContextCountin the init configurationArchitecture
Performance Benefits
Multiple stack viewports can now render simultaneously across different WebGL contexts, and significant performance improvement for sychronized operations, eg cine, synced scrolling.
Implementation Details
Configuration
Users can configure the number of WebGL contexts during initialization:
Context Assignment Strategy
Important Notes
Context Limit: While 8 is the safe default, users should not exceed this unless necessary. Browser limits are typically around 16 contexts per tab, but if your goal is to support as many devices as possible, it's best to stay well below this limit to avoid issues.
Volume Viewport Limitation: Volume viewports cannot currently utilize parallel rendering due to WebGL resource sharing constraints between contexts. This is a current limitation of WebGL.
Example
https://marvelous-genie-f7fb6a.netlify.app/live-examples/webglcontextpooling