PointerProperty in UI slows down extremely #91387

Open
opened 2021-09-13 20:58:39 +02:00 by Matthias Thurau · 14 comments

System Information
Windows 10

Blender Version
Blender 2.83.17

Short description of error
Creating a python script that utilizes bpy.props.PointerProperty suddenly slows down when rendered in the UI. This happens proportional to the amount of elements in a custom CollectionProperty in bpy.types.scene.

Exact steps for others to reproduce the error

  • Run the script attached
  • You should see a two categories in your 3d viewport.
  • The category UI called "INT PROPERTY" has normal behavior and speed.
  • the category UI called "POINTER PROPERTY" is extremely slow.
    (change the amount of items in line 161 of the script to slow down even more.)

This is a simplified version of the problem that occours for a huge addon developed in my company. We have hundreds of items in the bpy.context.scene.CollectionProperty as well as tens of UIs with tens of PointerPropertys. We are running into huge performance problems.

bug_pointer_property.py

**System Information** Windows 10 **Blender Version** Blender 2.83.17 **Short description of error** Creating a python script that utilizes bpy.props.PointerProperty suddenly slows down when rendered in the UI. This happens proportional to the amount of elements in a custom CollectionProperty in bpy.types.scene. **Exact steps for others to reproduce the error** - Run the script attached - You should see a two categories in your 3d viewport. - The category UI called "INT PROPERTY" has normal behavior and speed. - the category UI called "POINTER PROPERTY" is extremely slow. (change the amount of items in line 161 of the script to slow down even more.) This is a simplified version of the problem that occours for a huge addon developed in my company. We have hundreds of items in the bpy.context.scene.CollectionProperty as well as tens of UIs with tens of PointerPropertys. We are running into huge performance problems. [bug_pointer_property.py](https://archive.blender.org/developer/F10409601/bug_pointer_property.py)

Added subscriber: @Zweistein

Added subscriber: @Zweistein
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

Can confirm it is extremely slow, seems like it spends most of its time trying to figure out if the button is animated:

image.png

Usually performance issues are not considered bugs, but I will confirm this for now and see if #user_interface or #animation_rigging can classify this.

Can confirm it is extremely slow, seems like it spends most of its time trying to figure out if the button is animated: ![image.png](https://archive.blender.org/developer/F10412563/image.png) Usually performance issues are not considered bugs, but I will confirm this for now and see if #user_interface or #animation_rigging can classify this.
Member

Added subscribers: @mont29, @dr.sybren

Added subscribers: @mont29, @dr.sybren
Member

@mont29, @dr.sybren : Can the whole BKE_animdata_driver_path_hack from 8cb1b35bee go? (since this seems to be from times where there could be FCurves outside AnimData)

I also dont quite get how (all of a sudden) AnimData can be non-NULL:

If the BKE_animdata_driver_path_hack stuff can go, the example script from this report gets super snappy again (and drivers still seems to work properly):
P2392: T91387_snippet



diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 8e9c504dcbf..376dfdd86bf 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -431,11 +431,13 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
         C ? 2 : 1);
     char *path = NULL;
 
+    /*
     if (!adt && C) {
       path = BKE_animdata_driver_path_hack(C, &tptr, prop, NULL);
       adt = BKE_animdata_from_id(tptr.owner_id);
       step--;
     }
+    */
 
     /* Standard F-Curve - Animation (Action) or Drivers. */
     while (adt && step--) {
@mont29, @dr.sybren : Can the whole `BKE_animdata_driver_path_hack` from 8cb1b35bee go? (since this seems to be from times where there could be FCurves outside AnimData) I also dont quite get how (all of a sudden) AnimData can be non-NULL: - we get NULL from `BKE_animdata_from_id` https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/fcurve.c$428 - we call `BKE_animdata_driver_path_hack` - why should it ever be non-NULL afterwards? (`BKE_animdata_from_id` is called again after `BKE_animdata_driver_path_hack`) - if it stays NULL, all the rest of `BKE_fcurve_find_by_rna_context_ui` will be skipped anyways... If the `BKE_animdata_driver_path_hack` stuff can go, the example script from this report gets super snappy again (and drivers still seems to work properly): [P2392: T91387_snippet](https://archive.blender.org/developer/P2392.txt) ``` diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 8e9c504dcbf..376dfdd86bf 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -431,11 +431,13 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C, C ? 2 : 1); char *path = NULL; + /* if (!adt && C) { path = BKE_animdata_driver_path_hack(C, &tptr, prop, NULL); adt = BKE_animdata_from_id(tptr.owner_id); step--; } + */ /* Standard F-Curve - Animation (Action) or Drivers. */ while (adt && step--) { ```
Member

In #91387#1219956, @lichtwerk wrote:
If the BKE_animdata_driver_path_hack stuff can go, the example script from this report gets super snappy again (and drivers still seems to work properly):

Well, at least when it is not animated/driven ;)
As soon as that is the case, we get the similar bottleneck a bit further down [that is already commented to be slow -- also needs to call RNA_path_from_ID_to_property], but at least we are not calling it twice!
https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/fcurve.c$447

> In #91387#1219956, @lichtwerk wrote: > If the `BKE_animdata_driver_path_hack` stuff can go, the example script from this report gets super snappy again (and drivers still seems to work properly): Well, at least when it is not animated/driven ;) As soon as that is the case, we get the similar bottleneck a bit further down [that is already commented to be slow -- also needs to call `RNA_path_from_ID_to_property`], but at least we are not calling it twice! https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/fcurve.c$447
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly

I really hoped and tested this bug with Blender 3.0.0 and I have to confirm that it is sadly still there.

Is there a known workaround?

I really hoped and tested this bug with Blender 3.0.0 and I have to confirm that it is sadly still there. Is there a known workaround?

Yes, cool, there is a workaround:
If i change the pointed-to IntProperty "options", then it seems to be fast:

#create property group
class MyPointerProperty(bpy.types.PropertyGroup):
    my_int_property: bpy.props.IntProperty(options={'HIDDEN'})

The default is options={'ANIMATABLE'} as per documentation.

Yes, cool, there is a workaround: If i change the pointed-to IntProperty "options", then it seems to be fast: ``` #create property group class MyPointerProperty(bpy.types.PropertyGroup): my_int_property: bpy.props.IntProperty(options={'HIDDEN'}) ``` The default is options={'ANIMATABLE'} as per documentation.

In #91387#1276064, @Zweistein wrote:
I really hoped and tested this bug with Blender 3.0.0 and I have to confirm that it is sadly still there.

The task is still open, and not closed as "Resolved". There is no reason to think it's been resolved already.

> In #91387#1276064, @Zweistein wrote: > I really hoped and tested this bug with Blender 3.0.0 and I have to confirm that it is sadly still there. The task is still open, and not closed as "Resolved". There is no reason to think it's been resolved already.

This issue was referenced by 025c921416

This issue was referenced by 025c9214165ca9e43d3c281c326bf4887c32d642

In #91387#1219956, @lichtwerk wrote:
Can the whole BKE_animdata_driver_path_hack from 8cb1b35bee go?

Yes! It's gone since 025c921416 :)
It's replaced with a call to RNA_path_from_ID_to_property(), though, so the code isn't going to be any faster. It's much clearer, though.

I also dont quite get how (all of a sudden) AnimData can be non-NULL:

Some years ago BKE_animdata_driver_path_hack() still did a lot more, and could probably have caused the anim data to appear.
Now, though, RNA_path_from_ID_to_property() it's not changing tptr so the NULL pointer stays.

If the BKE_animdata_driver_path_hack stuff can go, the example script from this report gets super snappy again (and drivers still seems to work properly):
P2392: T91387_snippet



diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 8e9c504dcbf..376dfdd86bf 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -431,11 +431,13 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C,
         C ? 2 : 1);
     char *path = NULL;
 
+    /*
     if (!adt && C) {
       path = BKE_animdata_driver_path_hack(C, &tptr, prop, NULL);
       adt = BKE_animdata_from_id(tptr.owner_id);
       step--;
     }
+    */
 
     /* Standard F-Curve - Animation (Action) or Drivers. */
     while (adt && step--) {

Yup, nuke it!

> In #91387#1219956, @lichtwerk wrote: > Can the whole `BKE_animdata_driver_path_hack` from 8cb1b35bee go? Yes! It's gone since 025c921416 :) It's replaced with a call to `RNA_path_from_ID_to_property()`, though, so the code isn't going to be any faster. It's much clearer, though. > I also dont quite get how (all of a sudden) AnimData can be non-NULL: > - we get NULL from `BKE_animdata_from_id` https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/fcurve.c$428 > - we call `BKE_animdata_driver_path_hack` > - why should it ever be non-NULL afterwards? (`BKE_animdata_from_id` is called again after `BKE_animdata_driver_path_hack`) > - if it stays NULL, all the rest of `BKE_fcurve_find_by_rna_context_ui` will be skipped anyways... Some years ago `BKE_animdata_driver_path_hack()` still did a lot more, and could probably have caused the anim data to appear. Now, though, `RNA_path_from_ID_to_property()` it's not changing `tptr` so the `NULL` pointer stays. > If the `BKE_animdata_driver_path_hack` stuff can go, the example script from this report gets super snappy again (and drivers still seems to work properly): > [P2392: T91387_snippet](https://archive.blender.org/developer/P2392.txt) ``` diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 8e9c504dcbf..376dfdd86bf 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -431,11 +431,13 @@ FCurve *BKE_fcurve_find_by_rna_context_ui(bContext *C, C ? 2 : 1); char *path = NULL; + /* if (!adt && C) { path = BKE_animdata_driver_path_hack(C, &tptr, prop, NULL); adt = BKE_animdata_from_id(tptr.owner_id); step--; } + */ /* Standard F-Curve - Animation (Action) or Drivers. */ while (adt && step--) { ``` Yup, nuke it!
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:35:31 +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
6 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#91387
No description provided.