JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
572 stars 75 forks source link

Blender: Run Script - Exception Access Violation error #40

Closed risa2000 closed 5 years ago

risa2000 commented 5 years ago

I have been trying to make the add-on running with the recent build (blender-2.80.0-git.030c7df19da9-windows64), but even when running just the "empty" script (created by the add-on) the command Blender: Run Script triggers an exception in Blender and shuts it down.

Blender: Start outputs:

> Executing task in folder openvr: d:\Dev\blender-2.80.0-git.0fd96b4128ff-windows64\blender.exe --python C:\Users\risa\.vscode\extensions\jacqueslucke.blender-development-0.0.12\pythonFiles\launch.py <

Read prefs: C:\Users\risa\AppData\Roaming\Blender Foundation\Blender\2.80\config\userpref.blend
found bundled python: d:\Dev\blender-2.80.0-git.0fd96b4128ff-windows64\2.80\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:9448/ (Press CTRL+C to quit)
Sending: {'type': 'setup', 'blenderPort': 9448, 'ptvsdPort': 2120, 'blenderPath': 'd:\\Dev\\blender-2.80.0-git.0fd96b4128ff-windows64\\blender.exe', 'scriptsFolder': 'd:\\Dev\\blender-2.80.0-git.0fd96b4128ff-windows64\\2.80\\scripts', 'addonPathMappings': []}
Waiting for debug client.
Debug client attached.

following Blender: Run Script leads to:

Got GET: {'type': 'ping'}
127.0.0.1 - - [15/Jun/2019 12:53:11] "GET / HTTP/1.1" 200 -
Got POST: {'type': 'script', 'path': 'd:\\Work\\python\\test\\script 58e9321aae.py'}
127.0.0.1 - - [15/Jun/2019 12:53:11] "POST / HTTP/1.1" 200 -
Error   : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF67C1D8A90
Module  : d:\Dev\blender-2.80.0-git.0fd96b4128ff-windows64\blender.exe
The terminal process terminated with exit code: 11

The file script 58e9321aae.py is the default one:

import bpy
from mathutils import *
D = bpy.data
C = bpy.context

I saw it first on Blender version few days old, so I updated the fresh one today, but the error remains the same.

kobligo commented 5 years ago

Getting the exact same error here every time I save a script and this plug-in attempts to auto-reload my addon module. I hope this is just due to a simple API change. Help, Jacques, help! People at work depend on me.

Edit: I did a bit of debugging myself (I'm not a programmer mind you.) and it appears that the line causing the exception is line 16 in addons_update.py: bpy.ops.preferences.addon_disable(module=self.module_name) As soon as that line is executed, Blender crashes. The module_name string correct, so it must be the function itself. (Calling it from Blender's own python console works just fine btw.) That's all I can do to help.

JacquesLucke commented 5 years ago

I can confirm the issue. Unfortunately, I'm not entirely sure how to solve this correctly yet...

The issue is that the scripts run in a timer, which is context independent. However, e.g. when calling an operator, Blender always accesses some stuff in the context currently. It's unclear to me whether this is something I can completely fix in the addon, or if we need a better API for it in Blender.

Unfortunately, that means that the Run Script operator won't work for a while now....

jessey-git commented 5 years ago

Looks like this is the same issue as the "Reload Addons" action as well -- Issue #38

Hopefully a proper fix can be found soon :-/

jessey-git commented 5 years ago

Sergey may have just fixed this on Blender's side: https://developer.blender.org/T65806

Try again with a recent git build of Blender and see if this one is fixed too (Issue #38 seems to be now)

risa2000 commented 5 years ago

Tested with the recent build (from the 20th of June), the exception is still there:

> Executing task in folder openvr: d:\Dev\blender-2.80.0-git.d30f72dfd8ac-windows64\blender.exe --python C:\Users\risa\.vscode\extensions\jacqueslucke.blender-development-0.0.12\pythonFiles\launch.py <

Read prefs: C:\Users\risa\AppData\Roaming\Blender Foundation\Blender\2.80\config\userpref.blend
found bundled python: d:\Dev\blender-2.80.0-git.d30f72dfd8ac-windows64\2.80\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:8695/ (Press CTRL+C to quit)
Sending: {'type': 'setup', 'blenderPort': 8695, 'ptvsdPort': 8573, 'blenderPath': 'd:\\Dev\\blender-2.80.0-git.d30f72dfd8ac-windows64\\blender.exe', 'scriptsFolder': 'd:\\Dev\\blender-2.80.0-git.d30f72dfd8ac-windows64\\2.80\\scripts', 'addonPathMappings': []}
Waiting for debug client.
Debug client attached.
Got GET: {'type': 'ping'}
127.0.0.1 - - [20/Jun/2019 12:08:16] "GET / HTTP/1.1" 200 -
Got POST: {'type': 'script', 'path': 'd:\\Work\\python\\test\\script ad90770d6d.py'}
127.0.0.1 - - [20/Jun/2019 12:08:16] "POST / HTTP/1.1" 200 -
Error   : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF7E9A88EE0
Module  : d:\Dev\blender-2.80.0-git.d30f72dfd8ac-windows64\blender.exe
The terminal process terminated with exit code: 11
JacquesLucke commented 5 years ago

Seems to be fixed for me as well.

@risa2000 Your build is from yesterday. This fix has been committed today. Please try tomorrows buildbot build.

Besides that, a better solution is still necessary...

risa2000 commented 5 years ago

Just to let you know, do not wait for me. I will be away from the keyboard for week or so, starting tomorrow, so I will not be able to test it.

kobligo commented 5 years ago

Just tested it. The issue has been fixed. Excellent!

ViopAl commented 4 years ago

HI, Issue still there for me on blender 2.82a , vscode 1.43.1 and Blender development 0.0.12