Poly-Haven / polyhavenassets

A Blender add-on to integrate our assets natively in the asset browser
GNU General Public License v3.0
312 stars 21 forks source link

Blender does not close properly when using add-on #88

Open tlpss opened 1 year ago

tlpss commented 1 year ago

Describe the bug

When using the add-on, blender does not close when pressing CTRL+Q. It does close when pressing CTLR+Q (or pressing the UI button) and then pressing CTRL+C in the terminal, after which a thread appears that seems to suggest it was stuck in acquiring a lock.

This does not happen deterministically, sometimes blender closes by itself.

When disabling the add-on, the issue goes away.

Console log

CTRL+Q in UI + CTRL+C in terminal:

✗ blender    

Read prefs: /home/tlips/.config/blender/3.4/config/userpref.blend
....
(program output)
....

<press CTRL+Q in UI>
Saved session recovery to '/tmp/quit.blend'

<press CTRL+C>
^CException ignored in: <module 'threading' from '/home/tlips/Documents/synthetic-cloth-data/airo-blender/blender/blender-3.4.1-linux-x64/3.4/python/lib/python3.10/threading.py'>
Traceback (most recent call last):
  File "/home/tlips/Documents/synthetic-cloth-data/airo-blender/blender/blender-3.4.1-linux-x64/3.4/python/lib/python3.10/threading.py", line 1567, in _shutdown
    lock.acquire()
KeyboardInterrupt: 

Blender quit

CTRL+Q in UI:

....
(normal program output)
....

<press CTRL+Q>
Saved session recovery to '/tmp/quit.blend'
Exception in thread Thread-3 (long_task):
Traceback (most recent call last):
  File "/home/tlips/Documents/synthetic-cloth-data/airo-blender/blender/blender-3.4.1-linux-x64/3.4/python/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/tlips/Documents/synthetic-cloth-data/airo-blender/blender/blender-3.4.1-linux-x64/3.4/python/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/tlips/.config/blender/3.4/scripts/addons/polyhavenassets/operators/resolution_switch.py", line 115, in long_task
    self.prog += 1
  File "/home/tlips/Documents/synthetic-cloth-data/airo-blender/blender/blender-3.4.1-linux-x64/3.4/scripts/modules/bpy_types.py", line 812, in __getattribute__
    properties = StructRNA.path_resolve(self, "properties")
ReferenceError: StructRNA of type PHA_OT_resolution_switch has been removed
Writing: /tmp/blender.crash.txt

To Reproduce run blender from the terminal, then try to close.

Expected behavior blender closes as expected on CTRL+Q in the UI.

Additional context blender version: 3.4.1 add-on version: 1.1.5

gregzaal commented 1 year ago

Thanks for the report. Seems like threads may still be busy when the add-on is unregistered, and then properties that the threads expect are no longer available. Will investigate soon, though I have not heard any similar reports nor have I ever run into this issue in normal usage, so this is not the top priority at the moment.