Skip to content
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] With Webpack setToolActive throws "Cannot read properties of undefined (reading 'renderViewport')" on stack viewport #1262

Closed
plt-joey opened this issue May 21, 2024 · 2 comments
Assignees

Comments

@plt-joey
Copy link

Describe the Bug

Calling toolGroup.setToolActive on a barebones stack viewport in a webpack project throws an internal error.

The error thrown in Chrome:

index.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'renderViewport')
    at eval (index.js:1:391493)
    at Array.forEach (<anonymous>)
    at Bp._renderViewports (index.js:1:391412)
    at Bp.setToolActive (index.js:1:387749)
    at __webpack_require__.g.enable_tool (index.js:103:15)
    at HTMLButtonElement.onclick ((index):9:55)

The error thrown in Firefox:

Uncaught TypeError: oe.getRenderingEngine(...) is undefined
    _renderViewports webpack://cornerstone-test/./node_modules/@cornerstonejs/tools/dist/umd/index.js?:1
    _renderViewports webpack://cornerstone-test/./node_modules/@cornerstonejs/tools/dist/umd/index.js?:1
    setToolActive webpack://cornerstone-test/./node_modules/@cornerstonejs/tools/dist/umd/index.js?:1
    enable_tool webpack://cornerstone-test/./src/index.js?:103
    onclick https://localhost:8080/:1

Both are referring to the same line, just reporting the error differently.

Steps to Reproduce

A minimum repro that roughly matches the webpack configuration I am using: https://github.com/plt-joey/cornerstone-issue-repro

See the readme for build and run instructions, be sure to press the Enable Pan Tool button to trigger the error. Note that this uses the UMD distribution because of a similar error to one seen when using vite (#1071).

The sample DICOM provided is a slice from a publicly available scan of a mouse.

The current behavior

toolGroup.setToolActive is called, an error is thrown, and the tool does not become active . No interaction with the DICOM is possible.

Alternatively, if toolGroup.setToolActive is called before the viewport is set up then no error is thrown, but the tool still remains inactive.

The expected behavior

toolGroup.setToolActive is called, the tool becomes active and the user is able to interact with the DICOM image

OS

Windows

Node version

v18.12.1

Browser

Chrome (125.0.6422.60) and Firefox (126.0)

@plt-joey
Copy link
Author

This seems to be fixed as of 1.74.8

@llama-hedge
Copy link

I had this exact problem despite using Cornerstone 1.82.5, but was able to fix it by upgrading Webpack to 5.90.0.

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

No branches or pull requests

3 participants