[2.77a - 2.78] Removal of custom icon previews during add-on unregister crashes Blender #49829

Closed
opened 2016-10-24 19:25:12 +02:00 by notallowed · 14 comments

System Information
Linux Mint 18, GTX 660 Ti

Blender Version
Broken: 2.77a.abf6f08; 2.78.4bb1e22

Short description of error
If any custom icon is currently visible in Blender window, then Blender crashes while add-on is being unregistred.

Exact steps for others to reproduce the error

  1. Install add-on from "previews_bug.zip" by copying "previews_addon.py" and "icons" folder to "scripts/addons" folder
  2. Once installed enable addon "Previews Example" in User Preferences
  3. In 3D View open Tool Shelf and select "Previews" tab. You should see 10 buttons with custom icons (all look the same
  4. Now open up User Preferences again and rapidly enable and disable this addon. Blender will crash soon.

ZIP file:

**System Information** Linux Mint 18, GTX 660 Ti **Blender Version** Broken: 2.77a.abf6f08; 2.78.4bb1e22 **Short description of error** If any custom icon is currently visible in Blender window, then Blender crashes while add-on is being unregistred. **Exact steps for others to reproduce the error** 1. Install add-on from "previews_bug.zip" by copying "previews_addon.py" and "icons" folder to "scripts/addons" folder 2. Once installed enable addon "Previews Example" in User Preferences 3. In 3D View open Tool Shelf and select "Previews" tab. You should see 10 buttons with custom icons (all look the same 4. Now open up User Preferences again and rapidly enable and disable this addon. Blender will crash soon. ZIP file: - previews_bug.zip: [previews_bug.zip](https://archive.blender.org/developer/F385855/previews_bug.zip)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @simon_lusenc

Added subscriber: @simon_lusenc

Added subscriber: @mont29

Added subscriber: @mont29
Bastien Montagne self-assigned this 2016-10-24 20:10:23 +02:00

Confirmed, think problem comes from deferred loading of previews from files…

Confirmed, think problem comes from deferred loading of previews from files…
Author

Happy to see I finally made proper bug report, which can be reproduced.

Btw I am also experiencing another problem with previews. That icons get randomly lost after some time (they simply don't show in UI anymore), is it possible to be tided to this or?

Happy to see I finally made proper bug report, which can be reproduced. Btw I am also experiencing another problem with previews. That icons get randomly lost after some time (they simply don't show in UI anymore), is it possible to be tided to this or?
Member

Added subscriber: @BrendonMurphy

Added subscriber: @BrendonMurphy
Member

hi, the addon here should be in it's own folder, not a single file with an icons folder dropped into blenders file structure.
my_folder/init.py /icons is the right structure.
for the correct way to use icons please see mesh_tinycad addon, I'm unable to reproduce this crash with mesh_tinycad
try this & let us know if it still crashes

hi, the addon here should be in it's own folder, not a single file with an icons folder dropped into blenders file structure. my_folder/__init__.py /icons is the right structure. for the correct way to use icons please see mesh_tinycad addon, I'm unable to reproduce this crash with mesh_tinycad try this & let us know if it still crashes

@BrendonMurphy afaict, your comparison is wrong, mesh-tiny-cad does not have any 'static' panel always visible, showing custom icons right? it’s only in 'Special' W menu?

Issue here is when you unregister an addon (i.e. remove its custom icons) while those custom icons are being lazily loaded by UI code (because this loading happens in a thread iirc, which means it can be using custom icons data while it’s being cleaned out), at least that what I’m guessing until I investigate properly the issue. ;)

@BrendonMurphy afaict, your comparison is wrong, mesh-tiny-cad does not have any 'static' panel always visible, showing custom icons right? it’s only in 'Special' W menu? Issue here is when you unregister an addon (i.e. remove its custom icons) **while those custom icons are being lazily loaded by UI code** (because this loading happens in a thread iirc, which means it can be using custom icons data while it’s being cleaned out), at least that what I’m guessing until I investigate properly the issue. ;)
Member

@mont29
tested the file & was able to reproduce only if I pressed reg/unreg the addon multiple times as fast as I could. pressing reg/unreg multiple times at a reasonable rate, say 0.5 second gap, the crash does not occur. I think what happens here is the Button Mashing is too quick for the addon to reload the custom icons.

I tested some other panel addons that use custom icons with no conclusion yet.

I just wonder is Button Mashing the reg/unreg of an addon usual use & expected use. ;)

@mont29 tested the file & was able to reproduce only if I pressed reg/unreg the addon multiple times as fast as I could. pressing reg/unreg multiple times at a reasonable rate, say 0.5 second gap, the crash does not occur. I think what happens here is the Button Mashing is too quick for the addon to reload the custom icons. I tested some other panel addons that use custom icons with no conclusion yet. I just wonder is Button Mashing the reg/unreg of an addon usual use & expected use. ;)
Author

@BrendonMurphy it depends on add-on and on how much and many custom icons are used and visible at the time of reg/unreg. I have add-on which has around 20 custom icons usages in tool shelf so I get to crash with that add-on quicker usually after 1-2 reg/unreg presses.

@BrendonMurphy it depends on add-on and on how much and many custom icons are used and visible at the time of reg/unreg. I have add-on which has around 20 custom icons usages in tool shelf so I get to crash with that add-on quicker usually after 1-2 reg/unreg presses.
Member

@simon_lusenc hi, sorry to be on your case here seemingly ;)
currently there is a delay when loading custom icons on first load.
I enable your test addon (in it's own folder using init.py), when I click the tab to open the panel the icons incrementally load. You can see it, they load one after the other taking maybe 1 second to populate the menu. From here they are loaded & switching tabs does not incur the "lag".
I'm thinking that the reg/unreg really quick beats this time, so blender tries to grab the icons & in the middle tries to grab them again, causing the crash.
This is prevented by taking your time & not pushing the current limitations,
I can easily reproduce this crash & also easily not crash here by not smashing the reg/unreg button.

Also I noticed in wazou's speedflow addon, which also has custom icons within a toolshelf panel, this is handled somewhat better. It has an option in addons preferences to display the custom icon panel. When addons preferences are saved as "use panel" the panel is on by default when you start blender, however if you reg/unreg the addon, the panel is not displayed until you re-activate it in the addons preferences.

To summarize, whilst there is an issue & a crash here, it's preventable.
i feel here the crash is some what forced by the user.
It's not usual behavior to enable/disable the same addon in fast succession. Don't do that ;)
The method used by wazou, whilst I tested, I did not examine the code, that said, it's impossible to reproduce this crash, using his code.

@simon_lusenc hi, sorry to be on your case here seemingly ;) currently there is a delay when loading custom icons on first load. I enable your test addon (in it's own folder using __init__.py), when I click the tab to open the panel the icons incrementally load. You can see it, they load one after the other taking maybe 1 second to populate the menu. From here they are loaded & switching tabs does not incur the "lag". I'm thinking that the reg/unreg really quick beats this time, so blender tries to grab the icons & in the middle tries to grab them again, causing the crash. This is prevented by taking your time & not pushing the current limitations, I can easily reproduce this crash & also easily not crash here by not smashing the reg/unreg button. Also I noticed in wazou's speedflow addon, which also has custom icons within a toolshelf panel, this is handled somewhat better. It has an option in addons preferences to display the custom icon panel. When addons preferences are saved as "use panel" the panel is on by default when you start blender, however if you reg/unreg the addon, the panel is not displayed until you re-activate it in the addons preferences. To summarize, whilst there is an issue & a crash here, it's preventable. i feel here the crash is some what forced by the user. It's not usual behavior to enable/disable the same addon in fast succession. Don't do that ;) The method used by wazou, whilst I tested, I did not examine the code, that said, it's impossible to reproduce this crash, using his code.

This issue was referenced by 5f0933f07a

This issue was referenced by 5f0933f07a548719a850d9cac01aae6709b9dc0b
Author

@BrendonMurphy Yep I know to that if I will slowly enable/disable addon that crash won't happen, but that's not really a solution :)
Well I myself went aroound this the way:
I am not removing previews at all on unregister (they are kept in module dictionary variable for reuse) and if user again enables add-on preview is still accessible and rather than creating whole previews again I just reload images. The only downside is that preview collection is never cleared until you close Blender, but shouldn't be noticeable problem for user.

Another solution popped up during writing this post, that on each register I could create new preview collection and once new collection is created and used by UI I can in peace delete old collection hopefully without a crash.

However I still think that this "bug" should be take care of at some point ;)

@BrendonMurphy Yep I know to that if I will slowly enable/disable addon that crash won't happen, but that's not really a solution :) Well I myself went aroound this the way: I am not removing previews at all on unregister (they are kept in module dictionary variable for reuse) and if user again enables add-on preview is still accessible and rather than creating whole previews again I just reload images. The only downside is that preview collection is never cleared until you close Blender, but shouldn't be noticeable problem for user. Another solution popped up during writing this post, that on each register I could create new preview collection and once new collection is created and used by UI I can in peace delete old collection hopefully without a crash. However I still think that this "bug" should be take care of at some point ;)

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
4 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#49829
No description provided.