ami icon indicating copy to clipboard operation
ami copied to clipboard

Reduce bundle size

Open NicolasRannou opened this issue 7 years ago • 7 comments

Lots of code from THREEJS is not shaked-out and OpenJPEG is way too big.

> yarn analyze:ami:prod 

screen shot 2018-07-23 at 1 38 11 pm

NicolasRannou avatar Jul 23 '18 11:07 NicolasRannou

https://github.com/FNNDSC/ami/pull/326

NicolasRannou avatar Jul 25 '18 07:07 NicolasRannou

screen shot 2018-07-25 at 9 48 40 am

NicolasRannou avatar Jul 25 '18 07:07 NicolasRannou

Pako is being included 2 times. (-200kB)

OpenJPEG is huge. Can we get rid of JPX/JPEG decoder then?

Freesurder segmentation preset should not be part of the bundle. (-100kB)

NicolasRannou avatar Jul 25 '18 07:07 NicolasRannou

OpenJPEG can be excluded from package. If users want to work with J2K, AMI documentation will force them to load OpenJPEG script before AMI, like it done in Cornerstone.

JSibir avatar Jul 25 '18 11:07 JSibir

Interesting - do you have a link to where they would do in Cornerstone?

In AMI, the data "parsers" and "decoders" is the most expensive thing

NicolasRannou avatar Jul 25 '18 11:07 NicolasRannou

https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/docs/Codecs.md https://rawgit.com/cornerstonejs/cornerstoneWADOImageLoader/master/examples/dicomfile/index.html L112-L133

JSibir avatar Jul 25 '18 11:07 JSibir

Thanks that's useful!

What I am thinking now is that: 1- load all codecs on demand in ami (somehow)

// in dicom parser
if (j2k) {
  // get j2k decoder through ajax file, then when loaded, continue
}

or 2- provide codecs in the loader/parser constructors

const volumeLoader = new VolumeLoader({
  decoders:
  { 
    j2k: J2K, // J2K constructor
  }
})

NicolasRannou avatar Jul 25 '18 12:07 NicolasRannou