MathVis sometimes refers to outdated vars #91111

Closed
opened 2021-09-01 14:43:18 +02:00 by Gaia Clary · 11 comments
Member

System Information
Operating system: windwos-10
Graphics card: nvidia

Blender Version
Broken: master
Worked: n.a.

i have observed that the MathVis addon sometimes creates a stack trace because of outdated variables in the console. Below i added a brief information about how to reproduce the issue.

In general terms: i found the problem results from the function console_namespace() . Sometimes the returned console vars result in a stacktrace:

Traceback (most recent call last):
  File "C:\...\3.0\scripts\addons\space_view3d_math_vis\draw.py", line 151, in draw_callback_view
    data_matrix, data_quat, data_euler, data_vector, data_vector_array = utils.console_math_data()
  File "C:\...\3.0\scripts\addons\space_view3d_math_vis\utils.py", line 171, in console_math_data
    if isinstance(var, Matrix):
ReferenceError: StructRNA of type Object has been removed

This issue seems to be related to loading a new scene from file. In that case it looks like the console is not updated consistently. The question is: what exactly leads to console.locals containing outdated vars ?

Is this something to be taken care off in the blender core functions ?
Or are the Addons expected to check for outdated vars on their own ?

I can add a try-exception block to avoid trace dumps, but maybe it is more correct to take care that the console data is always consistent with the blender scene?

Here is a recipe for making the issue visible:

  • Restart blender to be sure everything is fresh
  • Make sure Math Vis is enabled
  • Create an armature with a single bone
  • go to pose mode
  • open the Python console
  • type: mat = bpy.context.active_pose_bone.matrix

Now the mat is displayed in the viewport with name and bbox as expected.

  • load a new blender scene ( File -> New -> General)
  • observe 1: the item drawn by Math Vis is still displayed
  • observe 2: the MathVis var list contains nothing (no vars to display)
  • now click: Hide names in the Math Vis UI
  • observe 3: the Math Var list is populated
  • in the python console: ype var and see the variable does not exist.
**System Information** Operating system: windwos-10 Graphics card: nvidia **Blender Version** Broken: master Worked: n.a. i have observed that the MathVis addon sometimes creates a stack trace because of outdated variables in the console. Below i added a brief information about how to reproduce the issue. In general terms: i found the problem results from the function console_namespace() . Sometimes the returned console vars result in a stacktrace: ``` Traceback (most recent call last): File "C:\...\3.0\scripts\addons\space_view3d_math_vis\draw.py", line 151, in draw_callback_view data_matrix, data_quat, data_euler, data_vector, data_vector_array = utils.console_math_data() File "C:\...\3.0\scripts\addons\space_view3d_math_vis\utils.py", line 171, in console_math_data if isinstance(var, Matrix): ReferenceError: StructRNA of type Object has been removed ``` This issue seems to be related to loading a new scene from file. In that case it looks like the console is not updated consistently. The question is: what exactly leads to console.locals containing outdated vars ? Is this something to be taken care off in the blender core functions ? Or are the Addons expected to check for outdated vars on their own ? I can add a try-exception block to avoid trace dumps, but maybe it is more correct to take care that the console data is always consistent with the blender scene? Here is a recipe for making the issue visible: - Restart blender to be sure everything is fresh - Make sure Math Vis is enabled - Create an armature with a single bone - go to pose mode - open the Python console - type: `mat = bpy.context.active_pose_bone.matrix` Now the mat is displayed in the viewport with name and bbox as expected. - load a new blender scene ( `File -> New -> General`) - observe 1: the item drawn by Math Vis is still displayed - observe 2: the MathVis var list contains nothing (`no vars to display`) - now click: Hide names in the Math Vis UI - observe 3: the Math Var list is populated - in the python console: ype `var` and see the variable does not exist.
Author
Member

Added subscriber: @GaiaClary

Added subscriber: @GaiaClary
Author
Member

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Author
Member

It looks pretty much like the Math Vis itemlist is preserved when a new file is loaded. So the main questions remains:

  • Is it on purpose that the Math Vis itemlist is not refreshed upon loading a new scene ?
  • Do i handle the issue in Math Vis or is this an issue that is handled by the Scene loader ?

According to @ideasman42 in blender chat: "no, WM data isn't saved." But somehow it appearas to me this contradicts to what i see.

It looks pretty much like the Math Vis itemlist is preserved when a new file is loaded. So the main questions remains: - Is it on purpose that the Math Vis itemlist is not refreshed upon loading a new scene ? - Do i handle the issue in Math Vis or is this an issue that is handled by the Scene loader ? According to @ideasman42 in blender chat: "no, WM data isn't saved." But somehow it appearas to me this contradicts to what i see.

There was no convenient way to check if a mathutils value has an invalid owner.

Committed support for conveniently checking this blender/blender@0950cfd9d5.

Suggest to skip values that aren't valid.

There was no convenient way to check if a mathutils value has an invalid owner. Committed support for conveniently checking this blender/blender@0950cfd9d5. Suggest to skip values that aren't valid.
Author
Member

@ideasman42 There is something wrong still even when i use your fix:

  • I start blender (factory settings)
  • in the python console i add a var v=Vector((0,1,2))
  • v.is_valid returns True as expected
  • File -> new -> general
  • v does no longer exist but in MathVis it is still in the itemlist:
    for key, var in console_namespace().items():
        if not getattr(var, 'is_valid', False):
            continue
        - v appearas here and v.is_valid is True although
        - it does no longer exist in the python console.
        - Hence the vector is still displayed correctly
        - although it does no longer exist 

I suspect that maybe two console instances are involved ?

@ideasman42 There is something wrong still even when i use your fix: - I start blender (factory settings) - in the python console i add a var v=Vector((0,1,2)) - v.is_valid returns True as expected - File -> new -> general - v does no longer exist but in MathVis it is still in the itemlist: ``` for key, var in console_namespace().items(): if not getattr(var, 'is_valid', False): continue - v appearas here and v.is_valid is True although - it does no longer exist in the python console. - Hence the vector is still displayed correctly - although it does no longer exist ``` I suspect that maybe two console instances are involved ?
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Is this still an issue? I can't replicate it myself. No variables are displayed after a new file, and window_manager.MathVisStatePropList is empty.

Is this still an issue? I can't replicate it myself. No variables are displayed after a new file, and window_manager.MathVisStatePropList is empty.
Member

Just a poke regarding my inquiry above, otherwise, we will have to archive this for now.

Just a poke regarding my inquiry above, otherwise, we will have to archive this for now.
Member

Changed status from 'Needs User Info' to: 'Archived'

Changed status from 'Needs User Info' to: 'Archived'
Member

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed.

Thanks again for the report. If the problem persists please open a new report with the required information.

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed. Thanks again for the report. If the problem persists please open a new report with the required information.
Sign in to join this conversation.
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-addons#91111
No description provided.