OBJECT_BAKE flag is true in object_bake_complete handler #119622
Labels
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#119622
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows 10
Graphics card: GeForce 2080 TI
Blender Version
Broken: 4.0.2,
9be62e85b7
, master, 2023-12-05Worked: Never afaik (tested on 3.6.8 as well)
Short description of error
bpy.app.is_job_running('OBJECT_BAKE') returns true inside on_bake_completed handler, making it hard to start new bake afterwards, or do anything else.
Exact steps for others to reproduce the error
I can confirm, but I don't think it's a bug.
bpy.app.is_job_running('OBJECT_BAKE')
is not necessarily an indication that the image is being baked.It indicates that the job is running. And since the Bake callbacks are part of the job, it seems to be expected that the job is running when the callbacks are called.
But in any case, I'm tagging the report as
Needs Info from Developers
.@Sergey, maybe you can shed some light here?
I am a bit confused about this statement. Job's completion/cancellation callback is called from main thread, via
wm_job_end
, which hasBLI_assert_msg(BLI_thread_is_main(), "wm_job_end should only be called from the main thread");
.Probably we can solve the expected behavior in this case by moving
wm_job->running = false;
prior to thewm_job_end(wm, wm_job);
in thewm_jobs_timer
. At that point the job is ready, so it is no longer running, andis_job_running
shouldn't be returning that the job is running.For me, the confusion would be in defining what is part of the job: {callbacks before running in multithread; running in multithread; callbacks after running in multithread}.
If, even in the main thread, the callback is part of the job, the job is running... no?
The callback is called "completed". So it is not very intuitive that something is both "completed" and "running".
I think it still falls to the question of definition (what is bake completed? What is job running?)
I'm confirming the issue anyway.
The fix can go either to the definition side, or to when setting
wm_job->running = false
.The job itself have completed and running states, and the "bake completed" handler is called from job's completed callback. A bit of a details, but it does affect on the quesrtion a little bit.
In any case, I think it is something where @dr.sybren or @ideasman42 would be best to be asked. The job query API Sybren did, and probably has better understanding of what the expectations are.
I agree with Sergey here. The callback is called "completed" (past tense), and not "completing". The purpose for the job query API was to allow scripts to be notified that background work was done, so that something else can be done after it. Ensuring that
wm_job->running = false
before calling the 'completed' callback seems like the right way to go for me.From the script in the example blend file (thanks for providing that, clear examples are always much appreciated):
Please never do this, even in simple example code. Having a bare
except:
that ignores any exception is bound to catch more than you intend, and can hide very nasty errors. Just have aexcept WhateverTypeYouExpect:
here.Thank you for taking the time to address this issue, and a thanks to Sybren for the advice on handling exceptions. Noted!
From my POV as an API user, without going into technical details, current behaviour doesn't make much sense. on_bake_completed could make chaining bakes or doing any "post bake" ops much easier , opposed to using macros or any other means. Right now we have to register timer for every on_bake_completed handler, which makes whole thing messy in my oppinion.
Sorry I missclicked "Comment and Close"