cornerstonejs / cornerstone3D

Cornerstone is a set of JavaScript libraries that can be used to build web-based medical imaging applications. It provides a framework to build radiology applications such as the OHIF Viewer.
https://cornerstonejs.org
MIT License
528 stars 271 forks source link

Uncaught TypeError: Cannot read properties of undefined (reading 'vec2') at CrosshairsTool.ts:54:34 #339

Open mxj009 opened 1 year ago

mxj009 commented 1 year ago

import * as cornerstoneTools from '@cornerstonejs/tools';

In Vue3, after all dependencies are installed and Cornerstone is introduced, the error of vec2 is reported

rogerbramon commented 1 year ago

I'm experiencing the same issue when using it in a Next.js project. As far as I was able to investigate, this problem was introduced on commit 18aa4d8 that includes versions:

The last working version on my case is @cornerstonejs/tools@0.27.2 combined with @cornerstonejs/core@0.19.2 and @cornerstonejs/streaming-image-volume-loader@0.5.19.

Not sure if @sedghi can provide any feedback since it was the main contributor of this version.

Using the latest versions, this error a bit different but related to loading modules:

TypeError: Cannot destructure property 'floodFill' of '_utilities__WEBPACK_IMPORTED_MODULE_1__.segmentation' as it is undefined.

Let me now if you need anything.

Thanks!

sedghi commented 1 year ago

Hmm, the latest version error seems weird to me. I checked floodfill export and it looked fine to me here

It would help if you provide a repo link for sure

rogerbramon commented 1 year ago

Thanks @sedghi for your fast reply!

It turn out that the problem only occurs on dev mode running the app using yarn dev. It works fine using yarn build & yarn start

I prepared a basic repo to show them problem: https://github.com/rogerbramon/cornerstone-nextjs

On main branch, you have a working setup using versions: @cornerstonejs/tools@0.27.2 combined with @cornerstonejs/core@0.19.2 and @cornerstonejs/streaming-image-volume-loader@0.5.19.

On branch cornerstone-issue-339, I just updated to the latest available versions. The error should appear just after starting the website using yarn dev command. If you use version 0.20.0 instead of the latest, you could reproduce the error mentioned by @mxj009 in the initial comment of this issue.

image

Hope that helps.

sedghi commented 1 year ago

I think I have a fix. Maybe try it after merged

rogerbramon commented 1 year ago

Thanks @sedghi! It seems to be fixed on @cornerstonejs/tools@0.35.2.

Is there anything we can do to prevent it from happening again in the future?

sedghi commented 1 year ago

I'm not sure what was the issue. probably from next.js ts loader ...?

rogerbramon commented 1 year ago

Not sure either... It seems to be happening on Vue3 too.

sedghi commented 1 year ago

so there is still problem? what it says in Vue?

rogerbramon commented 1 year ago

No, sorry for the confusion. I meant that when the issue was reported by @mxj009 it was happening on Vue3. So, the cause was probably affecting both frameworks (Next.js, Vue3). It's working for me now on Next.js.

sedghi commented 1 year ago

related https://github.com/cornerstonejs/cornerstone3D-beta/issues/226

sedghi commented 10 months ago

This seem to be related to the ciruclar dependencies that we have #742 We will fix it in the version 2