Porting my addons to 2.8 - missing scene_update_post handler


#1

Two of my addons (VSE Quick Functions, and another I have not released yet) rely on the scene_update_post handler, which has been removed along with scene_update_pre
(See the first ‘Open Topic’ at: https://developer.blender.org/T47811 ).

I don’t think this functionality can be properly replicated with a modal operator. I have tried in the past and run into reliability issues, and as far as I know, this isn’t what modal operators are supposed to be used for either. So what am I supposed to use for this now?

I get that it isn’t working the way it was intended right now, but without an effective alternative, removing it entirely is not the solution…


#2

I like to know this too.


#3

Same issue here. Having a way to continously run code is crucial for some addons. If used properly, the overhead it adds to viewport is minor but the benefit is great. So removing it without alternative is a bad choice, please bring it back.


#4

the weekly notes of jun 26 2018 mentioned the following

Handler bpy.app.handlers.scene_update_pre
===========================================

This was being mis-used because of a bug causing it to run constantly.

API's to replace this can be:

- A timer API to run Python code at less frequent intervals,
  encourage timers to run less frequently,
  the timer must be explicitly told to run again each time
  (avoiding timers being left enabled)

  - Bastien handles.

- Another use case use synchronizing data
  a depsgraph API needs to handle this.

  - Sergey handles.

So it’s unlikely this handler is going to be back, @mont29 might be able to comment on how far out the replacement api is.


#5

So this is unclear. is scene_update_post handler still possible with 2.8? Or just the scene_update_pre going away?


#6

Both pre and post are gone.


#7

Any replacement planned? The ability to run code on scene updates and repeteadly is a very much needed feature for some addons.


#8

There will be a replacement, it’s not clear yet what form it will take.


#9

For me and other this means our addons will not work with 2.8 - I made 2 years of work in add-ons and sold on Blendermarket, donate to Blender and users where very happy. Now start from scratch again? I cannot do. Like I ask you “start Blender from scratch again cause we made changes to C and remove 50% of what Blender use”.


#10

There is no need to start from scratch. There will be a replacement for this function.


#11

There is now a depsgraph_update_pre and depsgraph_update_post, which runs when something actually changed in the scene, not continuously.

For the remaining uses cases, something is being worked on here:
https://developer.blender.org/D3977


#12

Thank you so much for letting us know! That should do the job for my addon. And it is also very nice that I will not have to check manually if the scene was updated anymore to stop it from firing the code continuously.


#13

Fantastic! Sounds like its actually doing what the removed handlers were supposed to be doing in the first place.
Only question tho, why not just keep the original names?
Regardless, thank you so much for devoting the time to this! I, and many other addon devs appreciate it greatly!


#14

Can this function be used for monitoring size changes in the Sequencer Preview area and call “Fit Preview In Window” if changed, without weighing down the system?

It would be great to have this as an checkbox option in the Sequencer/Preview/View menu in the VSE - Reworked project. If it is possible, here’s a link if someone here wants to help out with this: https://github.com/samytichadou/blender_vse_reworked


#15

There are some cases in which the depsgraph_update_pre/post handlers can’t be used (did not test your case).
If it does not work, you can still fallback to the new Timer API.