2.8: Python API: Changing area type on frame change crashes Blender #72602

Open
opened 2019-12-20 15:03:13 +01:00 by Christopher Gearhart · 7 comments

System Information
Operating system: Windows 10
Graphics card: Quadro P4200/PCIe/SSE2

Blender Version
Broken: 2.81a (also crashes in 2.79 and 2.80)

Short description of error
I am attempting to sample the individual frames of an image on frame change, using a solution similar to the one described here: https://blenderartists.org/t/how-to-get-particular-frame-of-video-image/590889/5. I cannot seem to set the viewer area, however, from this context, as bpy.context.screen is None, and bpy.context.window_manager.windows- [x].screen seems to crash Blender in some situations.

Exact steps for others to reproduce the error
From the default startup file, run the following basic code:

import bpy

def on_frame_change(scn):
    bpy.context.window_manager.windows[0].screen.areas[0].type = "IMAGE_EDITOR"

bpy.app.handlers.frame_change_pre.append(on_frame_change)

Run the Render Animation operator to crash Blender.

Note: This code runs fine when playing the animation in the 3D Viewport. It seems that this bug relates to the render context only.

**System Information** Operating system: Windows 10 Graphics card: Quadro P4200/PCIe/SSE2 **Blender Version** Broken: 2.81a (also crashes in 2.79 and 2.80) **Short description of error** I am attempting to sample the individual frames of an image on frame change, using a solution similar to the one described here: https://blenderartists.org/t/how-to-get-particular-frame-of-video-image/590889/5. I cannot seem to set the viewer area, however, from this context, as `bpy.context.screen` is `None`, and `bpy.context.window_manager.windows- [x].screen` seems to crash Blender in some situations. **Exact steps for others to reproduce the error** From the default startup file, run the following basic code: ``` import bpy def on_frame_change(scn): bpy.context.window_manager.windows[0].screen.areas[0].type = "IMAGE_EDITOR" bpy.app.handlers.frame_change_pre.append(on_frame_change) ``` Run the `Render Animation` operator to crash Blender. Note: This code runs fine when playing the animation in the 3D Viewport. It seems that this bug relates to the render context only.

Added subscriber: @bblanimation

Added subscriber: @bblanimation
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

I can confirm the crash, but personally I'd put this into the "known limitation" category...
Realistically, I'd recommend to find another solution that does not involve changing the area type in an event handler.

I can confirm the crash, but personally I'd put this into the "known limitation" category... Realistically, I'd recommend to find another solution that does not involve changing the area type in an event handler.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

Can also confirm.

There are similar issues:
#62074 (2.8: Python API: crash due to missing window context in Application timer)
#71383 (2.8: Python API: window's workspace can't be set in Application timer)
blender/blender-addons#71422 (Blender 2.81 - Crash when deleting scene from timers API)

However in this case, even the solution using an operator with custom context mentioned in the other reports does not work.

Will confirm for now and follow @JacquesLucke into the Known Issue category.
We should however sync this with the other reports mentioned above at some point.

Can also confirm. There are similar issues: #62074 (2.8: Python API: crash due to missing window context in Application timer) #71383 (2.8: Python API: window's workspace can't be set in Application timer) blender/blender-addons#71422 (Blender 2.81 - Crash when deleting scene from timers API) However in this case, even the solution using an operator with custom context mentioned in the other reports does not work. Will confirm for now and follow @JacquesLucke into the `Known Issue` category. We should however sync this with the other reports mentioned above at some point.
Philipp Oeser changed title from Changing area type on frame change crashes Blender to 2.8: Python API: Changing area type on frame change crashes Blender 2020-01-15 21:06:02 +01:00
Philipp Oeser removed the
Interest
Python API
label 2023-02-10 09:04:43 +01:00
Member

Just noting we are warning here https://docs.blender.org/api/master/bpy.app.handlers.html#note-on-altering-data )

While rendering the frame_change_pre and frame_change_post handlers are called from one thread and the viewport updates from a different thread. If the handler changes data that is accessed by the viewport, this can cause a crash of Blender. In such cases, lock the interface (Render → Lock Interface or bpy.types.RenderSettings.use_lock_interface) before starting a render.

However Lock Interface doesnt really help here...

Just noting we are warning here https://docs.blender.org/api/master/bpy.app.handlers.html#note-on-altering-data ) >While rendering the frame_change_pre and frame_change_post handlers are called from one thread and the viewport updates from a different thread. If the handler changes data that is accessed by the viewport, this can cause a crash of Blender. In such cases, lock the interface (Render → Lock Interface or bpy.types.RenderSettings.use_lock_interface) before starting a render. However `Lock Interface` doesnt really help here...
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
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#72602
No description provided.