Smart UV Project operator freezes Blender and never finishes #102843

Closed
opened 2022-11-29 10:37:08 +01:00 by Ludvik Koutny · 19 comments
Contributor

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 522.25

Blender Version
Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: b292cfe5a9
Worked: (newest version of Blender that worked as expected)

Short description of error
In one of my production files, on a specific mesh object, using Smart UV Project operator freezes Blender and the operation never finishes. The memory grows a little but then stays the same, as if the operator was stuck in a loop.

Exact steps for others to reproduce the error

  1. Open the attached .blend file: UVFreeze.zip
  2. Select the Cliff_A object
  3. Enter edit mode
  4. Select all faces
  5. Execute Smart UV Project operator with default settings
    Result: Blender freezes and the operation never finishes
    Expect: Blender does not freeze and operation eventually finishes
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 522.25 **Blender Version** Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: `b292cfe5a9` Worked: (newest version of Blender that worked as expected) **Short description of error** In one of my production files, on a specific mesh object, using Smart UV Project operator freezes Blender and the operation never finishes. The memory grows a little but then stays the same, as if the operator was stuck in a loop. **Exact steps for others to reproduce the error** 1. Open the attached .blend file: [UVFreeze.zip](https://archive.blender.org/developer/F13978189/UVFreeze.zip) 2. Select the Cliff_A object 3. Enter edit mode 4. Select all faces 5. Execute Smart UV Project operator with default settings Result: Blender freezes and the operation never finishes Expect: Blender does not freeze and operation eventually finishes
Author
Contributor

Added subscriber: @Rawalanche

Added subscriber: @Rawalanche

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

This object is corrupted.
See the Mesh.validate() log:

ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:719 BKE_mesh_validate_arrays:Polys 681551 and 681545 use same vertices (105825
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353645
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353648
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:723 BKE_mesh_validate_arrays: ), considering poly 681545 as invalid.
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085779 is unused.
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085780 is unused.
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085781 is unused.

But even validating, the operation is taking a lot of time.
I don't know if it's an infinite loop or if it's just because it takes so long.

This object is corrupted. See the `Mesh.validate()` log: ``` ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:719 BKE_mesh_validate_arrays:Polys 681551 and 681545 use same vertices (105825 ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353645 ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353648 ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:723 BKE_mesh_validate_arrays: ), considering poly 681545 as invalid. ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085779 is unused. ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085780 is unused. ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085781 is unused. ``` But even validating, the operation is taking a lot of time. I don't know if it's an infinite loop or if it's just because it takes so long.
Author
Contributor

In #102843#1453070, @mano-wii wrote:
This object is corrupted.
See the Mesh.validate() log:

ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:719 BKE_mesh_validate_arrays:Polys 681551 and 681545 use same vertices (105825
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353645
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353648
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:723 BKE_mesh_validate_arrays: ), considering poly 681545 as invalid.
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085779 is unused.
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085780 is unused.
ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085781 is unused.

But even validating, the operation is taking a lot of time.
I don't know if it's an infinite loop or if it's just because it takes so long.

The mesh is a product of decimate modifier. I've been using this workflow for years, and never had issues. I don't think invalid mesh is a dealbreaker for Smart UV project. If it is, then there's some small random chance that Decimate Modifier outputs invalid geometry.

> In #102843#1453070, @mano-wii wrote: > This object is corrupted. > See the `Mesh.validate()` log: > ``` > ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:719 BKE_mesh_validate_arrays:Polys 681551 and 681545 use same vertices (105825 > ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353645 > ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:721 BKE_mesh_validate_arrays: , 353648 > ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:723 BKE_mesh_validate_arrays: ), considering poly 681545 as invalid. > ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085779 is unused. > ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085780 is unused. > ERROR (bke.mesh): D:\BlenderDev\blender\source\blender\blenkernel\intern\mesh_validate.cc:763 BKE_mesh_validate_arrays:Loop 2085781 is unused. > ``` > > But even validating, the operation is taking a lot of time. > I don't know if it's an infinite loop or if it's just because it takes so long. The mesh is a product of decimate modifier. I've been using this workflow for years, and never had issues. I don't think invalid mesh is a dealbreaker for Smart UV project. If it is, then there's some small random chance that Decimate Modifier outputs invalid geometry.

Added subscriber: @Chris_Blackbourn

Added subscriber: @Chris_Blackbourn
Chris Blackbourn self-assigned this 2022-11-29 23:02:33 +01:00

Nice mesh!

Poking around a little, it appears to be a performance issue with the packer. I'm not seeing any obvious bugs other than the fact it's taking a very very long time.

For example:

  • Load UVFreeze, Edit mode, select all etc.
  • From the UV Editor, choose UV > Unwrap > Sphere Projection
  • From the UV Editor, choose UV > Unwrap > Pack Islands (Completes in a few seconds with only a few islands.)
  • From the UV Editor, choose UV > Unwrap > Cube Projection (Lots of disconnected islands.)
  • From the UV Editor, choose UV > Unwrap > Pack Islands (I'm still waiting for it to complete. *Update: Completed after 3 hours)

Will investigate further...

Nice mesh! Poking around a little, it *appears* to be a performance issue with the packer. I'm not seeing any obvious bugs other than the fact it's taking a very very long time. For example: * Load UVFreeze, Edit mode, select all etc. * From the UV Editor, choose `UV > Unwrap > Sphere Projection` * From the UV Editor, choose `UV > Unwrap > Pack Islands` (Completes in a few seconds with only a few islands.) * From the UV Editor, choose `UV > Unwrap > Cube Projection` (Lots of disconnected islands.) * From the UV Editor, choose `UV > Unwrap > Pack Islands` (I'm still waiting for it to complete. *Update: Completed after 3 hours) Will investigate further...
Author
Contributor

In #102843#1453331, @Chris_Blackbourn wrote:
Nice mesh!

Poking around a little, it appears to be a performance issue with the packer. I'm not seeing any obvious bugs other than the fact it's taking a very very long time.

For example:

  • Load UVFreeze, Edit mode, select all etc.
  • From the UV Editor, choose UV > Unwrap > Sphere Projection
  • From the UV Editor, choose UV > Unwrap > Pack Islands (Completes in a few seconds with only a few islands.)
  • From the UV Editor, choose UV > Unwrap > Cube Projection (Lots of disconnected islands.)
  • From the UV Editor, choose UV > Unwrap > Pack Islands (I'm still waiting for it to complete. *Update: Completed after 3 hours)

Will investigate further...

When I changed the second level displacement map to a lower frequency one, the packing also completed much faster. If this is indeed a packer issue, then shouldn't the Smart UV Project operator get a toggle to opt out of packing? I use UVPackmaster addon for packing anyway. I can't afford to wait 3 hours to pack a mesh with 800k triangles (which is not even considered high poly by today's standards), and the UVPackmaster addon packs it in about 20 seconds. But I need to be able to unwrap the mesh first in a non-manual manner, and for that, the Smart UV project is invaluable.

So I'd say either fix the performance bug or add option to opt out of packing step when performing Smart UV Project operation.

> In #102843#1453331, @Chris_Blackbourn wrote: > Nice mesh! > > Poking around a little, it *appears* to be a performance issue with the packer. I'm not seeing any obvious bugs other than the fact it's taking a very very long time. > > For example: > * Load UVFreeze, Edit mode, select all etc. > * From the UV Editor, choose `UV > Unwrap > Sphere Projection` > * From the UV Editor, choose `UV > Unwrap > Pack Islands` (Completes in a few seconds with only a few islands.) > * From the UV Editor, choose `UV > Unwrap > Cube Projection` (Lots of disconnected islands.) > * From the UV Editor, choose `UV > Unwrap > Pack Islands` (I'm still waiting for it to complete. *Update: Completed after 3 hours) > > Will investigate further... When I changed the second level displacement map to a lower frequency one, the packing also completed much faster. If this is indeed a packer issue, then shouldn't the Smart UV Project operator get a toggle to opt out of packing? I use UVPackmaster addon for packing anyway. I can't afford to wait 3 hours to pack a mesh with 800k triangles (which is not even considered high poly by today's standards), and the UVPackmaster addon packs it in about 20 seconds. But I need to be able to unwrap the mesh first in a non-manual manner, and for that, the Smart UV project is invaluable. So I'd say either fix the performance bug or add option to opt out of packing step when performing Smart UV Project operation.

@Chris_Blackbourn, are you working on a fix? If so, can the bug be confirmed?

In #102843#1453468, @Rawalanche wrote:
(...)
So I'd say either fix the performance bug or add option to opt out of packing step when performing Smart UV Project operation.

While we do continue to work on improving performance in general, potential performance improvements are not handled as bug reports :\

@Chris_Blackbourn, are you working on a fix? If so, can the bug be confirmed? > In #102843#1453468, @Rawalanche wrote: >(...) > So I'd say either fix the performance bug or add option to opt out of packing step when performing Smart UV Project operation. While we do continue to work on improving performance in general, potential performance improvements are not handled as bug reports :\
Author
Contributor

In #102843#1453627, @mano-wii wrote:
@Chris_Blackbourn, are you working on a fix? If so, can the bug be confirmed?

In #102843#1453468, @Rawalanche wrote:
(...)
So I'd say either fix the performance bug or add option to opt out of packing step when performing Smart UV Project operation.

While we do continue to work on improving performance in general, potential performance improvements are not handled as bug reports :\

What we are talking about here is a unwrap of 800k triangle mesh taking 3+ hours. Let's say for example that adding a modifier to a default cube would suddenly take 50 minutes instead of 5 milliseconds. Would you say that it's a performance improvement, not a bug?

> In #102843#1453627, @mano-wii wrote: > @Chris_Blackbourn, are you working on a fix? If so, can the bug be confirmed? > >> In #102843#1453468, @Rawalanche wrote: >>(...) >> So I'd say either fix the performance bug or add option to opt out of packing step when performing Smart UV Project operation. > While we do continue to work on improving performance in general, potential performance improvements are not handled as bug reports :\ What we are talking about here is a unwrap of 800k triangle mesh taking 3+ hours. Let's say for example that adding a modifier to a default cube would suddenly take 50 minutes instead of 5 milliseconds. Would you say that it's a performance improvement, not a bug?
Contributor

Added subscriber: @Raimund58

Added subscriber: @Raimund58

To add a bit of context, it's not the triangle count so much as the number of islands. With the cube projection, there's 100k+ UV Islands, and yeah, that's going to take a long time with the current packer.

In terms of fixes, I need to do a bit more investigation. I have a potential "quick fix" on my machine, but am hesitant to check it in if it will make it harder to get even better packing in future versions.

Is it okay to leave this one hanging for a little bit until I know more?

To add a bit of context, it's not the triangle count so much as the number of islands. With the cube projection, there's 100k+ UV Islands, and yeah, that's going to take a long time with the current packer. In terms of fixes, I need to do a bit more investigation. I have a potential "quick fix" on my machine, but am hesitant to check it in if it will make it harder to get even better packing in future versions. Is it okay to leave this one hanging for a little bit until I know more?

Added subscriber: @GeorgiaPacific

Added subscriber: @GeorgiaPacific
Author
Contributor

In #102843#1453863, @Chris_Blackbourn wrote:
To add a bit of context, it's not the triangle count so much as the number of islands. With the cube projection, there's 100k+ UV Islands, and yeah, that's going to take a long time with the current packer.

In terms of fixes, I need to do a bit more investigation. I have a potential "quick fix" on my machine, but am hesitant to check it in if it will make it harder to get even better packing in future versions.

Is it okay to leave this one hanging for a little bit until I know more?

Wouldn't it actually be possible to just introduce new checkbox to Smart UV Project operator called "Pack UVs", and enabled by default? So that users could turn it off, if they intend to use 3rd party packing solution? I mean even if you manage to make the packing step 100x faster, if it used to take 100 minutes to finish, it will still take additional minute of waste for anyone who wants to do the packing themselves. No time wasted is IMO still better than less time wasted.

> In #102843#1453863, @Chris_Blackbourn wrote: > To add a bit of context, it's not the triangle count so much as the number of islands. With the cube projection, there's 100k+ UV Islands, and yeah, that's going to take a long time with the current packer. > > In terms of fixes, I need to do a bit more investigation. I have a potential "quick fix" on my machine, but am hesitant to check it in if it will make it harder to get even better packing in future versions. > > Is it okay to leave this one hanging for a little bit until I know more? Wouldn't it actually be possible to just introduce new checkbox to Smart UV Project operator called "Pack UVs", and enabled by default? So that users could turn it off, if they intend to use 3rd party packing solution? I mean even if you manage to make the packing step 100x faster, if it used to take 100 minutes to finish, it will still take additional minute of waste for anyone who wants to do the packing themselves. No time wasted is IMO still better than less time wasted.

Wouldn't it actually be possible to just introduce (a) new checkbox to Smart UV Project operator called "Pack UVs", and enabled by default?

In principle, "yes", it's possible to just add a new checkbox.

In practice, all of the UV operators, Smart UV Project, Cube projection, Cylinder Projection, Sphere Projection, plus the geometry nodes version, as well as "Project From View" and even the "Add Simple UVs" which are used in texture painting are all interconnected.

Changing any one of them has impacts on all of the others.

Not just from a coding perspective, but also from a documentation POV, testing, as well as user expectation, and of course regressions over time such as forwards and backwards compatibility.

The roadmap is indeed to add a "Don't Pack" option to the Smart UV Project operator, along with other packing options. But it'll probably be a drop down choosing from a list rather than a checkbox, and it's going to take a little bit of time...

> Wouldn't it actually be possible to just introduce (a) new checkbox to Smart UV Project operator called "Pack UVs", and enabled by default? In principle, "yes", it's possible to just add a new checkbox. In practice, all of the UV operators, Smart UV Project, Cube projection, Cylinder Projection, Sphere Projection, plus the geometry nodes version, as well as "Project From View" and even the "Add Simple UVs" which are used in texture painting are all interconnected. Changing any one of them has impacts on all of the others. Not just from a coding perspective, but also from a documentation POV, testing, as well as user expectation, and of course regressions over time such as forwards and backwards compatibility. The roadmap is indeed to add a "Don't Pack" option to the Smart UV Project operator, along with other packing options. But it'll probably be a drop down choosing from a list rather than a checkbox, and it's going to take a little bit of time...

I mean even if you manage to make the packing step 100x faster, if it used to take 100 minutes to finish, it will still take additional minute of waste for anyone who wants to do the packing themselves.

(technical) The current packing is worse than O(N^3), so increasing the island count from 1000 -> 10,000 increases the packing time by a factor of 101010 = 1000 slower.

(technical) The new packing code will be O(N log N), so increasing the island count from 1000 -> 10,000 increases packing time by a factor of ~14.

i.e. The new packer should run faster than the unwrapping.

> I mean even if you manage to make the packing step 100x faster, if it used to take 100 minutes to finish, it will still take additional minute of waste for anyone who wants to do the packing themselves. (technical) The current packing is worse than `O(N^3)`, so increasing the island count from 1000 -> 10,000 increases the packing time by a factor of 10*10*10 = 1000 slower. (technical) The new packing code will be `O(N log N)`, so increasing the island count from 1000 -> 10,000 increases packing time by a factor of ~14. i.e. The new packer should run faster than the unwrapping.
Philipp Oeser removed the
Interest
Modeling
label 2023-02-09 15:27:09 +01:00

The PR #105393 adds a new UV Packing strategy, the "Alpaca".

It runs in O(n log n) performance, which means the updated packer is faster than the UV Unwrapper.

For example, on a release build, "UVFreeze.blend" used to take ~3 hours on my machine to Pack Islands.

Now, on a debug build, Pack Islands on UVFreeze.blend takes around 5 seconds:

image

This is a drop-in replacement. The largest 1024 islands are still packed using the exact same "box_pack" strategy. Only the smaller (16312 - 1024) = 14288 islands are packed using the "Alpaca" strategy.

The PR #105393 adds a new UV Packing strategy, the "Alpaca". It runs in O(n log n) performance, which means the updated packer is faster than the UV Unwrapper. For example, on a release build, "UVFreeze.blend" used to take ~3 hours on my machine to Pack Islands. Now, on a debug build, Pack Islands on UVFreeze.blend takes around 5 seconds: ![image](/attachments/d34d5f23-4247-48c6-a16e-d343acd48cc1) This is a drop-in replacement. The largest 1024 islands are still packed using the exact same "box_pack" strategy. Only the smaller (16312 - 1024) = 14288 islands are packed using the "Alpaca" strategy.
532 KiB
Author
Contributor

This is great, but will this ever make it into the main branch?

This is great, but will this ever make it into the main branch?
Member

This is great, but will this ever make it into the main branch?

@Rawalanche - best is to just follow the activity on that PR and you will see lots of work and discussion over the last few days. #105393

> This is great, but will this ever make it into the main branch? @Rawalanche - best is to just follow the activity on that PR and you will see lots of work and discussion over the last few days. https://projects.blender.org/blender/blender/pulls/105393
Blender Bot added
Status
Resolved
and removed
Status
Needs Info from Developers
labels 2023-03-08 08:41:55 +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
6 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#102843
No description provided.