Regression: Box Hide occasionally causes artifacts #121107

Open
opened 2024-04-26 07:47:21 +02:00 by Sean Kim · 7 comments
Member

System Information
Operating system: Linux-6.8.6-200.fc39.x86_64-x86_64-with-glibc2.38 64 Bits, X11 UI
Graphics card: NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 550.67

Blender Version
Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-04-25 19:53, hash: 095d37c186b6
Worked: version: 3.6.11, branch: blender-v3.6-release, commit date: 2024-04-15 07:27, hash: 0d97ea8e3dc2

Also tested and verified broken behavior on 4.1.1

Short description of error
Rapid Box Hide actions on a dense mesh can sometimes cause weird artifacts

3.6.11 4.2
3.6.11_hide_glitch.gif 4.2_hide_glitch.gif

Exact steps for others to reproduce the error

  1. Open attached blend file
  2. Switch to Box Hide
  3. Repeatedly perform Box Hide action on mesh

With a developer build, I get an assert crash on a MutableSpan operator[] call.

BLI_assert failed: source/blender/blenlib/BLI_span.hh:578, operator[](), at 'index < size_'

But the rest of the stacktrace provides nothing readable. I noticed that running blender with only a single thread seems to prevent the issue from occurring.

**System Information** Operating system: Linux-6.8.6-200.fc39.x86_64-x86_64-with-glibc2.38 64 Bits, X11 UI Graphics card: NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 550.67 **Blender Version** Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-04-25 19:53, hash: `095d37c186b6` Worked: version: 3.6.11, branch: blender-v3.6-release, commit date: 2024-04-15 07:27, hash: `0d97ea8e3dc2` Also tested and verified broken behavior on 4.1.1 **Short description of error** Rapid *Box Hide* actions on a dense mesh can sometimes cause weird artifacts | 3.6.11 | 4.2 | | --- | --- | | ![3.6.11_hide_glitch.gif](/attachments/a356d962-a893-4194-84bf-9056eff3ae69) | ![4.2_hide_glitch.gif](/attachments/218a3a91-cc75-44f8-9ca8-6d82cd1cc426) | **Exact steps for others to reproduce the error** 1. Open attached blend file 2. Switch to *Box Hide* 3. Repeatedly perform Box Hide action on mesh --- With a developer build, I get an assert crash on a `MutableSpan` `operator[]` call. ``` BLI_assert failed: source/blender/blenlib/BLI_span.hh:578, operator[](), at 'index < size_' ``` But the rest of the stacktrace provides nothing readable. I noticed that running blender with only a single thread seems to prevent the issue from occurring.
Sean Kim added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-04-26 07:47:22 +02:00
Author
Member

Running with a debugger gets this particular block as triggering the assert:

  vert_hide_update(*object, nodes, [&](const Span<int> verts, MutableSpan<bool> hide) {
    for (const int i : verts.index_range()) {
      if (gesture::is_affected(gesture_data, positions[verts[i]], normals[verts[i]])) {
        hide[i] = value;
      }
    }
  });

on hide[i] = value

Running with a debugger gets this particular block as triggering the assert: ```Cpp vert_hide_update(*object, nodes, [&](const Span<int> verts, MutableSpan<bool> hide) { for (const int i : verts.index_range()) { if (gesture::is_affected(gesture_data, positions[verts[i]], normals[verts[i]])) { hide[i] = value; } } }); ``` on `hide[i] = value`
Author
Member

Adding this assert into paint_hide.cc in vert_hide_update shows the problem I think.

  threading::EnumerableThreadSpecific<Vector<bool>> all_new_hide;
  threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
    Vector<bool> &new_hide = all_new_hide.local();
    for (PBVHNode *node : nodes.slice(range)) {
      const Span<int> verts = bke::pbvh::node_unique_verts(*node);
      new_hide.reinitialize(verts.size());
      array_utils::gather(hide_vert.span.as_span(), verts, new_hide.as_mutable_span());
      BLI_assert(verts.size() == new_hide.size());
      calc_hide(verts, new_hide);

I suspect that the usage of the the thread local vector in this way is not thread-safe for cases where there are fewer threads than PBVH nodes.

Adding this assert into `paint_hide.cc` in `vert_hide_update` shows the problem I think. ```Cpp threading::EnumerableThreadSpecific<Vector<bool>> all_new_hide; threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { Vector<bool> &new_hide = all_new_hide.local(); for (PBVHNode *node : nodes.slice(range)) { const Span<int> verts = bke::pbvh::node_unique_verts(*node); new_hide.reinitialize(verts.size()); array_utils::gather(hide_vert.span.as_span(), verts, new_hide.as_mutable_span()); BLI_assert(verts.size() == new_hide.size()); calc_hide(verts, new_hide); ``` I suspect that the usage of the the thread local vector in this way is not thread-safe for cases where there are fewer threads than PBVH nodes.
Author
Member

Adding this

    for (PBVHNode *node : nodes.slice(range)) {
      std::stringstream msg;
      msg << std::this_thread::get_id() << "\t" << node << "\t" << &new_hide << std::endl;
      std::cout << msg.str();

Shows that multiple different nodes are using the same thread id and therefore the same Vector<bool> reference.

A dump of the data is in the attached sorted_dump.tsv

Adding this ```Cpp for (PBVHNode *node : nodes.slice(range)) { std::stringstream msg; msg << std::this_thread::get_id() << "\t" << node << "\t" << &new_hide << std::endl; std::cout << msg.str(); ``` Shows that multiple different nodes are using the same thread id and ~~therefore~~ the same `Vector<bool>` reference. A dump of the data is in the attached `sorted_dump.tsv`
Member

Unable to confirm the assert (neither artifacts) in debug build: 71e7775bcbf4f53ffeade9b34f6e6a8c6946e0e0

Unable to confirm the assert (neither artifacts) in debug build: `71e7775bcbf4f53ffeade9b34f6e6a8c6946e0e0`
Iliya Katushenock added the
Interest
Sculpt, Paint & Texture
label 2024-04-26 13:38:36 +02:00
Iliya Katushenock changed title from Box Hide occasionally causes artifacts to Regression: Box Hide occasionally causes artifacts 2024-04-26 13:38:43 +02:00
Member

Also cannot repro here

**System Information**
Operating system: Linux-6.8.6-200.fc39.x86_64-x86_64-with-glibc2.38 64 Bits, X11 UI
Graphics card: NVIDIA GeForce RTX 3080 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 550.67
version: version: 4.2.0 Alpha, branch: main, commit date: 2024-04-29 02:32, hash: `3a5389d5abe0`

@Sean-Kim : maybe you can try bisecting this yourself?

Also cannot repro here ``` **System Information** Operating system: Linux-6.8.6-200.fc39.x86_64-x86_64-with-glibc2.38 64 Bits, X11 UI Graphics card: NVIDIA GeForce RTX 3080 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 550.67 version: version: 4.2.0 Alpha, branch: main, commit date: 2024-04-29 02:32, hash: `3a5389d5abe0` ``` @Sean-Kim : maybe you can try bisecting this yourself?
Philipp Oeser added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2024-04-30 14:05:37 +02:00
Author
Member

@lichtwerk - Sure, I can bisect this. It's probably 4e66769ec0, but I'll spend some time verifying that assumption.

@lichtwerk - Sure, I can bisect this. It's probably 4e66769ec09461384af48b0bfdafc28884f01d19, but I'll spend some time verifying that assumption.
Author
Member

I'm not having much luck actually building that revision or surrounding ones with either a regular or lite build. In the recent sculpt module meeting, @HooglyBoogly said he would start looking at a fix for this, so I think it's probably just fine to remove the status tag on this altogether.

I'm not having much luck actually building that revision or surrounding ones with either a regular or lite build. In the recent sculpt module meeting, @HooglyBoogly said he would start looking at a fix for this, so I think it's probably just fine to remove the status tag on this altogether.
Hans Goudey self-assigned this 2024-05-03 00:06:57 +02:00
Philipp Oeser removed the
Status
Needs Information from User
label 2024-05-03 09:35:36 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
Asset Browser Project
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
3 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#121107
No description provided.