Skip to content

Conversation

@arul-trenser
Copy link
Contributor

Context

  • When crosshair is enabled and a measurement jump is triggered, navigating to the target view causes a recursive camera reset, eventually resulting in a “Maximum call stack exceeded” error.
  • This PR has been incorporated by FlyWheel.io.

During measurement navigation, the following sequence occurs:

  • setViewReference invokes setOrientation
  • setOrientation calls applyViewOrientation
  • applyViewOrientation triggers resetCamera with { resetOrientation: false, resetRotation: false }
  • resetCamera emits a CAMERA_RESET event
  • The crosshair listener responds to CAMERA_RESET by resetting the camera again with resetRotation: true

After applying the orientation, setViewReference continues under the assumption that the viewport is aligned with the measurement’s orientation. However, the repeated camera resets triggered by the crosshair revert the orientation. This causes setViewReference to continuously reapply the orientation, resulting in an infinite loop and eventually a maximum call stack exceeded error.

image
maxium_call_stack_error.mp4

Changes & Results

Camera reset events are now suppressed while applying orientation changes during measurement navigation, preventing recursive resets and eliminating the call stack overflow.

Testing

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • "OS: Windows 11
  • "Node version: 22.19.0
  • "Browser: Chrome 143.0.7499.109

@wayfarer3130 wayfarer3130 merged commit 074faf3 into cornerstonejs:main Dec 17, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants