Crash after manipulating Object.hide_viewport while iterating Collection.all_objects #62406
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
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#62406
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: Win10
Graphics card: nVidia 1070
Blender Version
Broken: 2.80 (sub 47), branch: master, commit date: 2019-03-09 16:19, hash:
4041249943
Worked: A February build was fine, but I don't know the hash :-/
Short description of error
Running this script fragment will cause a crash inside the Collection.all_objects code path -- one of the 2 hide_viewport lines seems to trigger it:
Exact steps for others to reproduce the error
hide_viewport-crash.blend
Added subscriber: @deadpin
#89576 was marked as duplicate of this issue
Added subscribers: @mont29, @ZedDB
Backtrace:
@mont29 feel free to reassign if this is not for you.
Changed status from 'Open' to: 'Archived'
This is expected actually… though rather unfortunates. Here is what happens:
collection.all_objects
uses a temp internal cache.object.hide_viewport
callsBKE_main_collection_sync_remap()
has part of its update process.BKE_main_collection_sync_remap()
function invalidates all cahces of all collections, including the one we are looping on.As usual, you should avoid iterating over data when modifying data, you never know when you will end up re-allocating things and hence accessing bad memory, this works instead:
print('Processing object : ', ob_name)
obj = bpy.data.objects[ob_name]
prev_hide_viewport = obj.hide_viewport
obj.hide_viewport = False
obj.select_set(False)
obj.hide_viewport = prev_hide_viewport
Note that this is not really considered as a nice behavior, and some enhancements/refinements are possible here, but this is not a bug either. Thanks for the report anyway.
Aaahhhh such a minefield :) Thanks for looking and spending time on this; I'll have to modify several of my scripts to account for this... I only thought modifying the collection itself, not items within it, would be bad -- but I guess there's a hidden manipulation here.
Can this be added to https://docs.blender.org/api/blender2.8/info_gotcha.html -- Namely "Even modifying items within certain collections (even if the collection itself does not change) should be avoided" as I can't find it there.
Done, thanks (will appear on next API doc rebuild).
Added subscribers: @barakooda, @PratikPB2123, @lichtwerk
Added subscriber: @kursadk
It will be probably very helpful to include example working code from @mont29 in https://docs.blender.org/api/blender2.8/info_gotcha.html