Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when adding mesh #63

Closed
CarstenHoyer opened this issue Feb 18, 2020 · 5 comments
Closed

Crash when adding mesh #63

CarstenHoyer opened this issue Feb 18, 2020 · 5 comments

Comments

@CarstenHoyer
Copy link

CarstenHoyer commented Feb 18, 2020

OS: macOS Mojave 10.14.5
Blender version: Version 2.81 (2.81 2019-11-20)
VS Code: Version: 1.42.1 Commit: c47d83b293181d9be64f27ff093689e8e7aed054

>Python: Select interpreter
/usr/local/bin/python3 -> /Applications/Blender.app/Contents/Resources/2.81/python/bin/python3.7m

>Blender: Start --> pick /Applications/Blender.app/Contents/MacOS/blender

> Executing task: /Applications/Blender.app/Contents/MacOS/blender --python /Users/me/.vscode/extensions/jacqueslucke.blender-development-0.0.12/pythonFiles/launch.py <

Read prefs: /Users/me/Library/Application Support/Blender/2.81/config/userpref.blend
found bundled python: /Applications/Blender.app/Contents/Resources/2.81/python
[]

  • Serving Flask app "Blender Server" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://127.0.0.1:7419/ (Press CTRL+C to quit)
    Sending: {'type': 'setup', 'blenderPort': 7419, 'ptvsdPort': 2897, 'blenderPath': '/Applications/Blender.app/Contents/MacOS/blender', 'scriptsFolder': '/Applications/Blender.app/Contents/MacOS/2.81/scripts', 'addonPathMappings': []}
    Waiting for debug client.
    Debug client attached.
    Got GET: {'type': 'ping'}
    127.0.0.1 - - [18/Feb/2020 06:38:45] "GET / HTTP/1.1" 200 -
    Got POST: {'type': 'script', 'path': '/Users/me/Workspace/blender/script d9e1873a82.py'}
    127.0.0.1 - - [18/Feb/2020 06:38:45] "POST / HTTP/1.1" 200 -
    Writing: /var/folders/1k/jt297hcd28dc3rkbv3kkz6k80000gn/T/blender.crash.txt

Terminal will be reused by tasks, press any key to close it.

Executing task: /Applications/Blender.app/Contents/MacOS/blender --python /Users/me/.vscode/extensions/jacqueslucke.blender-development-0.0.12/pythonFiles/launch.py <

Read prefs: /Users/me/Library/Application Support/Blender/2.81/config/userpref.blend
found bundled python: /Applications/Blender.app/Contents/Resources/2.81/python
[]

  • Serving Flask app "Blender Server" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://127.0.0.1:6874/ (Press CTRL+C to quit)
    Sending: {'type': 'setup', 'blenderPort': 6874, 'ptvsdPort': 8568, 'blenderPath': '/Applications/Blender.app/Contents/MacOS/blender', 'scriptsFolder': '/Applications/Blender.app/Contents/MacOS/2.81/scripts', 'addonPathMappings': []}
    Waiting for debug client.
    Debug client attached.

With this simple script:

# context.area: VIEW_3D
import bpy
from mathutils import *

D = bpy.data
C = bpy.context

bpy.ops.mesh.primitive_ico_sphere_add(location=Vector((0,0,0)), radius=1.0)

>Blender: Run Script

Debug console

Debug client attached. Got GET: {'type': 'ping'} Got POST: {'type': 'script', 'path': '/Users/me/Workspace/blender/script d9e1873a82.py'}

Terminal

Got GET: {'type': 'ping'} 127.0.0.1 - - [18/Feb/2020 06:42:28] "GET / HTTP/1.1" 200 - Got POST: {'type': 'script', 'path': '/Users/me/Workspace/blender/script d9e1873a82.py'} 127.0.0.1 - - [18/Feb/2020 06:42:28] "POST / HTTP/1.1" 200 - Writing: /var/folders/1k/jt297hcd28dc3rkbv3kkz6k80000gn/T/blender.crash.txt

Blender crash report

# Blender 2.81 (sub 16), Commit date: 2019-11-20 14:27, Hash 26bd5ebd42e3 bpy.ops.mesh.primitive_ico_sphere_add(radius=1, enter_editmode=False, location=(0, 0, 0)) # Operator

backtrace

0 blender 0x000000010344cea7 BLI_system_backtrace + 55
1 blender 0x000000010316bbea sig_handle_crash + 362
2 libsystem_platform.dylib 0x00007fff5bed6b5d _sigtramp + 29
3 ??? 0x0000000000000000 0x0 + 0
4 blender 0x0000000107503418 extract_run + 632
5 blender 0x00000001074fbd18 extract_task_create + 632
6 blender 0x00000001074fb830 mesh_buffer_cache_create_requested + 4224
7 blender 0x000000010750e0c9 DRW_mesh_batch_cache_create_requested + 13145
8 blender 0x000000010751b10f drw_engines_cache_populate + 191
9 blender 0x000000010751a361 DRW_draw_render_loop_ex + 1025
10 blender 0x0000000107802a8d view3d_main_region_draw + 125
11 blender 0x000000010787394e ED_region_do_draw + 366
12 blender 0x000000010367564b wm_draw_update + 1899
13 blender 0x00000001036732a0 WM_main + 48
14 blender 0x000000010316840f main + 927
15 libdyld.dylib 0x00007fff5bceb3d5 start + 1

@JacquesLucke
Copy link
Owner

Unfortunately, there is an annoying limitation with running these scripts in Blender currently. They must not access any context (and operators access context). I've thought about solutions for the fundamental problem of triggering operators in Blender from the outside multiple times. I did not find the time to implement any of that yet though.... That's still on my todo list.

@CarstenHoyer
Copy link
Author

Oh, so I guess it is the same thing at play here: #68 ?

@dorcatty
Copy link

dorcatty commented Aug 6, 2020

same issue with Blender v2.83.2
but i confirm that it works well with Blender v2.80.rc
no ops issues, adding mesh causes no crash.

@MatthiasThDs
Copy link

@JacquesLucke Did you find a solution for this yet? I have problems with all bpy.ops.mesh.xx functions it seems and maybe this is related.

CGArtPython added a commit to CGArtPython/blender_vscode that referenced this issue Jan 8, 2023
…e when run from VS Code Extension JacquesLucke#135

# Summary of issue
Calling a script via operator results in an empty context.

# Related devtalk.blender
from @JacquesLucke
https://devtalk.blender.org/t/how-to-run-a-script-from-outside-blender-script-live-link-addon/9792/3?u=jacqueslucke

# Solution
Use bpy.app.timers to register a function to run the target script.

# Changes
pythonFiles\include\blender_vscode\operators\script_runner.py
* remove the RunScriptOperator and move the contents of the execute method into a the `run_script()` function
* register a timer callback to the `run_script()` function that will execute the target script

# Potentially related issues
* When adding objects to collections the objects only show after the script ends. JacquesLucke#101
* accessing bpy.context.object crashes Blender JacquesLucke#86
* Crash when adding mesh JacquesLucke#63
* Delete is skipped JacquesLucke#68

# Testing
* execute a simple script that uses `bpy.context.active_object`
* set the #context.area:   SEQUENCE_EDITOR and run this script https://github.com/CGArtPython/blender_plus_python/blob/main/sequence_editor_frame_import/sequence_editor_frame_import_done.py
* execute the script from issue JacquesLucke#101 JacquesLucke#101
* execute the script from issue JacquesLucke#86 JacquesLucke#86
* execute the script from issue JacquesLucke#63 JacquesLucke#63
* execute the script from issue JacquesLucke#68 JacquesLucke#68
* execute the script from issue JacquesLucke#41 JacquesLucke#41
CGArtPython added a commit to CGArtPython/blender_vscode that referenced this issue Apr 2, 2023
…e when run from VS Code Extension JacquesLucke#135

# Summary of issue
Calling a script via operator results in an empty context.

# Related devtalk.blender
from @JacquesLucke
https://devtalk.blender.org/t/how-to-run-a-script-from-outside-blender-script-live-link-addon/9792/3?u=jacqueslucke

# Solution
Use bpy.app.timers to register a function to run the target script.

# Changes
pythonFiles\include\blender_vscode\operators\script_runner.py
* remove the RunScriptOperator and move the contents of the execute method into a the `run_script()` function
* register a timer callback to the `run_script()` function that will execute the target script

# Potentially related issues
* When adding objects to collections the objects only show after the script ends. JacquesLucke#101
* accessing bpy.context.object crashes Blender JacquesLucke#86
* Crash when adding mesh JacquesLucke#63
* Delete is skipped JacquesLucke#68

# Testing
* execute a simple script that uses `bpy.context.active_object`
* set the #context.area:   SEQUENCE_EDITOR and run this script https://github.com/CGArtPython/blender_plus_python/blob/main/sequence_editor_frame_import/sequence_editor_frame_import_done.py
* execute the script from issue JacquesLucke#101 JacquesLucke#101
* execute the script from issue JacquesLucke#86 JacquesLucke#86
* execute the script from issue JacquesLucke#63 JacquesLucke#63
* execute the script from issue JacquesLucke#68 JacquesLucke#68
* execute the script from issue JacquesLucke#41 JacquesLucke#41
CGArtPython added a commit to CGArtPython/blender_vscode that referenced this issue Apr 2, 2023
…e when run from VS Code Extension JacquesLucke#135

# Summary of issue
Calling a script via operator results in an empty context.

# Related devtalk.blender
from @JacquesLucke
https://devtalk.blender.org/t/how-to-run-a-script-from-outside-blender-script-live-link-addon/9792/3?u=jacqueslucke

# Solution
Use bpy.app.timers to register a function to run the target script.

# Changes
pythonFiles\include\blender_vscode\operators\script_runner.py
* remove the RunScriptOperator and move the contents of the execute method into a the `run_script()` function
* register a timer callback to the `run_script()` function that will execute the target script

# Potentially related issues
* When adding objects to collections the objects only show after the script ends. JacquesLucke#101
* accessing bpy.context.object crashes Blender JacquesLucke#86
* Crash when adding mesh JacquesLucke#63
* Delete is skipped JacquesLucke#68

# Testing
* execute a simple script that uses `bpy.context.active_object`
* set the #context.area:   SEQUENCE_EDITOR and run this script https://github.com/CGArtPython/blender_plus_python/blob/main/sequence_editor_frame_import/sequence_editor_frame_import_done.py
* execute the script from issue JacquesLucke#101 JacquesLucke#101
* execute the script from issue JacquesLucke#86 JacquesLucke#86
* execute the script from issue JacquesLucke#63 JacquesLucke#63
* execute the script from issue JacquesLucke#68 JacquesLucke#68
* execute the script from issue JacquesLucke#41 JacquesLucke#41
@CGArtPython
Copy link
Collaborator

I am closing this issue.
This was resolved with this commit 621e275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants