Scene not changed when use Python in Pinned workspace #100165

Closed
opened 2022-08-03 11:39:53 +02:00 by Antonio Vazquez · 17 comments

Failed: Version 3.3.0 Beta 31/07/2022
Worked: Never, PIN is a new option in 3.3 version.

Using the add-on we have developed for storyboarding, when the scene is pinned to the workspace, the scene is not correct when is changed using python.

WorkspacePinned.mp4

The python code is very simple:

context.window.workspace = storypencil_main_workspace
Failed: Version 3.3.0 Beta 31/07/2022 Worked: Never, PIN is a new option in 3.3 version. Using the add-on we have developed for storyboarding, when the scene is pinned to the workspace, the scene is not correct when is changed using python. [WorkspacePinned.mp4](https://archive.blender.org/developer/F13333457/WorkspacePinned.mp4) The python code is very simple: ``` context.window.workspace = storypencil_main_workspace ```
Author
Member

Added subscriber: @antoniov

Added subscriber: @antoniov
Author
Member

Added subscribers: @JulianEisel, @mendio

Added subscribers: @JulianEisel, @mendio
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

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

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

I can't seem to replicate this myself. Does the target Workspace have a different pinned scene than 03_Scene?
I am testing with this file:

pinnedWorkspace.blend

What does this mean?

Worked: New function of this version

I can't seem to replicate this myself. Does the target Workspace have a different pinned scene than `03_Scene`? I am testing with this file: [pinnedWorkspace.blend](https://archive.blender.org/developer/F13333623/pinnedWorkspace.blend) What does this mean? > Worked: New function of this version
Member

Are you able to reproduce the issue on the attached file? Because I can't seem to be able to.

Are you able to reproduce the issue on the attached file? Because I can't seem to be able to.
Author
Member

No, I cannot...I guess this is related to some multi thread issue and depends on the file size and complexity and CPU speed.... a really hard bug to catch.

No, I cannot...I guess this is related to some multi thread issue and depends on the file size and complexity and CPU speed.... a really hard bug to catch.
Member

Could you share the file where you originally reproduced the bug?

Could you share the file where you originally reproduced the bug?
Author
Member

I'm doing some debug and I have seen something weird.

My python code does this: context.window.workspace = scene.storypencil_edit_workspace

After that line, both variables would contain the same, I mean, the right variable is a workspace and is assigned to the context.workspace, but doing a debug I can see the left variable is not updated as you can see in the image below stopped in the next line after the assign of the value.

image.png

Is this normal? the question is why the variable is not updated because the code is working when is not pinned, so that means that the context.window.workspace update is delayed.

How can I force to update that value?

I'm doing some debug and I have seen something weird. My python code does this: ` context.window.workspace = scene.storypencil_edit_workspace` After that line, both variables would contain the same, I mean, the right variable is a workspace and is assigned to the `context.workspace`, but doing a debug I can see the left variable is not updated as you can see in the image below stopped in the next line after the assign of the value. ![image.png](https://archive.blender.org/developer/F13416854/image.png) Is this normal? the question is why the variable is not updated because the code is working when is not pinned, so that means that the `context.window.workspace` update is delayed. How can I force to update that value?

Added subscriber: @storyvalk

Added subscriber: @storyvalk
Member

It seems this is normal. Changing the workspace is a change of context, so it is intentionally delayed until all code that depends on the current context is executed.
This is done by adding a ND_WORKSPACE_SET notifier to the window, which is handled in wm_event_do_notifiers, which execute automatically as part of the main loop and can't be invoked manually as far as I can see.
So you can't force an update to that value. Why do you need it to take effect immediately?

It seems this is normal. Changing the workspace is a change of context, so it is intentionally delayed until all code that depends on the current context is executed. This is done by adding a `ND_WORKSPACE_SET` notifier to the window, which is handled in `wm_event_do_notifiers`, which execute automatically as part of the main loop and can't be invoked manually as far as I can see. So you can't force an update to that value. Why do you need it to take effect immediately?
Member
About that, see [D15614: Py Docs: Document delayed setting of UI data](https://archive.blender.org/developer/D15614).
Author
Member

@OmarEmaraDev I need the instant update because the add-on is switching all the time back and forth between VSE scene and strip scene to draw the storyboard.... I will investigate alternatives. Anyway, it would be great to have a context.windows.workspace.update()for this type of situations as we have for view_layers. I know that force the update is not the best, but in situations like this could be the best solution.

@OmarEmaraDev I need the instant update because the add-on is switching all the time back and forth between VSE scene and strip scene to draw the storyboard.... I will investigate alternatives. Anyway, it would be great to have a `context.windows.workspace.update()`for this type of situations as we have for `view_layers`. I know that force the update is not the best, but in situations like this could be the best solution.
Member

The situation is a bit different for view layers. For them the update is just delayed for performance reasons. So enforcing an immediate update is fine. For workspaces (and other UI changes) it's delayed because it could corrupt context. IIRC switching workspaces immediately will just result in crashes in many cases.

The situation is a bit different for view layers. For them the update is just delayed for performance reasons. So enforcing an immediate update is fine. For workspaces (and other UI changes) it's delayed because it could corrupt context. IIRC switching workspaces immediately will just result in crashes in many cases.
Member

Since this is getting documented as Julian pointed out, I would say this is handled.
But is the original issue you pointed out a manifestation of the issue you just described? Or is it different?

Since this is getting documented as Julian pointed out, I would say this is handled. But is the original issue you pointed out a manifestation of the issue you just described? Or is it different?
Author
Member

I all agree, we could consider this a Known Issue

I all agree, we could consider this a `Known Issue`
Member

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

Changed status from 'Needs User Info' to: 'Archived'
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
4 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#100165
No description provided.