calling obj.data.materials.clear() on an object with 2+ materials in lookdev or rendered(eevee) shading crashes Blender #67999
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#67999
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Linux-4.13.10-041310-generic-x86_64-with-debian-stretch-sid 64 Bits
Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 390.67
Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash:
f6cb5f5449
,Also Broken: version: 2.81 (sub 0), branch: master, commit date: 2019-07-30 20:50, hash:
5359b7a033
Short description of error
Have object with 2 or more materials applied. Be in lookdev or rendered shading(using Eevee).
Use
obj.data.materials.clear()
in the console or from a script to remove materials and slots. Blender crashes.I've had sb. else mention it takes more than 2 materials for him, but for me 2 are sufficient, and clearing them crashes Blender every time.
obj.data.matrials.clear()_crashes_blender_in_eevee_shading.blend
Exact steps for others to reproduce the error
C.active_object.data.materials.clear()
in the python console and hit return, otherwise it's already typed out and you can just hit returnAdded subscriber: @MACHIN3
calling obj.data.materials.clear() on an object with 2+ materials in lookedev or rendered(eevee) shading crashes Blenderto calling obj.data.materials.clear() on an object with 2+ materials in lookdev or rendered(eevee) shading crashes BlenderAdded subscriber: @dr.sybren
I can confirm this crash on current master (
03be31e817
). In debug mode it fails an assertion, showing that there is a difference between the number of material slots on the mesh and the object:This issue was referenced by
92a3995c6d
Changed status from 'Open' to: 'Resolved'
Changed status from 'Resolved' to: 'Open'
I'm opening this one again, because the issue seems to have re-appeared in
cb7ead2e3b
. Seems like it's - in my case at least - for 3+ Materials now, so make sure to use the cube on the right in the example blend above.Added subscriber: @brecht
The root cause of the crash is that something is allowed via Python that we never do from C. The
Mesh.materials.clear()
function will remove all the material slots from the mesh, but it keeps the polygon material indices (mpoly->mat_nr
) intact. The drawing code then usesmpoly->mat_nr
to index into the material slots, which crashes because they aren't there.The crash is resolved by passing
Mesh.materials.clear(update_data=True)
. From C we always passupdate_data=true
to the underlyingBKE_material_clear_id()
function, as that updates the polygon material and keeps things in sync. My proposal is to remove theupdate_data
parameter altogether, both in C and Python, and always update the polygon material indices. This would then have the same effect as removing the material slots one by one in the UI (that also removes the poly assignment). I do want to discuss this with @brecht though.I've updated
extract_tris_init()
(the function that crashes) to clamp the material indices to the number of material slots, to see what would be drawn in that case. It's clear that this isn't supported by the rest of the draw code:(left/right = before/after material removal)
Thanks for looking into this! I've also occasionally seen those vanishing faces when it didn't crash. Also, wasn't aware of the update_data argument, either.
This issue was referenced by
c70f975d5c
Changed status from 'Open' to: 'Resolved'