Memory inefficiency with layer groups
Environment/Versions
- GIMP Version: 2.10.22 and 2.99
- Package: Debian repository for 2.10 and flatpak for 2.99
- Operating System: Debian 11
Issue Description
When you add a mask to a layer group, the xcf size increases as much as if you added the same mask on each layer inside the group. This seems very unoptimized since the same mask data gets duplicated as many times as you have layers inside a group.
To demonstrate my theory, I attached 2 files:
- noise.xcf contains 4 layers with 4 masks, all made of pure noise. All noise patterns have a different seed, making this file contain 8 uncompressible "drawables" (as gimp calls it).
- noise-group.xcf contains the same 4 layers but this time only one mask applied to a group that contains the 4 layers, meaning this time there are only 5 uncompressible drawables.
Yet, both files have a size of 1.84MB. And to be clear you can make these noise patterns large enough to make a 32MB xcf, the size difference between the first and second version will be in the kilobytes, meaning it's only a matter of which noise pattern is slightly more compressible than which other.
Desired result
I think the xcf format should be made more optimized so that a mask added to a layer group wouldn't increase the size of an xcf by more than the size of one instance of the mask.