Thread race condition with lock interface enabled #90043
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#90043
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-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.2 Release Candidate, branch: master, commit date: 2021-07-07 05:52, hash:
9e64fd461a
Worked: (newest version of Blender that worked as expected)
Description
UI redraw is still taking place in the render_init and render_complete handlers when use_lock_interface = True. This lock was only implemented for 3D viewport, but this is not mentioned in any of manuals.
Adding lock to node editor seems to resolve the issue:
Trace:
Exact steps for others to reproduce the error
Open below file, run the script and then press f12.
ui lock ignored on some handlers which are not on the main thread.blend
Added subscriber: @3di
#90079 was marked as duplicate of this issue
Added subscriber: @iss
Seems to work fine in 3.0. Not sure if this would be possible to fix in 2.93 would have to check which commit fixed this
Morning @iss I've just tested with today's 3.0 build, and it's still crashing Blender with ACCESS VIOLATION. Render a few times and it should crash (it just depends on what the main thread is doing with memory at the time I believe). One thing I've just noticed is that it only crashes if you have the compositor visible, even if lock interface is set to true.
My guess is that lock interface is ignored during the render_init and render_complete handlers, which causes the crash as they're still not on the main thread. This would explain why it always happens during UI drawing:
ExceptionCode : EXCEPTION_ACCESS_VIOLATION
Exception Address : 0x00007FF742D015C3
Exception Module : blender.exe
Exception Flags : 0x00000000
Exception Parameters : 0x2
Parameters- [x] : 0x0000000000000000
Parameters- [x] : 0x0000000000000010
Stack trace:
blender.exe :0x00007FF742D01560 UI_block_end_ex
blender.exe :0x00007FF742E038A0 node_draw_basis
blender.exe :0x00007FF742E06630 node_draw_default
blender.exe :0x00007FF742E03450 draw_nodetree
blender.exe :0x00007FF742E06D70 node_draw_space
blender.exe :0x00007FF7429F5B20 ED_region_do_draw
blender.exe :0x00007FF742513680 wm_draw_window_offscreen
blender.exe :0x00007FF7425134D0 wm_draw_window
blender.exe :0x00007FF742512FD0 wm_draw_update
blender.exe :0x00007FF7424EEC00 WM_main
blender.exe :0x00007FF742182EA0 main
blender.exe :0x00007FF747025F08 __scrt_common_main_seh
KERNEL32.DLL :0x00007FFBC0537020 BaseThreadInitThunk
ntdll.dll :0x00007FFBC2502630 RtlUserThreadStart
So perhaps an easier solution would be to have render_complete respect the lock interface setting? Although that would still leave render_init open to problems if it's also not on the main python thread?
Access Violation due to some handlers not running on the main thread (Speak to Pedro, he mentioned he'd moved all python code to run on the main thread, maybe some slipped through the net?)to Access Violation due to some handlers not running on the main thread and still updating the UI even when lock UI is set to true.Here's a simple example file showing how to force all render handlers onto the main thread:
force render handlers onto main thread.blend
INSTRUCTIONS:
Access Violation due to some handlers not running on the main thread and still updating the UI even when lock UI is set to true.to Thread race condition with lock interface enabledChanged status from 'Needs Triage' to: 'Confirmed'
@3di can reproduce in 3.0 too, I think I was lucky on first try. Issue here seems to be, that
use_lock_interface
property is used only by 3D viewport. I don't know why more editors don't use this property though.I think It's best to add this to description too.
@iss You're a legend! Could you tell me when you're fix will be applied to master, and which versions it'll apply to please? Does it stop the image editor opening during render, and can the user still press escape to cancel a render?
I did find a workaround of:
overwrite default keymap on addon initialisation so that render.render would be called from an operator in my addon (so that I could handle render_init code before the render.render call, instread of using the render_init handler), and then using a queue to do move the render_complete code to a function run by the main thread once the rendering thread had closed down.
Do you know if it's possible to cancel a render from the render_init handler by the way?
I will leave this decision on nodes & physics module owners, because I don't know why this is implemented this way, nor can I say that this would be a good change. Even though it looks safe...
ah ok, got you. Thanks 👍