Blender 4.0 creates many invalid materials, corrupts file, Eevee crashes #114428

Closed
opened 2023-11-02 20:46:17 +01:00 by Josef-Nilsen · 12 comments

System Information
Operating system: macOS 14
Graphics card: M1 (Metal, GPU-only)

Blender Version
Broken: f6c52849b5 (would be nice if this could be copied from the splash screen)
Worked: Don't know

Short description of error
When assigning a new material to some meshes (not all), Blender creates hundreds of empty/invalid materials. Possibly one per face? This increases the file size and causes incorrect rendering (both the default/no material and the set material). It's impossible to remove these materials with the material cleanup (Material utilities -> Clean slots only gives me a Python stack trace).

Exact steps for others to reproduce the error
Open the file, there is a "Bad" and a "Good" object. A material "Feet" has been assigned to the good object. Try assigning it to the bad object and it will create many empty materials. I once managed to solve it by recalculating the outer normals, which sometimes but not always works, so I suspect it could be related to that?

This event somehow corrupts the file, so switching over to to the Material Preview-view, after this has happened, even after it has been remedied, causes Eevee to crash as it's populating the materials cache.

I'm a newbie so I could be doing something stupid, but it doesn't seem like the application should segfault at least...

Crash report attached along with the example.

**System Information** Operating system: macOS 14 Graphics card: M1 (Metal, GPU-only) **Blender Version** Broken: f6c52849b502 (would be nice if this could be copied from the splash screen) Worked: Don't know **Short description of error** When assigning a new material to some meshes (not all), Blender creates hundreds of empty/invalid materials. Possibly one per face? This increases the file size and causes incorrect rendering (both the default/no material and the set material). It's impossible to remove these materials with the material cleanup (Material utilities -> Clean slots only gives me a Python stack trace). **Exact steps for others to reproduce the error** Open the file, there is a "Bad" and a "Good" object. A material "Feet" has been assigned to the good object. Try assigning it to the bad object and it will create many empty materials. I once managed to solve it by recalculating the outer normals, which sometimes but not always works, so I suspect it could be related to that? This event somehow corrupts the file, so switching over to to the Material Preview-view, after this has happened, even after it has been remedied, causes Eevee to crash as it's populating the materials cache. I'm a newbie so I could be doing something stupid, but it doesn't seem like the application should segfault at least... Crash report attached along with the example.
Josef-Nilsen added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-11-02 20:46:18 +01:00
Iliya Katushenock added the
Interest
EEVEE & Viewport
label 2023-11-03 08:48:23 +01:00
Member

We have corrupted material indices here

image

These can easily be corrected:

  • open a Python Colsole
  • select the Bad object
  • run C.active_object.data.validate_material_indices()

Now the question is: how can this corruption be reproduced?
How has the mesh been created? Was this imported (which importer)? Was this modelled with blenders tools (which)?
Please try to find ways to reproduce (otherwise we cannot continue with this report)

We have corrupted material indices here ![image](/attachments/70c42f16-19e6-4488-8f84-d4dc9e6316c0) These can easily be corrected: - open a Python Colsole - select the `Bad` object - run `C.active_object.data.validate_material_indices()` Now the question is: how can this corruption be reproduced? How has the mesh been created? Was this imported (which importer)? Was this modelled with blenders tools (which)? Please try to find ways to reproduce (otherwise we cannot continue with this report)
Philipp Oeser added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2023-11-03 10:13:59 +01:00
Member

(would be nice if this could be copied from the splash screen)

Help > Report a Bug 🙂

I can confirm that extra materials slots are generated but unable to identify the reason.

> (would be nice if this could be copied from the splash screen) `Help > Report a Bug` 🙂 I can confirm that extra materials slots are generated but unable to identify the reason.
Member

We have corrupted material indices here

oh, nice findings. I did not consider to check the spreadsheet 😅

> We have corrupted material indices here oh, nice findings. I did not consider to check the spreadsheet 😅
Author

I created the geometries in Blender from scratch, with a combination of adjustments in edit mode (manual + bevel), and two boolean difference modifiers. I will try to reproduce...

I created the geometries in Blender from scratch, with a combination of adjustments in edit mode (manual + bevel), and two boolean difference modifiers. I will try to reproduce...
Author

We have corrupted material indices here

These can easily be corrected:

  • open a Python Colsole
  • select the Bad object
  • run C.active_object.data.validate_material_indices()

I have tried for about 30 minutes to reproduce the issue, but it seems non-trivial. I could spend more time, but I'm not sure that the corruption you mention specifically is the cause, although I don't doubt that there is some form of corruption.

Start by running validate_material_indices, the output returns True, and ensure that it worked in the spreadsheet. So far so good. Both the 3D printing toolbox and the spreadsheet now indicates that the geometry is clean, as far as I can understand. Go back to the Layout view and assign the Feet material, and the problem persists.

I tried to rule out the material itself being the cause, by creating a new material and assigning that, but the issue persists nonetheless.

I suppose it could also be argued that if I did something stupid in edit mode, the fallback could still be more graceful than a Blender segfault, i.e. even if there isn't a clear solution to the problem, one might consider mitigating its consequences with some form of error handling perhaps. This seems Eevee specific however, as Cycles does not segfault, but the Eevee segfault brings all of Blender down along with it.

> We have corrupted material indices here > > These can easily be corrected: > - open a Python Colsole > - select the `Bad` object > - run `C.active_object.data.validate_material_indices()` I have tried for about 30 minutes to reproduce the issue, but it seems non-trivial. I could spend more time, but I'm not sure that the corruption you mention specifically is the cause, although I don't doubt that there is some form of corruption. Start by running `validate_material_indices`, the output returns `True`, and ensure that it worked in the spreadsheet. So far so good. Both the 3D printing toolbox and the spreadsheet now indicates that the geometry is clean, as far as I can understand. Go back to the Layout view and assign the `Feet` material, and the problem persists. I tried to rule out the material itself being the cause, by creating a new material and assigning that, but the issue persists nonetheless. I suppose it could also be argued that if I did something stupid in edit mode, the fallback could still be more graceful than a Blender segfault, i.e. even if there isn't a clear solution to the problem, one might consider mitigating its consequences with some form of error handling perhaps. This seems Eevee specific however, as Cycles does not segfault, but the Eevee segfault brings all of Blender down along with it.
Philipp Oeser added
Status
Needs Triage
and removed
Status
Needs Information from User
labels 2023-11-03 16:25:44 +01:00
Member

OK, can confirm that doing C.active_object.data.validate_material_indices() cleans up the indices, but assigning the material creates additional material slots.

It would still be good to know how we got to the corrupted state, but cleaning up the indices should really give us a clean plate.
Will put on my desk to investigate more later...

OK, can confirm that doing `C.active_object.data.validate_material_indices()` cleans up the indices, but assigning the material creates additional material slots. It would still be good to know how we got to the corrupted state, but cleaning up the indices should really give us a clean plate. Will put on my desk to investigate more later...
Philipp Oeser self-assigned this 2023-11-06 10:14:25 +01:00
Philipp Oeser added
Status
Confirmed
Module
Modeling
and removed
Status
Needs Triage
labels 2023-11-06 10:14:38 +01:00
Author

I will let you know if it happens again, now that I'm aware I'll be able to detect it earlier and more easily trace back to the operation causing it. Just curious: after assigning the material, causing the extra material slots to be added, can you use Eevee in the viewport or does Blender crash?

I will let you know if it happens again, now that I'm aware I'll be able to detect it earlier and more easily trace back to the operation causing it. Just curious: after assigning the material, causing the extra material slots to be added, can you use Eevee in the viewport or does Blender crash?
Member

Eevee doesnt crash for me

but cleaning up the indices should really give us a clean plate.

agree

Eevee doesnt crash for me > but cleaning up the indices should really give us a clean plate. agree
Member

Btw. as a workaround you can use https://docs.blender.org/manual/en/4.1/scene_layout/object/editing/cleanup.html#remove-unused-material-slots to get rid of the unwanted material slots

Btw. as a workaround you can use https://docs.blender.org/manual/en/4.1/scene_layout/object/editing/cleanup.html#remove-unused-material-slots to get rid of the unwanted material slots
Author

That didn't work for me either once the slots are there, like I wrote in my initial post:

Material utilities -> Clean slots only gives me a Python stack trace

But one thing that does work for me, is to create a new material for "Bad" rather than assigning a material. Then you can assign another material...

That didn't work for me either once the slots are there, like I wrote in my initial post: > Material utilities -> Clean slots only gives me a Python stack trace But one thing that does work for me, is to create a new material for "Bad" rather than assigning a material. Then you can assign another material...
Member

Btw. as a workaround you can use https://docs.blender.org/manual/en/4.1/scene_layout/object/editing/cleanup.html#remove-unused-material-slots to get rid of the unwanted material slots

OR: simply type C.active_object.active_material_index = 0 before assigning the material
(when opening the file, C.active_object.active_material_index is 19976 ... )

> Btw. as a workaround you can use https://docs.blender.org/manual/en/4.1/scene_layout/object/editing/cleanup.html#remove-unused-material-slots to get rid of the unwanted material slots OR: simply type `C.active_object.active_material_index = 0` before assigning the material (when opening the file, C.active_object.active_material_index is 19976 ... )
Member

It is actually very easy to break:

From the default startup cube:

  • type C.active_object.active_material_index = 100
  • assign a material
  • 100 material slots are created (the first 99 empty), material is assigned to the 100th slot

I find this quite questionable behavior of setting the active_material_index (this should probably be clamped to the number of available slots?)

It is actually very easy to break: From the default startup cube: - type `C.active_object.active_material_index = 100` - assign a material - 100 material slots are created (the first 99 empty), material is assigned to the 100th slot I find this quite questionable behavior of setting the `active_material_index` (this should probably be clamped to the number of available slots?)
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-04-12 17:35:38 +02: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
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#114428
No description provided.