Maniphest T68740

Mask modifier slow when one of its properties is animated/driven
Confirmed, NormalKNOWN ISSUE

Assigned To
None
Authored By
Ovionis (Phigon)
Aug 16 2019, 5:34 PM
Tags
  • BF Blender
  • Performance
  • Modeling
Subscribers
Demeter Dzadik (Mets)
Germano Cavalcante (mano-wii)
Lucas (ElioH)
Ovionis (Phigon)
Sergey Sharybin (sergey)

Description

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 770/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.64

Blender Version
Broken: version: 2.81 (sub 1), branch: master, commit date: 2019-08-14 01:55, hash: rBb3c3c835609e

When one of mask properties is animated/driven, it drops performance excessively, the less it hides.


Exact steps for others to reproduce the error

  1. Open attached file;
  2. Play animation to see the fps;
  3. Add a keyframe (I key) to the Display modifier in viewport.

Event Timeline

Ovionis (Phigon) created this task.Aug 16 2019, 5:34 PM
Demeter Dzadik (Mets) added a subscriber: Demeter Dzadik (Mets).Aug 16 2019, 10:47 PM
Germano Cavalcante (mano-wii) lowered the priority of this task from 90 to 50.Oct 3 2019, 7:42 PM
Germano Cavalcante (mano-wii) updated the task description.
Germano Cavalcante (mano-wii) added a project: Performance.
Germano Cavalcante (mano-wii) assigned this task to Sergey Sharybin (sergey).Oct 3 2019, 7:55 PM
Germano Cavalcante (mano-wii) added subscribers: Sergey Sharybin (sergey), Germano Cavalcante (mano-wii).

I can confirm.
I don't know if this is a known issue or maybe there really is some unnecessary update.

@Sergey Sharybin (sergey), this involves depsgraph and with a quick profiler I realized that applyModifier is responsible for 53.86% of the total frame time.
Is this expected?

Demeter Dzadik (Mets) added a comment.Oct 3 2019, 10:46 PM

(This affects playback performance at the studio! 👀)

Sergey Sharybin (sergey) changed the task status from Unknown Status to Unknown Status.Oct 7 2019, 4:02 PM

By adding animation to the modifier stack you effectively make it so the modifier stack depends on time (since animation depends on time, and modifier stack depends on animation).

There is no tracking of state happening, so when input (such as time) changes the update is propagating through the entire hierarchy, without any checks done from the previous evaluation.

So it is expected that modifier stack is re-evaluating in this case.

Solving this is not impossible, but it would require changing animation system and the way how updates are propagating. And it's really tricky to make reliable without performance regression for the case when real animation is involved.

What you can try doing is to have a pre-update handler and disable visibility of modifier if it's in a state which you don't want it to (as in, don't just assign the value, compare the value first to avoid the block being tagged for update).

This affects playback performance at the studio!

If you have static object where you want to control something on per-shot basis then just create a rig for that object and use driver from that rig. And don't animate the rig.

If it's an object which is belongs to an animated character, then it does need to be re-evaluated and there is no way around it.

All in all, such issues are touching fundamental designs which can not be tackled in a nearest future and hence are handled outside of the bug tracker.

Demeter Dzadik (Mets) added a comment.Oct 16 2019, 12:23 PM

I think an interesting idea would be to allow Custom Properties to be set to non-animatable.

Then if a driver only depends on non-animatable properties, it won't be pushing update calls to the modifier stack every frame.

But for now, I can work around this in a number of ways(including as you described, by storing the previous state of the settings and checking against them in pre_depsgraph_update), so for me personally it's not very important, just thought I'd throw this idea out there.

Demeter Dzadik (Mets) reopened this task as Confirmed.EditedJun 16 2020, 4:31 PM
Demeter Dzadik (Mets) changed the subtype of this task from "Report" to "Known Issue".

I wonder if this should be re-opened as a known issue.

I feel like the workaround is quite involved and probably beyond most users. The performance impact for those who can't work around it is massive. Just ran into this again today with a character going from 24 to 15 fps because of a driven mask modifier, and I had to put my python hat on to work around it with app handlers.

Maybe one day someone will have the time and energy to re-think the way these systems interact. For example, adding a check in drivers to check against their previous value and not fire updates if they didn't change, sounds interesting.

Sergey Sharybin (sergey) removed Sergey Sharybin (sergey) as the assignee of this task.EditedSep 7 2020, 5:29 PM

@Demeter Dzadik (Mets), the idea you are suggesting is not impossible to be implemented, but it requires some deep changes in how the system is currently functions. It might also cause worse performance in "real" cases, because it will be more difficult to keep all CPU threads busy bu requiring to wait while tree of animation/drives is evaluated.

P.S. The new status and priority represents the state here better than "Unknown Status" :)
P.P.S. Just to be clear: the idea is interesting to investigate, "just" needs to be done with a lot of care, and is hard to squeeze this into the current agenda.

Richard Antalik (ISS) added a project: Modeling.Nov 24 2020, 8:52 PM
Lucas (ElioH) added a subscriber: Lucas (ElioH).EditedDec 12 2020, 12:55 AM

Hi there,

I was just wondering, is it normal then that this modifier (in my case the mask modifier has visibility in render + viewport being driven, but keyframes seem to be quite fine though) would slow the scene down more or less heavily even without playing the animation, just by moving the object in the viewport ?
Especially in EEVEE, it's quite impressive how slow it can get with a relatively low poly mesh, and without any other object in the scene.

Is that related ?

Bastien Montagne (mont29) moved this task from Backlog to Known Issues on the Modeling board.Dec 24 2020, 9:44 AM