Joining objects can create more customdata layers (e.g. UVMaps) than allowed, can eat huge amounts of RAM, bloats the filesize #111608

Open
opened 2023-08-28 13:30:46 +02:00 by Philipp Oeser · 13 comments
Member

System Information
Operating system: Linux-6.1.18-200.fc37.x86_64-x86_64-with-glibc2.36 64 Bits, WAYLAND UI
Graphics card: AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.1.18-200.fc37.x86_64) AMD 4.6 (Core Profile) Mesa 22.3.7

Blender Version
Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-08-27 18:51, hash: 8a735d0aa4c7
Worked: never

Short description of error
Joining objects can create more customdata layers (e.g. UVMaps) than allowed.
While there is no hard limit for UV layers (yet), we usually restrict this to 8 from the UI.
Why can this be a problem?

See reports #111564, #71823, #96926

Joining many (hundreds or thousands -- which is not uncommon for CAD data) small objects with uniquely named UV layers will result in many, many UV layers (not only UVs, other customdata layers / attributes may be affected as well, but encountered most frequently for those), each then taking up memory/space for the whole -- now possibly very large -- mesh.

This will - unexpectedly - bloat up the filesize tremendously, also take up huge amounts of RAM for the joining operation, leading to possible crashes.
This is also not actually supported for UVMaps (the UI limit/restriction of 8 is there for a reason since e.g. Eevee, probably Cycles, too, dont handle more then 8).

Exact steps for others to reproduce the error

  • open uv_maps_on_merge_single_user_mesh_unique_uv_layer_names.blend (1.6MB)
  • join all objects, save (file is now 3.8MB, the joined object has 121 UVmaps)
  • the problem gets much worse if the resulting object is larger and/or if object count increases
**System Information** Operating system: Linux-6.1.18-200.fc37.x86_64-x86_64-with-glibc2.36 64 Bits, WAYLAND UI Graphics card: AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.1.18-200.fc37.x86_64) AMD 4.6 (Core Profile) Mesa 22.3.7 **Blender Version** Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-08-27 18:51, hash: `8a735d0aa4c7` Worked: never **Short description of error** Joining objects can create more customdata layers (e.g. UVMaps) than allowed. While there is no hard limit for UV layers (yet), we usually restrict this to 8 from the UI. Why can this be a problem? See reports #111564, #71823, #96926 Joining many (hundreds or thousands -- which is not uncommon for CAD data) small objects with uniquely named UV layers will result in many, many UV layers (not only UVs, other customdata layers / attributes may be affected as well, but encountered most frequently for those), each then taking up memory/space for the whole -- now possibly very large -- mesh. This will - unexpectedly - bloat up the filesize tremendously, also take up huge amounts of RAM for the joining operation, leading to possible crashes. This is also not actually supported for UVMaps (the UI limit/restriction of 8 is there for a reason since e.g. Eevee, probably Cycles, too, dont handle more then 8). **Exact steps for others to reproduce the error** - open `uv_maps_on_merge_single_user_mesh_unique_uv_layer_names.blend` (1.6MB) - join all objects, save (file is now 3.8MB, the joined object has 121 UVmaps) - the problem gets much worse if the resulting object is larger and/or if object count increases
Philipp Oeser added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-08-28 13:30:46 +02:00
Author
Member

Will put on my desk for further investigation, possible solutions:

  • either limiting the amount of UV layers upon joining to 8 (as we elsewhere in the UI)
  • merging the UV layers based upon index (so merge all first uv layers of all sources into one on the destination, merge all second uv layers of all sources into a second uv layer on destination, ...) -- this could be an option on the operator
  • if the above doesnt work out for some reason, at least spit out a warning in the UI that more than 8 UV layers have been created
Will put on my desk for further investigation, possible solutions: - either limiting the amount of UV layers upon joining to 8 (as we elsewhere in the UI) - merging the UV layers based upon index (so merge all first uv layers of all sources into one on the destination, merge all second uv layers of all sources into a second uv layer on destination, ...) -- this could be an option on the operator - if the above doesnt work out for some reason, at least spit out a warning in the UI that more than 8 UV layers have been created
Author
Member

Note to myself: LayerTypeInfo could have a layers_max() function for CD_PROP_FLOAT2 (it did have one for CD_MTFACE -- layerMaxNum_tface)

Note to myself: `LayerTypeInfo` could have a `layers_max()` function for `CD_PROP_FLOAT2` (it did have one for `CD_MTFACE` -- `layerMaxNum_tface`)
Philipp Oeser added
Status
Confirmed
Module
Modeling
and removed
Status
Needs Triage
labels 2023-08-28 13:34:53 +02:00
Philipp Oeser self-assigned this 2023-08-28 13:34:57 +02:00
Author
Member

@Baardaap might be interested

@Baardaap might be interested
Author
Member

Just dropping a workaround for folks running into this: you can of course rename the UVs (probably best thing to do is by index) prior to joining (so names are equal on participating meshes -- this way the layers get merged instead of created)

Just dropping a workaround for folks running into this: you can of course rename the UVs (probably best thing to do is by index) prior to joining (so names are equal on participating meshes -- this way the layers get merged instead of created)
Member

If I'm understanding this correctly, this behaviour is because that every face corner should have a UV coordinate in all uv layers present in the mesh? (Or every layer of UV will have all face corners of the mesh, I guess the same idea)

If I'm understanding this correctly, this behaviour is because that every face corner should have a UV coordinate in _all_ uv layers present in the mesh? (Or every layer of UV will have all face corners of the mesh, I guess the same idea)
Author
Member

Yes, all layers have the size of the whole mesh.

Quoting @HooglyBoogly from chat:

It's theoretically possible to optimize attribute storage for cases like this, to avoid keeping the giant array of zeros

Yes, all layers have the size of the whole mesh. Quoting @HooglyBoogly from chat: >It's theoretically possible to optimize attribute storage for cases like this, to avoid keeping the giant array of zeros
Member

I should clarify we're pretty far from being able to do that (we have to replaces uses of CustomData_* with the attribute API first), but it's good to keep such sparse attribute storage in mind.

I do think it's better if joining stays predictable/simple and name based. A "Rename UV Maps by Index" operator might make sense, though it may be a bit specific?

I should clarify we're pretty far from being able to do that (we have to replaces uses of `CustomData_*` with the attribute API first), but it's good to keep such sparse attribute storage in mind. I do think it's better if joining stays predictable/simple and name based. A "Rename UV Maps by Index" operator might make sense, though it may be a bit specific?
Member

I also want to clarify that there is no limit to the number of UV attributes in the design now-- that was an important part of the switch to the generic attribute API.

I also want to clarify that there is no limit to the number of UV attributes in the design now-- that was an important part of the switch to the generic attribute API.
Author
Member

I also want to clarify that there is no limit to the number of UV attributes in the design now-- that was an important part of the switch to the generic attribute API.

We still limit it from the UI though (at least from the UIList, adding more than 8 is prevented)

> I also want to clarify that there is no limit to the number of UV attributes in the design now-- that was an important part of the switch to the generic attribute API. We still limit it from the UI though (at least from the UIList, adding more than 8 is prevented)
Member

We still limit it from the UI though (at least from the UIList, adding more than 8 is prevented)

Interesting, didn't realize that. I know the transition to remove the limit from some areas is still incomplete, maybe that's the reasoning (hence the "on a design level")

> We still limit it from the UI though (at least from the UIList, adding more than 8 is prevented) Interesting, didn't realize that. I know the transition to remove the limit from some areas is still incomplete, maybe that's the reasoning (hence the "on a design level")
Author
Member

We still limit it from the UI though (at least from the UIList, adding more than 8 is prevented)

Interesting, didn't realize that. I know the transition to remove the limit from some areas is still incomplete, maybe that's the reasoning (hence the "on a design level")

The limit is there for a reason, see BKE_mesh_validate_all_customdata

More UV layers than allowed, last ones won't be available for render, shaders, etc.

The limit cant be removed from everywhere (at least not in a way that layers above the limit will actually work as expected), so even if we would allow them internally (which might not be the best idea due to the problems presented in this report), we have to counter-act on the UX level (warnings, cleanup operators, defaulting to merge by index in the join operator, ...)

> > We still limit it from the UI though (at least from the UIList, adding more than 8 is prevented) > > Interesting, didn't realize that. I know the transition to remove the limit from some areas is still incomplete, maybe that's the reasoning (hence the "on a design level") > The limit is there for a reason, see `BKE_mesh_validate_all_customdata` >More UV layers than allowed, last ones won't be available for render, shaders, etc. The limit cant be removed from everywhere (at least not in a way that layers above the limit will actually work as expected), so even if we would allow them internally (which might not be the best idea due to the problems presented in this report), we have to counter-act on the UX level (warnings, cleanup operators, defaulting to merge by index in the join operator, ...)

More UV layers than allowed, last ones won't be available for render, shaders, etc.

I'm not completely sure about this, since it has been a while I really dove into this code, but I think only the uv layers referenced from the material get copied to the renderer. So that gives it some leeway as a mesh can have more uv layers.

Extra UV layers can be useful in GN trees which have no problem using them. But it does lead to a quite messy situation which would need clear warnings in the UI some maybe it would be simpler to just keep the restriction on the number of UV layers in place.

> More UV layers than allowed, last ones won't be available for render, shaders, etc. I'm not completely sure about this, since it has been a while I really dove into this code, but I _think_ only the uv layers referenced from the material get copied to the renderer. So that gives it some leeway as a mesh can have more uv layers. Extra UV layers can be useful in GN trees which have no problem using them. But it does lead to a quite messy situation which would need clear warnings in the UI some maybe it would be simpler to just keep the restriction on the number of UV layers in place.
Author
Member

Stepping down since I currently not plan on actually working on this (although it is still a big issue)

Stepping down since I currently not plan on actually working on this (although it is still a big issue)
Philipp Oeser removed their assignment 2024-03-27 14:10:32 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111608
No description provided.