Crash Python API - GPUOffScreen.draw_view3d() crashes blender with draw_type = POST_VIEW but works with draw_type = POST_PIXEL #102526

Closed
opened 2022-11-15 13:23:06 +01:00 by Giuseppe · 9 comments

System Information
Operating system: Windows-10-10.0.22000-SP0 64 Bits
Graphics card: GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.51

Blender Version
Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: b292cfe5a9

Short description of error
When using [GPUOffScreen.draw_view3d() ]] in a draw_handler , blender crashes when running the [ https://docs.blender.org/api/current/gpu.shader.html?highlight=gpu+shader+from_builtin#built-in-shaders | 3D_IMAGE builtin shader if the draw_type was set to POST_VIEW but works if the draw_type was set to POST_PIXEL.

Exact steps for others to reproduce the error

  • Open CrashScriptDrawView3D.blend

  • Run the script Crash3D and blender will crash

  • Open CrashScriptDrawView3D.blend

  • Run the script NoCrash2D, and it will draw the camera view in the viewport without crashing

Attachments:

CrashScriptDrawView3D.blend
blender.crash.txt

**System Information** Operating system: Windows-10-10.0.22000-SP0 64 Bits Graphics card: GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.51 **Blender Version** Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: `b292cfe5a9` **Short description of error** When using [GPUOffScreen.draw_view3d() ]] in a [[ https:*docs.blender.org/api/current/bpy.types.Space.html?highlight=post_view#bpy.types.Space.draw_handler_add | draw_handler ]], blender crashes when running the [[ https://docs.blender.org/api/current/gpu.shader.html?highlight=gpu+shader+from_builtin#built-in-shaders | 3D_IMAGE builtin shader ](https:*docs.blender.org/api/current/gpu.types.html?highlight=draw_view3d#gpu.types.GPUOffScreen.draw_view3d) if the draw_type was set to POST_VIEW but works if the draw_type was set to POST_PIXEL. **Exact steps for others to reproduce the error** - Open CrashScriptDrawView3D.blend - Run the script Crash3D and blender will crash - Open CrashScriptDrawView3D.blend - Run the script NoCrash2D, and it will draw the camera view in the viewport without crashing Attachments: [CrashScriptDrawView3D.blend](https://archive.blender.org/developer/F13917079/CrashScriptDrawView3D.blend) [blender.crash.txt](https://archive.blender.org/developer/F13917087/blender.crash.txt)
Author

Added subscriber: @BetaDab

Added subscriber: @BetaDab
Author

Added subscriber: @regcs

Added subscriber: @regcs
Author

I thought this could be related to #84402, so I tried to use the hack proposed by @regcs in that task.

I added the script NoCrash3D to the file CrashScriptDrawView3D.blend. In this script, I separated the offscreen drawing from the drawing of the offscreen in a prepare() function and a draw() function.

This approach doesn't crash blender, but makes the viewport unresponsive and just draws a black square instead of the camera view.

CrashScriptDrawView3D.blend

I thought this could be related to #84402, so I tried to use the hack proposed by @regcs in that task. I added the script NoCrash3D to the file CrashScriptDrawView3D.blend. In this script, I separated the offscreen drawing from the drawing of the offscreen in a `prepare()` function and a `draw()` function. This approach doesn't crash blender, but makes the viewport unresponsive and just draws a black square instead of the camera view. [CrashScriptDrawView3D.blend](https://archive.blender.org/developer/F13917202/CrashScriptDrawView3D.blend)
Author

System Information
Operating system: Kubuntu 22.04 Linux-5.15.0-53-generic-x86_64-with-glibc2.35 64 Bits
Graphics card: NVIDIA GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.85.02

Blender Version
Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: b292cfe5a9

The script Crash3D also crashes on the same machine with Kubuntu 22.04.

On Kubuntu, the script NoCrash3D behaves differently than windows. Blender doesn't crash, the viewport remains responsive, but draws some psychedelic stuff (lol).

Here are two videos of the viewport after I run the script NoCrash3D on Kubuntu 22.04:
https://youtu.be/wAfb53Cqgq4
https://youtu.be/yzfFezErT4M

In the second video, it seems that there are pieces of the splashscreen being rendered on the square.

**System Information** Operating system: Kubuntu 22.04 Linux-5.15.0-53-generic-x86_64-with-glibc2.35 64 Bits Graphics card: NVIDIA GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.85.02 **Blender Version** Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: `b292cfe5a9` The script Crash3D also crashes on the same machine with Kubuntu 22.04. On Kubuntu, the script NoCrash3D behaves differently than windows. Blender doesn't crash, the viewport remains responsive, but draws some psychedelic stuff (lol). Here are two videos of the viewport after I run the script NoCrash3D on Kubuntu 22.04: https://youtu.be/wAfb53Cqgq4 https://youtu.be/yzfFezErT4M In the second video, it seems that there are pieces of the splashscreen being rendered on the square.
Author

Weirdly enough, if I don't run the prepare() function before adding it as a draw_handler, the workaround proposed by @regcs in #84402 works!

So now I have a workaround that enables me to show the expected behavior. You can test it by running the script WorkingNoCrash3D in the attached file.
CrashScriptDrawView3D.blend

Here is a video of the script running on Kubuntu 22.04:
https://youtu.be/3WMzrdZY0b0

Edit:
Also tested the workaround on windows, and it works.

Weirdly enough, if I don't run the `prepare()` function before adding it as a `draw_handler`, the workaround proposed by @regcs in #84402 works! So now I have a workaround that enables me to show the expected behavior. You can test it by running the script WorkingNoCrash3D in the attached file. [CrashScriptDrawView3D.blend](https://archive.blender.org/developer/F13925091/CrashScriptDrawView3D.blend) Here is a video of the script running on Kubuntu 22.04: https://youtu.be/3WMzrdZY0b0 Edit: Also tested the workaround on windows, and it works.

Added subscriber: @mano-wii

Added subscriber: @mano-wii

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

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

Thanks for the report, I can confirm the problem.

It happens because DRW_draw_render_loop_ex is called inside DRW_draw_render_loop_ex and DRWManager (DST) is recreated causing problems for code continuity.

Thanks for the report, I can confirm the problem. It happens because `DRW_draw_render_loop_ex` is called inside `DRW_draw_render_loop_ex` and `DRWManager` (DST) is recreated causing problems for code continuity.
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:12:02 +01:00
Member

Shader needs to be changed to shader = gpu.shader.from_builtin('IMAGE') in newer versions, but it still crashes in POST_VIEW

Will dare setting this to high priority since it crashes ans is not an uncommon thing to do in my opinion (and the "2d workaround" is not obvious -- and possibly not what the user is after...)

Of course feel free to lower in priority again if this does not feel important enough to fix...

Shader needs to be changed to `shader = gpu.shader.from_builtin('IMAGE')` in newer versions, but it still crashes in `POST_VIEW` Will dare setting this to high priority since it crashes ans is not an uncommon thing to do in my opinion (and the "2d workaround" is not obvious -- and possibly not what the user is after...) Of course feel free to lower in priority again if this does not feel important enough to fix...
Philipp Oeser added
Priority
High
and removed
Priority
Normal
labels 2024-02-26 14:03:16 +01:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-02-27 11:32:51 +01: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#102526
No description provided.