Crash when appending object using callack from enum prop, followed by undo #82361

Closed
opened 2020-11-03 13:46:18 +01:00 by MACHIN3 · 10 comments

System Information
Operating system: Linux-4.15.0-117-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21

Blender Version
Broken: version: 2.90.1, branch: master, commit date: 2020-09-23 06:43, hash: 3e85bb34d0
Worked: 2.82

Short description of error
This is a follow-up to https://developer.blender.org/T80217

I'm using the update callback of an enum prop to append an object from an external blend file, then link it to the master collection.
This is a fairly standard procedure for addons using layout.template_icon_view() to "load assets".

In the previous report, it was suggested to not call an operator from the update callback to prevent crashes, if the user were to undo after such an "asset load".

This new report then avoids using an operator and instead uses a dedicated append_object_function().
Unfortunately the crash is still happening as soon as one does an undo.

As in the previous report, appending using layout.operator() works fine. All of this worked up until 2.82 and 2.83 was the first to crash.

If the suggestion now is to not do any database manipulation from update callbacks, then what is the recommended way to bring in external assets using template icon views? If this isn't possible anymore, than it seems this layout element is a lot less useful, and addons that have been building on this ability for years are now a serious cause of blender instability and potential for data loss.

append_obj_undo_crash_from_update_callback_of_enum_prop.zip

Exact steps for others to reproduce the error

  • Extract the above zip file and open append_obj_undo_crash_from_template_icon_view.blend
  • Run the script
  • In the 3d view sidebar, a new panel 'Append Object' appears under the Tool tab
  • In the Append Object panel, click on the thumbnail, and again on the blender icon inside
    • the append object op was called and a cube was appended to the scene
  • Undo
    • Blender should crash!!!
  • Start Blender again and run the script again
  • This time, run the append op using the button below the thumbnail, then undo again
    • Blender should not crash this time
**System Information** Operating system: Linux-4.15.0-117-generic-x86_64-with-debian-buster-sid 64 Bits Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21 **Blender Version** Broken: version: 2.90.1, branch: master, commit date: 2020-09-23 06:43, hash: `3e85bb34d0` Worked: 2.82 **Short description of error** This is a follow-up to https://developer.blender.org/T80217 I'm using the update callback of an enum prop to append an object from an external blend file, then link it to the master collection. This is a fairly standard procedure for addons using `layout.template_icon_view()` to "load assets". In the previous report, it was suggested to not call an operator from the update callback to prevent crashes, if the user were to undo after such an "asset load". This new report then avoids using an operator and instead uses a dedicated `append_object_function()`. Unfortunately the crash is still happening as soon as one does an undo. As in the previous report, appending using `layout.operator()` works fine. All of this worked up until 2.82 and 2.83 was the first to crash. If the suggestion now is to not do any database manipulation from update callbacks, then what is the recommended way to bring in external assets using template icon views? If this isn't possible anymore, than it seems this layout element is a lot less useful, and addons that have been building on this ability for years are now a serious cause of blender instability and potential for data loss. [append_obj_undo_crash_from_update_callback_of_enum_prop.zip](https://archive.blender.org/developer/F9180709/append_obj_undo_crash_from_update_callback_of_enum_prop.zip) **Exact steps for others to reproduce the error** * Extract the above zip file and open append_obj_undo_crash_from_template_icon_view.blend * Run the script * In the 3d view sidebar, a new panel 'Append Object' appears under the Tool tab * In the Append Object panel, click on the thumbnail, and again on the blender icon inside * the append object op was called and a cube was appended to the scene * Undo * Blender should crash!!! * Start Blender again and run the script again * This time, run the append op using the button below the thumbnail, then undo again * Blender should not crash this time
Author

Added subscriber: @MACHIN3

Added subscriber: @MACHIN3
Bastien Montagne was assigned by MACHIN3 2020-11-03 13:46:48 +01:00
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Please read through #81345 (ID user decrement error when removing object which is referred to with a PointerProperty) starting:

In #81345#1027338, @mont29 wrote:
... note that manipulating data-blocks from update callback as you do in your script is extremely discouraged, it will basically break undo/redo process, among other potential severe issues, see the API documentation .

Please read through #81345 (ID user decrement error when removing object which is referred to with a PointerProperty) starting: > In #81345#1027338, @mont29 wrote: > ... note that manipulating data-blocks from `update` callback as you do in your script is extremely discouraged, it will basically break undo/redo process, among other potential severe issues, see [the API documentation](https://docs.blender.org/api/master/info_gotcha.html#abusing-rna-property-callbacks) .

Added subscriber: @Pinnhead

Added subscriber: @Pinnhead

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.09

Blender Version
Broken: version: 2.90.1, branch: master, commit date: 2020-09-23 06:43, hash: 3e85bb34d0

Exactly the same behaviour.

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.09 **Blender Version** Broken: version: 2.90.1, branch: master, commit date: 2020-09-23 06:43, hash: `3e85bb34d0` Exactly the same behaviour.

Changed status from 'Needs Triage' to: 'Archived'

Changed status from 'Needs Triage' to: 'Archived'

In #82361#1047115, @lichtwerk wrote:
Please read through #81345 (ID user decrement error when removing object which is referred to with a PointerProperty) starting:

In #81345#1027338, @mont29 wrote:
... note that manipulating data-blocks from update callback as you do in your script is extremely discouraged, it will basically break undo/redo process, among other potential severe issues, see the API documentation .

Nuf said.

> In #82361#1047115, @lichtwerk wrote: > Please read through #81345 (ID user decrement error when removing object which is referred to with a PointerProperty) starting: > >> In #81345#1027338, @mont29 wrote: >> ... note that manipulating data-blocks from `update` callback as you do in your script is extremely discouraged, it will basically break undo/redo process, among other potential severe issues, see [the API documentation](https://docs.blender.org/api/master/info_gotcha.html#abusing-rna-property-callbacks) . Nuf said.
Author

Read all of this, still don't have a working solution to prevent Blender crashing when appending using the layout.template_icon_view() as the interface (followed by undo)

  1. Don't use an operator in update callbacks
  2. Use an operator when manipulating the database
    So, there's a problem now.

I've tried calling the op from a timer and it's still crashing, will report that separately.

To me this looks like it should be something that is supported by the API. It's a massively popular use case, and shouldn't crash.

Read all of this, still don't have a working solution to prevent Blender crashing when appending using the `layout.template_icon_view()` as the interface (followed by undo) 1. Don't use an operator in update callbacks 2. Use an operator when manipulating the database So, there's a problem now. I've tried calling the op from a timer and it's still crashing, will report that separately. To me this looks like it should be something that is supported by the API. It's a massively popular use case, and shouldn't crash.

Added subscriber: @pauanyu_blender

Added subscriber: @pauanyu_blender
Member

I guess you need a separate operator [not called by a timer] that you need to execute "by hand".
So you choose your icon, then execute the operator (e.g. by button).

Not the nicest thing in the world, but a compromise.

I guess you need a separate operator [not called by a timer] that you need to execute "by hand". So you choose your icon, then execute the operator (e.g. by button). Not the nicest thing in the world, but a compromise.
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
5 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#82361
No description provided.