Blender freezes when calling an operator after a dialog window. #63207

Open
opened 2019-04-02 06:01:21 +02:00 by nBurn · 7 comments
Member

System Information
Operating system: Windows 10 x64

Blender Version
Broken: 2.80 win64, 2019-04-01 19:15
Worked: 2.79b win64, release

Short description of error

If an operator from bpy.ops is called after a dialog window / popup is closed, Blender freezes and has to be manually terminated. A script to reproduce the error is located at the bottom of this task description.

Exact steps for others to reproduce the error

  • Copy / Paste the code at the bottom of the task description into Blender's text editor
  • Press "ALT P" to run the script
  • Place the mouse cursor over a 3D Viewport
  • Select any object in the 3D View (for example the default cube)
  • Press "F3" to bring up the search bar
  • Type in "Popup Input Test" to launch the script
  • Press "P" to generate a popup dialog
  • Click the "OK" button in the dialog

Watch Blender freeze and stop responding to input.

Additional Notes

  • The freeze happens at the bpy.ops.transform.translate call in the run_transform function. The following print(" after bpy.ops.transform") statement never executes.
  • The freeze up when executing the run_transform function does not happen if...
  • a popup dialog is not opened first (Press "T" instead of "P" when the script is running).
  • the run_transform function is called from the execute method in the POPUP_OT_input_panel class instead of the draw_callback_px function.
  • the contents of the draw_callback_px function (if self.wait_for_popup ...) are relocated inside the modal method in the POPUP_OT_main class.
  • the script is run in Blender 2.79 instead of 2.80 (the script below can be run in both 2.79 and 2.80).
import bpy
print("\nLoaded add-on.\n")

# globals
popup_active = False
popup_cancel = False


def run_transform():
    print("before bpy.ops.transform")
    bpy.ops.transform.translate(value=(0.0, 0.0, 1.5))
    print("after bpy.ops.transform")


class POPUP_OT_input_panel(bpy.types.Operator):
    bl_idname = "object.popup_input_dialog_op"
    bl_label = "Popup Input Dialog Panel"
    bl_options = {'INTERNAL'}

    def execute(self, context):
        print("\nPOPUP_OT_input_panel: exec")
        global popup_active
        popup_active = False
        #run_transform()
        return {'FINISHED'}

    def invoke(self, context, event):
        print("\nPOPUP_OT_input_panel: Invoke")
        return context.window_manager.invoke_props_dialog(self)

    def cancel(self, context):
        print("\nPOPUP_OT_input_panel: Cancelled")
        global popup_active, popup_cancel
        popup_active = False
        popup_cancel = True


def draw_callback_px(self, context):
    if self.wait_for_popup:
        global popup_active, popup_cancel
        if not popup_active:
            if popup_cancel:
                popup_cancel = False
                self.wait_for_popup = False
            elif not popup_active:
                run_transform()
                self.wait_for_popup = False


class POPUP_OT_main(bpy.types.Operator):
    bl_idname = "view3d.popup_main_op"
    bl_label = "Popup Input Test"

    @classmethod
    def poll(self, context):
        return context.mode == 'OBJECT' or context.mode == 'EDIT_MESH'

    def exit_addon(self):
        bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
        print("Exiting addon")
        return {'CANCELLED'}

    def modal(self, context, event):
        context.area.tag_redraw()
        global popup_active

        if event.type in {'A', 'MIDDLEMOUSE', 'WHEELUPMOUSE',
                'WHEELDOWNMOUSE', 'LEFTMOUSE', 'TAB'}:
            return {'PASS_THROUGH'}

        if event.type == 'P' and event.value == 'PRESS':
            if not self.wait_for_popup and not popup_active:
                self.wait_for_popup = True
                popup_active = True
                bpy.ops.object.popup_input_dialog_op('INVOKE_DEFAULT')

        if event.type == 'T' and event.value == 'PRESS':
            if not self.wait_for_popup and not popup_active:
                run_transform()

        elif event.type == 'D' and event.value == 'RELEASE':
            # start debug console
            __import__('code').interact(local=dict(globals(), **locals()))

        elif event.type == 'ESC' and event.value == 'RELEASE':
            return self.exit_addon()

        elif self.force_quit:
            return self.exit_addon()

        #if self.wait_for_popup:

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.area.type == 'VIEW_3D':
            args = (self, context)
            self._handle = bpy.types.SpaceView3D.draw_handler_add(
                    draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
            self.force_quit = False
            self.wait_for_popup = False
            context.window_manager.modal_handler_add(self)
            print("Add-on running")
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "View3D not found, cannot run operator")
            return {'CANCELLED'}


def register():
    bpy.utils.register_class(POPUP_OT_input_panel)
    bpy.utils.register_class(POPUP_OT_main)

def unregister():
    bpy.utils.unregister_class(POPUP_OT_input_panel)
    bpy.utils.unregister_class(POPUP_OT_main)

if __name__ == "__main__":
    register()
**System Information** Operating system: Windows 10 x64 **Blender Version** Broken: 2.80 win64, 2019-04-01 19:15 Worked: 2.79b win64, release **Short description of error** If an operator from `bpy.ops` is called after a dialog window / popup is closed, Blender freezes and has to be manually terminated. A script to reproduce the error is located at the bottom of this task description. **Exact steps for others to reproduce the error** - Copy / Paste the code at the bottom of the task description into Blender's text editor - Press "ALT P" to run the script - Place the mouse cursor over a 3D Viewport - Select any object in the 3D View (for example the default cube) - Press "F3" to bring up the search bar - Type in "Popup Input Test" to launch the script - Press "P" to generate a popup dialog - Click the "OK" button in the dialog # Watch Blender freeze and stop responding to input. **Additional Notes** - The freeze happens at the `bpy.ops.transform.translate` call in the `run_transform` function. The following `print(" after bpy.ops.transform")` statement never executes. - The freeze up when executing the `run_transform` function does not happen if... - a popup dialog is not opened first (Press "T" instead of "P" when the script is running). - the `run_transform` function is called from the `execute` method in the `POPUP_OT_input_panel` class instead of the `draw_callback_px` function. - the contents of the `draw_callback_px` function (`if self.wait_for_popup` ...) are relocated inside the `modal` method in the `POPUP_OT_main` class. - the script is run in Blender 2.79 instead of 2.80 (the script below can be run in both 2.79 and 2.80). ``` import bpy print("\nLoaded add-on.\n") # globals popup_active = False popup_cancel = False def run_transform(): print("before bpy.ops.transform") bpy.ops.transform.translate(value=(0.0, 0.0, 1.5)) print("after bpy.ops.transform") class POPUP_OT_input_panel(bpy.types.Operator): bl_idname = "object.popup_input_dialog_op" bl_label = "Popup Input Dialog Panel" bl_options = {'INTERNAL'} def execute(self, context): print("\nPOPUP_OT_input_panel: exec") global popup_active popup_active = False #run_transform() return {'FINISHED'} def invoke(self, context, event): print("\nPOPUP_OT_input_panel: Invoke") return context.window_manager.invoke_props_dialog(self) def cancel(self, context): print("\nPOPUP_OT_input_panel: Cancelled") global popup_active, popup_cancel popup_active = False popup_cancel = True def draw_callback_px(self, context): if self.wait_for_popup: global popup_active, popup_cancel if not popup_active: if popup_cancel: popup_cancel = False self.wait_for_popup = False elif not popup_active: run_transform() self.wait_for_popup = False class POPUP_OT_main(bpy.types.Operator): bl_idname = "view3d.popup_main_op" bl_label = "Popup Input Test" @classmethod def poll(self, context): return context.mode == 'OBJECT' or context.mode == 'EDIT_MESH' def exit_addon(self): bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW') print("Exiting addon") return {'CANCELLED'} def modal(self, context, event): context.area.tag_redraw() global popup_active if event.type in {'A', 'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE', 'LEFTMOUSE', 'TAB'}: return {'PASS_THROUGH'} if event.type == 'P' and event.value == 'PRESS': if not self.wait_for_popup and not popup_active: self.wait_for_popup = True popup_active = True bpy.ops.object.popup_input_dialog_op('INVOKE_DEFAULT') if event.type == 'T' and event.value == 'PRESS': if not self.wait_for_popup and not popup_active: run_transform() elif event.type == 'D' and event.value == 'RELEASE': # start debug console __import__('code').interact(local=dict(globals(), **locals())) elif event.type == 'ESC' and event.value == 'RELEASE': return self.exit_addon() elif self.force_quit: return self.exit_addon() #if self.wait_for_popup: return {'RUNNING_MODAL'} def invoke(self, context, event): if context.area.type == 'VIEW_3D': args = (self, context) self._handle = bpy.types.SpaceView3D.draw_handler_add( draw_callback_px, args, 'WINDOW', 'POST_PIXEL') self.force_quit = False self.wait_for_popup = False context.window_manager.modal_handler_add(self) print("Add-on running") return {'RUNNING_MODAL'} else: self.report({'WARNING'}, "View3D not found, cannot run operator") return {'CANCELLED'} def register(): bpy.utils.register_class(POPUP_OT_input_panel) bpy.utils.register_class(POPUP_OT_main) def unregister(): bpy.utils.unregister_class(POPUP_OT_input_panel) bpy.utils.unregister_class(POPUP_OT_main) if __name__ == "__main__": register() ```
Author
Member

Added subscriber: @nBurn

Added subscriber: @nBurn
Campbell Barton was assigned by Sebastian Parborg 2019-04-05 12:08:13 +02:00
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:34:45 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Added subscriber: @iss

Added subscriber: @iss

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

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

I have re-triaged this report and can not reproduce it.
Can you please check if this is still an issue in latest build?
https://builder.blender.org/download/

I have re-triaged this report and can not reproduce it. Can you please check if this is still an issue in latest build? https://builder.blender.org/download/

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

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

After some time I opened Blender window and noticed, that it does not respond.

Backtrace:

>	blender.exe!bpy_class_call(bContext * C, PointerRNA * ptr, FunctionRNA * func, ParameterList * parms) Řádek 8325	C

 	blender.exe!rna_operator_modal_cb(bContext * C, wmOperator * op, const wmEvent * event) Řádek 1386	C
 	blender.exe!wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties, const unsigned char * kmi_idname) Řádek 1983	C
 	blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Řádek 2741	C
 	blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Řádek 2789	C
 	blender.exe!wm_event_do_handlers(bContext * C) Řádek 3168	C
 	blender.exe!WM_main(bContext * C) Řádek 421	C
 	blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Řádek 520	C

Console output:

Loaded add-on.

Add-on running
Exiting addon
Add-on running
Exiting addon
Add-on running
Exiting addon
Add-on running

POPUP_OT_input_panel: Invoke

POPUP_OT_input_panel: exec
before bpy.ops.transform
after bpy.ops.transform
Python 3.7.4 (default, Nov  1 2019, 18:35:29) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>

After some time I opened Blender window and noticed, that it does not respond. Backtrace: ``` > blender.exe!bpy_class_call(bContext * C, PointerRNA * ptr, FunctionRNA * func, ParameterList * parms) Řádek 8325 C blender.exe!rna_operator_modal_cb(bContext * C, wmOperator * op, const wmEvent * event) Řádek 1386 C blender.exe!wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties, const unsigned char * kmi_idname) Řádek 1983 C blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Řádek 2741 C blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Řádek 2789 C blender.exe!wm_event_do_handlers(bContext * C) Řádek 3168 C blender.exe!WM_main(bContext * C) Řádek 421 C blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Řádek 520 C ``` Console output: ``` Loaded add-on. Add-on running Exiting addon Add-on running Exiting addon Add-on running Exiting addon Add-on running POPUP_OT_input_panel: Invoke POPUP_OT_input_panel: exec before bpy.ops.transform after bpy.ops.transform Python 3.7.4 (default, Nov 1 2019, 18:35:29) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> ```
Philipp Oeser removed the
Interest
Python API
label 2023-02-10 09:04:45 +01:00
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
3 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#63207
No description provided.