UI: support 'activate_init' for popups which refresh #71112

Closed
opened 2019-10-26 07:06:08 +02:00 by Ryan Inch · 15 comments
Member

Currently 'activate_init' layout property doesn't work for popups which run their draw function multiple times once opened.


System Information
Operating system: Linux-5.3.7-arch1-1-ARCH-x86_64-with-arch 64 Bits
Graphics card: GeForce GTX 660M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21

Blender Version
Broken versions:
2.81 (sub 15), branch: master, commit date: 2019-10-24 19:00, hash: 892c3891ed
2.82 (sub 1), branch: master, commit date: 2019-10-24 19:11, hash: 2a3b5dc730

Short description of error
Setting the activate_init property of a UILayout causes weird behavior and often causes the blender ui to freeze. I'm including a test addon that utilizes activate_init in a panel, a popup, and an item within a UIList in a popup. Both the popup and the UIList item cause the whole ui to freeze after interacting with them, while the panel just isn't affected at all. The weird behavior only seems to happen after you press enter or otherwise finish interacting with the auto-activated field; everything acts like you would expect until you finish and find the UI is non-responsive.

The panel is named Test Panel and located in the Object tab of the Properties Editor.
The popup can be called by pressing ALT-T
The UIList can be called by pressing CTRL-T

Exact steps for others to reproduce the error
Install and activate the test addon.
Press one of the hotkeys.
Press enter to finish editing the auto activated field.
Try to pan the 3D View using the middle mouse button.

activate_init_bug_test.py

Currently 'activate_init' layout property doesn't work for popups which run their draw function multiple times once opened. ---- **System Information** Operating system: Linux-5.3.7-arch1-1-ARCH-x86_64-with-arch 64 Bits Graphics card: GeForce GTX 660M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21 **Blender Version** Broken versions: 2.81 (sub 15), branch: master, commit date: 2019-10-24 19:00, hash: `892c3891ed` 2.82 (sub 1), branch: master, commit date: 2019-10-24 19:11, hash: `2a3b5dc730` **Short description of error** Setting the activate_init property of a UILayout causes weird behavior and often causes the blender ui to freeze. I'm including a test addon that utilizes activate_init in a panel, a popup, and an item within a UIList in a popup. Both the popup and the UIList item cause the whole ui to freeze after interacting with them, while the panel just isn't affected at all. The weird behavior only seems to happen after you press enter or otherwise finish interacting with the auto-activated field; everything acts like you would expect until you finish and find the UI is non-responsive. The panel is named Test Panel and located in the Object tab of the Properties Editor. The popup can be called by pressing ALT-T The UIList can be called by pressing CTRL-T **Exact steps for others to reproduce the error** Install and activate the test addon. Press one of the hotkeys. Press enter to finish editing the auto activated field. Try to pan the 3D View using the middle mouse button. [activate_init_bug_test.py](https://archive.blender.org/developer/F7857838/activate_init_bug_test.py)
Author
Member

Added subscriber: @Imaginer

Added subscriber: @Imaginer

Added subscriber: @joules-2

Added subscriber: @joules-2

I can confirm this freezes the UI.

I came across a crash however trying to capture an event.
Regardless of activate_init enabled or not. Tried to capture an event (i.e {'ESC'}) with a modal() handler added with invoke() however blender will crash on modal(). Could be related or a case of don't do that with popups.

I can confirm this freezes the UI. I came across a crash however trying to capture an event. Regardless of activate_init enabled or not. Tried to capture an event (i.e {'ESC'}) with a modal() handler added with invoke() however blender will crash on modal(). Could be related or a case of *don't do that with popups*.

Added subscriber: @MiroHorvath

Added subscriber: @MiroHorvath
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

I can confirm that this is freezing the UI as well.
It does not crash or is completely unresponsive though.

The File Close Dialog is still working as usual (when you try to close Blender). So it looks like there is an issue with the event handling somewhere.

@Imaginer Can you explain what the test variable is supposed to do? While I haven't used the activate_init feature myself yet, your use of the test variable seems weird.

Interestingly, when I remove it, I actually get a crash.

==473==ERROR: AddressSanitizer: heap-use-after-free on address 0x6190004295c8 at pc 0x55f3950700c2 bp 0x7ffd84a25460 sp 0x7ffd84a25450
READ of size 4 at 0x6190004295c8 thread T0
    - 0 0x55f3950700c1 in UI_block_active_only_flagged_buttons /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:895
    - 1 0x55f391da0fdf in wm_operator_ui_create /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_operators.c:1470
    - 2 0x55f39522d70b in ui_popup_block_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:573
    - 3 0x55f39522b038 in ui_block_region_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:401
    - 4 0x55f391d0a2da in wm_draw_window_offscreen /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:656
    - 5 0x55f391d0b106 in wm_draw_window /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:770
    - 6 0x55f391d0c4d8 in wm_draw_update /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:952
    - 7 0x55f391cfd168 in WM_main /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm.c:423
    - 8 0x55f390f7f6ed in main /home/jacques/blender-git/blender/source/creator/creator.c:518
    - 9 0x7fa8fe12e1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2)
    #10 0x55f390f7ea2d in _start (/home/jacques/blender-git/build_linux/bin/blender+0x30ceaa2d)

0x6190004295c8 is located 72 bytes inside of 1152-byte region [0x619000429580,0x619000429a00)
freed by thread T0 here:
    - 0 0x7fa8fea306ef in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.5+0x10d6ef)
    - 1 0x55f3a8884fa1 in rem_memblock /home/jacques/blender-git/blender/intern/guardedalloc/intern/mallocn_guarded_impl.c:1097
    - 2 0x55f3a8883d95 in MEM_guarded_freeN /home/jacques/blender-git/blender/intern/guardedalloc/intern/mallocn_guarded_impl.c:983
    - 3 0x55f39508a476 in ui_but_free /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:3216
    - 4 0x55f39506fef7 in UI_but_active_only /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:877
    - 5 0x55f39507004d in UI_block_active_only_flagged_buttons /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:890
    - 6 0x55f391da0fdf in wm_operator_ui_create /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_operators.c:1470
    - 7 0x55f39522d70b in ui_popup_block_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:573
    - 8 0x55f39522b038 in ui_block_region_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:401
    - 9 0x55f391d0a2da in wm_draw_window_offscreen /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:656
    - 10 0x55f391d0b106 in wm_draw_window /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:770
    - 11 0x55f391d0c4d8 in wm_draw_update /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:952
    - 12 0x55f391cfd168 in WM_main /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm.c:423
    - 13 0x55f390f7f6ed in main /home/jacques/blender-git/blender/source/creator/creator.c:518
    #14 0x7fa8fe12e1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2)

previously allocated by thread T0 here:
    - 0 0x7fa8fea30ce6 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dce6)
    - 1 0x55f3a8881f68 in MEM_guarded_callocN /home/jacques/blender-git/blender/intern/guardedalloc/intern/mallocn_guarded_impl.c:613
    - 2 0x55f39508fd9d in ui_but_alloc /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:3671
    - 3 0x55f395090210 in ui_def_but /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:3727
    - 4 0x55f39509707b in ui_def_but_rna /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:4270
    - 5 0x55f395099bab in uiDefButR_prop /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:4869
    - 6 0x55f395299288 in uiDefAutoButR /home/jacques/blender-git/blender/source/blender/editors/interface/interface_utils.c:225
    - 7 0x55f3951965c9 in ui_item_with_label /home/jacques/blender-git/blender/source/blender/editors/interface/interface_layout.c:1048
    - 8 0x55f3951a01f1 in uiItemFullR /home/jacques/blender-git/blender/source/blender/editors/interface/interface_layout.c:2166
    - 9 0x55f39378310d in rna_uiItemR /home/jacques/blender-git/blender/source/blender/makesrna/intern/rna_ui_api.c:136
    - 10 0x55f393790904 in UILayout_prop_call /home/jacques/blender-git/build_linux/source/blender/makesrna/intern/rna_ui_gen.c:1794
    - 11 0x55f39303fd78 in RNA_function_call /home/jacques/blender-git/blender/source/blender/makesrna/intern/rna_access.c:7558
    - 12 0x55f3939326b7 in pyrna_func_call /home/jacques/blender-git/blender/source/blender/python/intern/bpy_rna.c:6146
    - 13 0x55f3a9e89163 in _PyObject_FastCallKeywords Objects/call.c:199
I can confirm that this is freezing the UI as well. It does not crash or is completely unresponsive though. The File Close Dialog is still working as usual (when you try to close Blender). So it looks like there is an issue with the event handling somewhere. @Imaginer Can you explain what the `test` variable is supposed to do? While I haven't used the `activate_init` feature myself yet, your use of the `test` variable seems weird. Interestingly, when I remove it, I actually get a crash. ``` ==473==ERROR: AddressSanitizer: heap-use-after-free on address 0x6190004295c8 at pc 0x55f3950700c2 bp 0x7ffd84a25460 sp 0x7ffd84a25450 READ of size 4 at 0x6190004295c8 thread T0 - 0 0x55f3950700c1 in UI_block_active_only_flagged_buttons /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:895 - 1 0x55f391da0fdf in wm_operator_ui_create /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_operators.c:1470 - 2 0x55f39522d70b in ui_popup_block_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:573 - 3 0x55f39522b038 in ui_block_region_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:401 - 4 0x55f391d0a2da in wm_draw_window_offscreen /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:656 - 5 0x55f391d0b106 in wm_draw_window /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:770 - 6 0x55f391d0c4d8 in wm_draw_update /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:952 - 7 0x55f391cfd168 in WM_main /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm.c:423 - 8 0x55f390f7f6ed in main /home/jacques/blender-git/blender/source/creator/creator.c:518 - 9 0x7fa8fe12e1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) #10 0x55f390f7ea2d in _start (/home/jacques/blender-git/build_linux/bin/blender+0x30ceaa2d) 0x6190004295c8 is located 72 bytes inside of 1152-byte region [0x619000429580,0x619000429a00) freed by thread T0 here: - 0 0x7fa8fea306ef in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.5+0x10d6ef) - 1 0x55f3a8884fa1 in rem_memblock /home/jacques/blender-git/blender/intern/guardedalloc/intern/mallocn_guarded_impl.c:1097 - 2 0x55f3a8883d95 in MEM_guarded_freeN /home/jacques/blender-git/blender/intern/guardedalloc/intern/mallocn_guarded_impl.c:983 - 3 0x55f39508a476 in ui_but_free /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:3216 - 4 0x55f39506fef7 in UI_but_active_only /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:877 - 5 0x55f39507004d in UI_block_active_only_flagged_buttons /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:890 - 6 0x55f391da0fdf in wm_operator_ui_create /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_operators.c:1470 - 7 0x55f39522d70b in ui_popup_block_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:573 - 8 0x55f39522b038 in ui_block_region_refresh /home/jacques/blender-git/blender/source/blender/editors/interface/interface_region_popup.c:401 - 9 0x55f391d0a2da in wm_draw_window_offscreen /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:656 - 10 0x55f391d0b106 in wm_draw_window /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:770 - 11 0x55f391d0c4d8 in wm_draw_update /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_draw.c:952 - 12 0x55f391cfd168 in WM_main /home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm.c:423 - 13 0x55f390f7f6ed in main /home/jacques/blender-git/blender/source/creator/creator.c:518 #14 0x7fa8fe12e1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2) previously allocated by thread T0 here: - 0 0x7fa8fea30ce6 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dce6) - 1 0x55f3a8881f68 in MEM_guarded_callocN /home/jacques/blender-git/blender/intern/guardedalloc/intern/mallocn_guarded_impl.c:613 - 2 0x55f39508fd9d in ui_but_alloc /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:3671 - 3 0x55f395090210 in ui_def_but /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:3727 - 4 0x55f39509707b in ui_def_but_rna /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:4270 - 5 0x55f395099bab in uiDefButR_prop /home/jacques/blender-git/blender/source/blender/editors/interface/interface.c:4869 - 6 0x55f395299288 in uiDefAutoButR /home/jacques/blender-git/blender/source/blender/editors/interface/interface_utils.c:225 - 7 0x55f3951965c9 in ui_item_with_label /home/jacques/blender-git/blender/source/blender/editors/interface/interface_layout.c:1048 - 8 0x55f3951a01f1 in uiItemFullR /home/jacques/blender-git/blender/source/blender/editors/interface/interface_layout.c:2166 - 9 0x55f39378310d in rna_uiItemR /home/jacques/blender-git/blender/source/blender/makesrna/intern/rna_ui_api.c:136 - 10 0x55f393790904 in UILayout_prop_call /home/jacques/blender-git/build_linux/source/blender/makesrna/intern/rna_ui_gen.c:1794 - 11 0x55f39303fd78 in RNA_function_call /home/jacques/blender-git/blender/source/blender/makesrna/intern/rna_access.c:7558 - 12 0x55f3939326b7 in pyrna_func_call /home/jacques/blender-git/blender/source/blender/python/intern/bpy_rna.c:6146 - 13 0x55f3a9e89163 in _PyObject_FastCallKeywords Objects/call.c:199 ```
Author
Member

@JacquesLucke I'm a little foggy on the details, but if I recall correctly I used test to make sure activate_init was only set once (so ui redraws wouldn't set it multiple times) to try and improve the result (could have been to avoid the crash). Another reason you'd want something like this is to allow activate_init to only be set in certain situations. I put this demonstration addon together quickly and didn't use blender's bool properties or annotation syntax, but I just tested and it performs the same.

Thanks for taking a look at this. :)

@JacquesLucke I'm a little foggy on the details, but if I recall correctly I used `test` to make sure `activate_init` was only set once (so ui redraws wouldn't set it multiple times) to try and improve the result (could have been to avoid the crash). Another reason you'd want something like this is to allow `activate_init` to only be set in certain situations. I put this demonstration addon together quickly and didn't use blender's bool properties or annotation syntax, but I just tested and it performs the same. Thanks for taking a look at this. :)

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Campbell Barton changed title from Using Activate Init in an Addon Causes the Blender UI to Freeze to UI: support 'activate_init' for popups which refresh 2020-02-12 12:20:28 +01:00

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

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

This issue was referenced by 0840469ccd

This issue was referenced by 0840469ccd4fafc1658628201f297005e27bca71

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Campbell Barton self-assigned this 2020-02-13 07:08:49 +01:00

Added subscriber: @portnov

Added subscriber: @portnov

The freezing reproduces for me at Blender 2.90.1 and Blender 2.91 b00820c04d . Was the fix included in some release?

The freezing reproduces for me at Blender 2.90.1 and Blender 2.91 b00820c04d2f . Was the fix included in some release?
Author
Member

@portnov It works for me in 2.90.0, so maybe it's a regression. Since #75521 is still open it could also be related to that.
Perhaps it's hardware dependent?

@portnov It works for me in 2.90.0, so maybe it's a regression. Since #75521 is still open it could also be related to that. Perhaps it's hardware dependent?
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
8 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#71112
No description provided.