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

Examples break when using streaming-wadors #149

Closed
heyflynn opened this issue Jul 18, 2022 · 11 comments
Closed

Examples break when using streaming-wadors #149

heyflynn opened this issue Jul 18, 2022 · 11 comments

Comments

@heyflynn
Copy link

heyflynn commented Jul 18, 2022

I ran into an issue while doing the examples and trying to use steaming-wadors

in all the Volume examples, imageIds are created and cached with the createImageIdsAndCacheMetaData helper function and 'VOLUME' (upper case string) for type.
https://github.com/cornerstonejs/cornerstone3D-beta/blob/659888db44ab70d562f7f52872c822feb5c1db03/packages/core/examples/multiVolumeAPI/index.ts#L214

After closer inspection of the helper function you, which prefix is determined here

https://github.com/cornerstonejs/cornerstone3D-beta/blob/main/utils/demo/helpers/createImageIdsAndCacheMetaData.js#L51

but VOLUME constant is
const VOLUME = 'volume';

When I fix the constant to 'VOLUME' the streaming loader fails to initialize with the following exception... "Error: cornerstoneWADOImageLoader requires a copy of Cornerstone to work properly."
image

@sedghi
Copy link
Member

sedghi commented Aug 9, 2022

Hmmm, so was it working with the VOLUME as type you are saying? As the error says you need to pass in the cornerstone to the cornerstoneWADOImageLoader, similar to what we do here

@heyflynn
Copy link
Author

what I mean is that the examples don't ever use streaming-image-volume-loader.

in the all the volume examples, the function createImageIdsAndCacheMetaData is called with an upper case string 'VOLUME'

in the examples createImageIdsAndCacheMetaData is called with type parameter as 'VOLUME' (upper case string ) that is evaluated against the constant VOLUME which is 'volume' (lower case).

const prefix = type === VOLUME ? 'streaming-wadors:' : 'wadors:';

will always be set to 'wadors:'

if I set the createImageIdsAndCacheMetaData to 'volume' then it tries to load images using streaming-wadors.

that's when streaming-image-volume-loader fails with the exception provided above.

I do have cornerstone external initialized properly as you pointed out.

@sedghi
Copy link
Member

sedghi commented Aug 10, 2022

I see, yeah this is a bug, but changing the it to volume doesn't give me error.

Basically the difference between wadors and streaming-wadors image loaders is that wadors creates the image object, but in the streaming-wadors which uses SharedArrayBufferImageLoader, it basically goes through the same process just don't create the image object (optimization for speed, since images are inserted into the volume and we don't need the image object basically).

So this subtle bug was creating the image objects but the pixeldata was also inserted into the volume.

How do you run the example that you get the error? Maybe check this out https://www.cornerstonejs.org/docs/tutorials/examples

image

@heyflynn
Copy link
Author

thanks for looking into it, the problem is with my code then.

I'm using Create React App and I don't think webpack is linking the same cornerstone-wado-image-loader module.

example: sharedArrayBufferImageLoader uses this dynamic import instead of the alias.

https://github.com/cornerstonejs/cornerstone3D-beta/blob/105bd9d97e0df6e67a61c5e13b3393a106ff69d5/packages/streaming-image-volume-loader/src/sharedArrayBufferImageLoader.ts#L7
'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js';

I tried making an alias for this module but that fails with a different error.

@sedghi
Copy link
Member

sedghi commented Aug 10, 2022

Thanks for reporting this bug, now our examples are much faster haha

I expect that the error don't happen if you don't link anything, right? Look into the OHIF webpack (which is basically ejected version of CRA), to see how we are setting the aliases etc.

@heyflynn
Copy link
Author

fantastic!

I missed the part about dynamic-imports from cornerstoneWadoImageLoader for upgrading to 4.0. Adding the alias for dynamic imports and adding CopyWebpackPlugin to copy to the build folder solved my last issue.

My examples are working using streaming-wadors now.

Thanks for your help.

@sedghi sedghi closed this as completed Aug 10, 2022
@selimcanglr
Copy link

I currently have the same issue. I've also created my React app with 'create-react-app' and get the same error message. Do you mind sharing how did you add the alias and the CopyWebpackPlugin?

@yanqzsu
Copy link
Contributor

yanqzsu commented Sep 6, 2022

You can refer to here

I currently have the same issue. I've also created my React app with 'create-react-app' and get the same error message. Do you mind sharing how did you add the alias and the CopyWebpackPlugin?

@selimcanglr
Copy link

You can refer to here

I currently have the same issue. I've also created my React app with 'create-react-app' and get the same error message. Do you mind sharing how did you add the alias and the CopyWebpackPlugin?

I have already solved the problem on my side. However, CopyWebpackPlugin part in the upgrade guide is outdated and not working anymore as it is. I have created a pull request to fix it.

@heyflynn
Copy link
Author

You can refer to here

I currently have the same issue. I've also created my React app with 'create-react-app' and get the same error message. Do you mind sharing how did you add the alias and the CopyWebpackPlugin?

I have already solved the problem on my side. However, CopyWebpackPlugin part in the upgrade guide is outdated and not working anymore as it is. I have created a pull request to fix it.

Are you still having a problem with this?

if so, I can create a bootstrap for Create React App and Cornerstone 3D.

@ShitalPP
Copy link

I was also getting same error while loading Volume with 'streaming-wadors:' .
As suggested I have added below config in my webpack , so now I am not getting error 'cornerstoneWADOImageLoader requires a copy of Cornerstone to work properly'

resolve: {
alias: {
'cornerstone-wado-image-loader':
'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js',
},

But Volume not getting loaded properly and getting error , please see attached pic

image4

Thanks

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

5 participants