python render.render() calls frame change handler even if it's rendering a single frame. Leads to recursion and crash if handler executed render.render() in the first place. #88726

Open
opened 2021-06-01 18:03:56 +02:00 by michael campbell · 10 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.92

Blender Version
Broken: version: 2.93.0 Beta, branch: master, commit date: 2021-04-29 17:14, hash: 39226cd437
Worked: (newest version of Blender that worked as expected)

Short description of error
[Please fill out a short description of the error here]

Exact steps for others to reproduce the error

Immediate crash of blender with any addon that calls render.render() from a frame change handler. It only happens when changing the playhead position in the timeline using the mouse, not when manually entering a frame number, or when using the left right arrows. So the problem appears to be that when blender/blender-addons#60094 was closed, the resolution didn't account for changing the frame with the mouse in the timeline.

Here's a simple script to test with. Open in the blender text editor, click run, and then change the frame by clicking an area of the timeline so that the playhead jumps to that frame.

newbug.txt

error:

Error : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF6317BAB2D
Module : blender.exe
Thread : 000026fc
Writing: C:\Users\3diWorkstation\AppData\Local\Temp\simple.crash.txt

simple.crash.txt

video:

2021-06-01 16-55-49.mp4

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.92 **Blender Version** Broken: version: 2.93.0 Beta, branch: master, commit date: 2021-04-29 17:14, hash: `39226cd437` Worked: (newest version of Blender that worked as expected) **Short description of error** [Please fill out a short description of the error here] **Exact steps for others to reproduce the error** Immediate crash of blender with any addon that calls render.render() from a frame change handler. It only happens when changing the playhead position in the timeline using the mouse, not when manually entering a frame number, or when using the left right arrows. So the problem appears to be that when blender/blender-addons#60094 was closed, the resolution didn't account for changing the frame with the mouse in the timeline. Here's a simple script to test with. Open in the blender text editor, click run, and then change the frame by clicking an area of the timeline so that the playhead jumps to that frame. [newbug.txt](https://archive.blender.org/developer/F10153091/newbug.txt) error: Error : EXCEPTION_ACCESS_VIOLATION Address : 0x00007FF6317BAB2D Module : blender.exe Thread : 000026fc Writing: C:\Users\3diWorkstation\AppData\Local\Temp\simple.crash.txt [simple.crash.txt](https://archive.blender.org/developer/F10153043/simple.crash.txt) video: [2021-06-01 16-55-49.mp4](https://archive.blender.org/developer/F10153029/2021-06-01_16-55-49.mp4)

Added subscriber: @3di

Added subscriber: @3di
michael campbell changed title from desgraph fix T60094 doesn't work when using the timeline playhead. Instant crash with access violation. to immediate crash when moving the playhead with the mouse if frame change handler calls render.render() 2021-06-01 18:43:40 +02:00

Added subscriber: @brecht

Added subscriber: @brecht

Calling bpy.ops.render.render() from a frame change handler is problematic because that in turn might cause the frame change handler to be called. I don't know if that is supported at all, maybe there is a way to get it working or at least fail with an error message without crashing.

blender/blender-addons#60094 also involves a frame change handler but otherwise seems unrelated.

Calling `bpy.ops.render.render()` from a frame change handler is problematic because that in turn might cause the frame change handler to be called. I don't know if that is supported at all, maybe there is a way to get it working or at least fail with an error message without crashing. blender/blender-addons#60094 also involves a frame change handler but otherwise seems unrelated.

@brecht I've just tested that by using a scene property to ensure the handler is only hit once, and it still crashes. I think if that had been the case, then it would crash when changing the frame using the timeline's current frame textbox, and when using the left and right arrows to change the frame, as they all call the same handler.

It seems changing the frame using the playhead or clicking a spot on the timeline for the playhead to jump to, doesn't update the desgraph in the same way the other methods of updating the frame do?

@brecht I've just tested that by using a scene property to ensure the handler is only hit once, and it still crashes. I think if that had been the case, then it would crash when changing the frame using the timeline's current frame textbox, and when using the left and right arrows to change the frame, as they all call the same handler. It seems changing the frame using the playhead or clicking a spot on the timeline for the playhead to jump to, doesn't update the desgraph in the same way the other methods of updating the frame do?
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

Can at least confirm it crashes

Traceback (most recent call last):
  File "/Text", line 4, in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 179, in <lambda>
    result.__getattr__ = lambda func: _bpy_ops_submodule__getattr__(module, func)
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 162, in _bpy_ops_submodule__getattr__
    return _BPyOpsSubModOp(module, func)
RecursionError: maximum recursion depth exceeded
Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow.
Python runtime state: initialized

Current thread 0x00007f1619c99200 (most recent call first):
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 189 in __getattr__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
  File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__
  File "/Text", line 4 in frame_change_pre
Can at least confirm it crashes ``` Traceback (most recent call last): File "/Text", line 4, in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 179, in <lambda> result.__getattr__ = lambda func: _bpy_ops_submodule__getattr__(module, func) File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 162, in _bpy_ops_submodule__getattr__ return _BPyOpsSubModOp(module, func) RecursionError: maximum recursion depth exceeded Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow. Python runtime state: initialized Current thread 0x00007f1619c99200 (most recent call first): File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 189 in __getattr__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre File "/build_linux/bin/3.0/scripts/modules/bpy/ops.py", line 132 in __call__ File "/Text", line 4 in frame_change_pre ```

I think my problem was actually not due to the recursion, because I'd overcome that using scene properties to limit it to one execution per call, but my problem turned out to be calling an operator from within the frame handler. My operator basically re-rendered the frame when the frame was changed.

So the bug for this report should probably be that when initiating a render from python using render.render(), a frame change handler is executed even if the frame is identical. f12 doesn't have the same problem.

I think my problem was actually not due to the recursion, because I'd overcome that using scene properties to limit it to one execution per call, but my problem turned out to be calling an operator from within the frame handler. My operator basically re-rendered the frame when the frame was changed. So the bug for this report should probably be that when initiating a render from python using render.render(), a frame change handler is executed even if the frame is identical. f12 doesn't have the same problem.

should I make a separate bug report about calling operators from frame handler causes access violation?

should I make a separate bug report about calling operators from frame handler causes access violation?

I've made a new report specific to the timeline bug in relation to frame change handlers:

https://developer.blender.org/T88739

I've made a new report specific to the timeline bug in relation to frame change handlers: https://developer.blender.org/T88739
michael campbell changed title from immediate crash when moving the playhead with the mouse if frame change handler calls render.render() to python render.render() calls frame change handler even if it's rendering a single frame. 2021-06-02 12:48:50 +02:00
michael campbell changed title from python render.render() calls frame change handler even if it's rendering a single frame. to python render.render() calls frame change handler even if it's rendering a single frame. Leads to recursion and crash. 2021-06-02 12:50:20 +02:00
michael campbell changed title from python render.render() calls frame change handler even if it's rendering a single frame. Leads to recursion and crash. to python render.render() calls frame change handler even if it's rendering a single frame. Leads to recursion and crash if handler executed render.render() in the first place. 2021-06-02 12:51:07 +02:00
Philipp Oeser removed the
Interest
Render & Cycles
label 2023-02-09 14:02:26 +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#88726
No description provided.