Error registering addons disabled by Load Factory Settings (from preferences window) #67577

Closed
opened 2019-07-24 09:32:12 +02:00 by Ryan Inch · 22 comments
Member

System Information
Operating system: Arch Linux 64 bit
Graphics card: Nvidia 660m

Blender Version
Broken: 2.80rc2, 2.83 beta (c57f65c088)

Short description of error
Load Factory Settings resets addon preferences before addons have a chance to unregister

Exact steps for others to reproduce the error

  1. Enable the Collection Manager add-on.
  2. In the 3D Viewport, see that there are a bunch of crosses in the top-right corner.
  3. Load Factory Settings.
  4. See that in the 3D Viewport the crosses have not disappeared; the add-on was unsuccessfully unregistered.
  5. Try enable Collection Manager again, it will produce an error that a class is already registered.

During unregistering, this error occurs:

Exception in module unregister(): '/home/sybren/workspace/blender-git/build_linux/bin/2.83/scripts/addons/object_collection_manager/__init__.py'
Traceback (most recent call last):
  File "/home/sybren/workspace/blender-git/build_linux/bin/2.83/scripts/modules/addon_utils.py", line 434, in disable
    mod.unregister()
  File "/home/sybren/workspace/blender-git/build_linux/bin/2.83/scripts/addons/object_collection_manager/__init__.py", line 149, in unregister
    if bpy.context.preferences.addons[__package__].preferences.enable_qcd:
KeyError: 'bpy_prop_collection[key]: key "object_collection_manager" not found'
	addon_utils.reset_all unloading blender_cloud
**System Information** Operating system: Arch Linux 64 bit Graphics card: Nvidia 660m **Blender Version** Broken: 2.80rc2, 2.83 beta (c57f65c088) **Short description of error** Load Factory Settings resets addon preferences before addons have a chance to unregister **Exact steps for others to reproduce the error** 1. Enable the Collection Manager add-on. 2. In the 3D Viewport, see that there are a bunch of crosses in the top-right corner. 3. Load Factory Settings. 4. See that in the 3D Viewport the crosses have not disappeared; the add-on was unsuccessfully unregistered. 5. Try enable Collection Manager again, it will produce an error that a class is already registered. During unregistering, this error occurs: ``` Exception in module unregister(): '/home/sybren/workspace/blender-git/build_linux/bin/2.83/scripts/addons/object_collection_manager/__init__.py' Traceback (most recent call last): File "/home/sybren/workspace/blender-git/build_linux/bin/2.83/scripts/modules/addon_utils.py", line 434, in disable mod.unregister() File "/home/sybren/workspace/blender-git/build_linux/bin/2.83/scripts/addons/object_collection_manager/__init__.py", line 149, in unregister if bpy.context.preferences.addons[__package__].preferences.enable_qcd: KeyError: 'bpy_prop_collection[key]: key "object_collection_manager" not found' addon_utils.reset_all unloading blender_cloud ```
Author
Member

Added subscriber: @Imaginer

Added subscriber: @Imaginer

Added subscriber: @GavinScott

Added subscriber: @GavinScott

Happens on Windows as well. I get problems with some but not all addons. After enabling add-ons, then Loading Factory Settings the addons show as disabled but attempting to enable them results in various errors suggesting that the Load Factory Settings did not un-register them but did disable them.

Happens on Windows as well. I get problems with some but not all addons. After enabling add-ons, then Loading Factory Settings the addons show as disabled but attempting to enable them results in various errors suggesting that the Load Factory Settings did not un-register them but did disable them.

Workaround is to exit Blender and start with --factory-startup

Workaround is to exit Blender and start with --factory-startup
Germano Cavalcante changed title from Load Factory Settings resets addon preferences to early to Error registering addons disabled by Load Factory Settings (from preferences window) 2019-07-24 17:45:49 +02:00
Campbell Barton was assigned by Germano Cavalcante 2019-07-24 17:45:49 +02:00
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:33:34 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sybren A. Stüvel self-assigned this 2020-01-27 18:03:32 +01:00

I cannot reproduce this with the latest Blender release (2.81a), so this appears to have been fixed already.
If the problem is still there with the latest Blender version, please let us know in a comment, including how to reproduce the issue with that version.

I cannot reproduce this with the latest Blender release (2.81a), so this appears to have been fixed already. If the problem is still there with the latest Blender version, please let us know in a comment, including how to reproduce the issue with that version.
Author
Member

Sorry for the late reply, but I can confirm the underlying issue here hasn't been fixed. The reason Magic UV works now is because the code trying to access the preferences in the unregister function wasn't actually needed and was removed with commit: blender/blender-addons@ba7e0de977. This bug can now be reproduced with the object_collection_manager addon (mine).

Sorry for the late reply, but I can confirm the underlying issue here hasn't been fixed. The reason Magic UV works now is because the code trying to access the preferences in the unregister function wasn't actually needed and was removed with commit: blender/blender-addons@ba7e0de977. This bug can now be reproduced with the object_collection_manager addon (mine).

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'
Author
Member

Thanks @dr.sybren !

Thanks @dr.sybren !

@ideasman42 I have reopened this task as @Imaginer provided a new way to reproduce it (and I could reproduce it indeed). Do you know if access to bpy.context.preferences.addons[__package__] is guaranteed to work? In other words, is this an issue with Blender (i.e. something that should exist doesn't) or is it an issue with the add-on (i.e. accessing something that isn't guaranteed to exist)?

From what I can see, Blender does the following when loading factory settings:

  • Load the startup blend file.
  • Load the default preferences.
  • Iterate over all add-ons, and disable/enable them so that their state matches the current (so default) preferences.

One of the issues why this is not just a matter of accessing bpy.context.preferences.addons[__package__] is that the add-on tries to unregister submodules based on the user preferences:

    if bpy.context.preferences.addons[__package__].preferences.enable_qcd:
        qcd_init.unregister_qcd()

Of course if the unregister() function is called after the user preferences have been reset, this is no longer possible. I do something similar with the Blender Cloud add-on: when the current Cloud project is set up for Attract, it registers a handler so that I can draw on the VSE, and this handler of course has to be unregistered when unloading. If the user preferences are reset at that time, it won't have any current Cloud project, so it wouldn't known it has to unregister that draw handler.

It could also be argued that unregistration should always be complete, and should not rely on the user preferences at all. I'd be fine with this too, but that would require proper documentation; currently the reference doc for bpy.context.preferences.addons doesn't mention this.

@ideasman42 I have reopened this task as @Imaginer provided a new way to reproduce it (and I could reproduce it indeed). Do you know if access to `bpy.context.preferences.addons[__package__]` is guaranteed to work? In other words, is this an issue with Blender (i.e. something that should exist doesn't) or is it an issue with the add-on (i.e. accessing something that isn't guaranteed to exist)? From what I can see, Blender does the following when loading factory settings: - Load the startup blend file. - Load the default preferences. - Iterate over all add-ons, and disable/enable them so that their state matches the current (so default) preferences. One of the issues why this is not just a matter of accessing `bpy.context.preferences.addons[__package__]` is that the add-on tries to unregister submodules based on the user preferences: ``` if bpy.context.preferences.addons[__package__].preferences.enable_qcd: qcd_init.unregister_qcd() ``` Of course if the `unregister()` function is called after the user preferences have been reset, this is no longer possible. I do something similar with the Blender Cloud add-on: when the current Cloud project is set up for Attract, it registers a handler so that I can draw on the VSE, and this handler of course has to be unregistered when unloading. If the user preferences are reset at that time, it won't have any current Cloud project, so it wouldn't known it has to unregister that draw handler. It could also be argued that unregistration should always be complete, and should not rely on the user preferences at all. I'd be fine with this too, but that would require proper documentation; currently [the reference doc for bpy.context.preferences.addons](https://docs.blender.org/api/master/bpy.types.Addons.html#bpy.types.Addons) doesn't mention this.
Sybren A. Stüvel removed their assignment 2020-05-08 11:40:04 +02:00
Campbell Barton self-assigned this 2020-05-08 13:58:53 +02:00
Author
Member

Any update on this? I'm really trying not to be pushy and I'm sure you have lots of things to deal with, but I'd prefer it if my addon wasn't released with blender 2.83 (LTS) with a bug where loading factory settings completely breaks it.

Any update on this? I'm really trying not to be pushy and I'm sure you have lots of things to deal with, but I'd prefer it if my addon wasn't released with blender 2.83 (LTS) with a bug where loading factory settings completely breaks it.

This issue was referenced by f18ed7ad89

This issue was referenced by f18ed7ad890ee5c89fc6e6a22e76c732fb5fc1bc

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Author
Member

@ideasman42 Thanks for fixing this. Everything works perfectly now! :D

@ideasman42 Thanks for fixing this. Everything works perfectly now! :D

This issue was referenced by e69f70e11f

This issue was referenced by e69f70e11f00b7dbb511cc9a1ea15c57c9ad668d

This issue was referenced by eba3aa1837

This issue was referenced by eba3aa1837e40bf168528b1e3588540a7f241e1e

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'

Reverted in 2.83, although I have a fix prepared for 2.90, will test & commit tomorrow.

Reverted in 2.83, although I have a fix prepared for 2.90, will test & commit tomorrow.

This issue was referenced by f0df4d6c35

This issue was referenced by f0df4d6c35fc17c57adc8c0bcd5af11f7583f2ee

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' 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
6 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#67577
No description provided.