Fix #105325: crash calling asset_generate_preview() in backgound mode #106046

Merged
Philipp Oeser merged 1 commits from lichtwerk/blender:105325 into main 2023-03-24 09:17:12 +01:00
Member

.asset_generate_preview() internally calls UI_icon_render_id as a
job -- as opposed to .preview_ensure() [which internally also calls
UI_icon_render_id, but not as a job] leading to crashes in background
mode.

This might be due to the fact that OpenGL context is not set up
correctly (so there might be other ways to fix this), but there seems to
be other places/comments indicating that icon handling is only for main
thread (see e.g. 13beeb5892).
And while this does not fully explain why doing this with jobs works fine
from the UI, the patch certainly fixes the crashes in background mode for
now (by not using jobs).

`.asset_generate_preview()` internally calls `UI_icon_render_id` as a job -- as opposed to `.preview_ensure()` [which internally also calls `UI_icon_render_id`, but not as a job] leading to crashes in background mode. This might be due to the fact that OpenGL context is not set up correctly (so there might be other ways to fix this), but there seems to be other places/comments indicating that icon handling is only for main thread (see e.g. 13beeb589227). And while this does not fully explain why doing this with jobs works fine from the UI, the patch certainly fixes the crashes in background mode for now (by not using jobs).
Philipp Oeser added this to the Pipeline, Assets & IO project 2023-03-23 15:17:50 +01:00
Philipp Oeser requested review from Bastien Montagne 2023-03-23 15:17:58 +01:00
Philipp Oeser requested review from Sybren A. Stüvel 2023-03-23 15:18:08 +01:00
Philipp Oeser added the
Interest
Python API
label 2023-03-23 15:18:19 +01:00
Sybren A. Stüvel approved these changes 2023-03-23 15:23:22 +01:00
Sybren A. Stüvel left a comment
Member

Nice find! Just one simplification, since I don't quite like comparisons to == false or == true. Can be merged without re-review though.

Nice find! Just one simplification, since I don't quite like comparisons to `== false` or `== true`. Can be merged without re-review though.
@ -53,3 +54,3 @@
}
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, (G.background == false));

I'd shorten this to !G.background.

I'd shorten this to `!G.background`.
lichtwerk marked this conversation as resolved
Bastien Montagne approved these changes 2023-03-23 17:50:12 +01:00
Philipp Oeser force-pushed 105325 from ef7f757d0a to 19b36ca24a 2023-03-24 09:13:53 +01:00 Compare
Philipp Oeser merged commit 2fba27e6d8 into main 2023-03-24 09:17:12 +01:00
Philipp Oeser deleted branch 105325 2023-03-24 09:17:13 +01:00
Bastien Montagne removed this from the Pipeline, Assets & IO project 2023-07-03 13:01:30 +02: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#106046
No description provided.