Slicer / Slicer

Multi-platform, free open source software for visualization and image computing.
https://www.slicer.org
Other
1.68k stars 546 forks source link

Cannot save scene to MRB on Windows if some node names are long #7901

Open cpinter opened 1 month ago

cpinter commented 1 month ago

Summary

Posting this as an issue because it comes up more and more often. If I want to save a scene to MRB that has at least one node with a name longer than ~60 characters (which is not at all unreasonably long), then saving the scene fails, even if I save it to the root directory (e.g. D:\).

Such long node names are quite frequent for example in RT data (such as 2: RTDOSE: DOSIsoft:RTDOSE:Phase #1 Dosi Dosi 1: Beam setup 1 (GY) [11] in the data provided in https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766). Another case when I have such long names is when I use a module that combines nodes, such as ComparisonSubtraction_[NodeName1]_[NodeName2]. So to me it seems that it is quite standard having a node with a name longer than a few dozen characters.

Important to note that if you save the scene as .mrml + data files then saving does not fail in this case.

The relevant part of the log:

[Qt] void __cdecl qSlicerSaveDataDialogPrivate::updateStatusIconFromMessageCollection(int,class vtkMRMLMessageCollection *,bool) Data save error: "- Error: MRHeadzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz (vtkMRMLScalarVolumeNode1): Failed to write 'C:/Users/CsabaPintér/AppData/Local/slicer.org/Slicer/cache/SlicerIO/__BundleSaveTemp-2024-08-22_124836_56/2024-08-22-Scene/Data/TempWriteMRHeadzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz/MRHeadzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.nrrd'\n- Error: Failed to save D:/zzzzzzzzzzzzzzzzzzzz/2024-08-22-Scene.mrb: Failed to save scene to data bundle directory\n- Error: Failed to save scene as D:/zzzzzzzzzzzzzzzzzzzz/2024-08-22-Scene.mrb\n- Error: Saving failed with all writers found for file 'D:/zzzzzzzzzzzzzzzzzzzz/2024-08-22-Scene.mrb' of type 'SceneFile'.\n"

Steps to reproduce

  1. Load MRHead in SampleData
  2. Go to Data module and rename MRHead: add 60 characters at the end
  3. Save scene as MRB to anywhere

Environment

lassoan commented 1 month ago

We have a pull request that may address this problem:

https://github.com/Slicer/Slicer/pull/7899

If you find that this does not fix the problem that you encountered then please comment on that pull request. The solution there could be extended to shorten long filename using the first N character of the node name followed by a hash of the remainder of the node name.

cpinter commented 1 month ago

What a coincidence, thanks for point out the PR. I did some searches among the issues and did not find one, so I decided to create this. I haven't looked at the PRs

Sunderlandkyl commented 1 month ago

I think that the PR doesn't address this problem since it only shortens the temporary bundle directory, and impacts sequences more than regular node types (since they use the bundle directory twice in the same path).

cpinter commented 1 month ago

The problem I think is the length of the entire path. I'll test my use cases after that PR is integrated and get back here with what I find.

Sunderlandkyl commented 1 month ago

Yeah the problem in both cases is likely the full path length, this issue is also related: https://github.com/Slicer/Slicer/issues/6037.