Update: Deferred Engine Events opt-in are now live and can be enabled in experiences.
Hey Developers,
On April 12th we will be allowing you to opt-in to using deferred engine events in your experiences.
Overview
For those of you that are not already familiar with deferred engine events you can find out more about them here but to give a brief summary:
- Rather than resuming event handlers immediately we queue them up and resume them all at once.
- This improves performance as code that would usually trigger an event can now complete without needing to run arbitrary event handlers which may themselves trigger further events.
- This improves security as scripts will only run at specific points in the frame. Doing this eliminates an entire set of vulnerabilities that we would otherwise need to patch on a case-by-case basis.
- This will allow us to make additional optimizations in the future.
Using Deferred Events
You can enable deferred events by changing the SignalBehavior property of workspace in each of your places. There are a few options to choose from:
- Default - The default behavior, currently equivalent to Immediate but will eventually change to Deferred.
- Deferred - All events are deferred and their handlers resumed at specific resumptions points each frame.
- AncestryDeferred - Equivalent to deferred but only for events triggered by changes in ancestry.
- Immediate - Event handlers are resumed immediately when the event occurs.
Since our last post, we have also introduced AncestryDeferred which will only defer events related to changes in ancestry. If you are interested in trying out deferred events in an existing experience this may be a good alternative to all events being deferred and will still provide some of the benefits described above.
How will this impact existing experiences?
By default, the behavior of your experiences will remain the same. Right now, the default SignalBehavior is equivalent to immediate (signals will fire as they did before). For those who had previously opted-in or out during the beta, we have reset the value of SignalBehaivor. This was done out of an abundance of caution so that no behavior changes are observed when we enable this feature platform wide on April 12th.
We encourage you to enable deferred mode in your experiences. Doing this may require you to adjust some of your code so make sure to test your experiences before publishing them. We have added some helpful tools to help adjust the code to be compatible with deferred events, such as the new task library (as a replacement for “fast signal” pattern and others), and the Once connection method on signals.
If your experience is not compatible with deferred events, you can keep using the default behavior for now or switch to Immediate to make sure the behavior of your experience is not affected when we switch to deferred-by-default (see below for more details).
Long-term plan for Deferred Engine Events
As you may have noticed, the SignalBehavior property is similar to other multiphase rollouts we have done in the past. Eventually, we would like all experiences to run in deferred mode but we know this is not realistic today.
Our goal for 2023 is to change the default (which is to say, the behavior of places with SignalBehavior set to Default) from immediate mode to deferred mode. However, we will not do this until we are convinced that doing so results in minimal disruption through a combination of us improving the system and developers adapting to change over time. If it is not possible for us to make this change without impacting your experiences then we will extend our timeline accordingly.
As mentioned, eventually we would like all experiences to run in deferred mode. We won’t be announcing the timeline for this until after we have changed the default but you can expect it to be years before we do this.
Even after we change the default, you will still be able to opt-out by setting SignalBehavior to Immediate.
You can learn more about deferred events and related features by reading the following pages:
We will also be updating our documentation on scheduling so keep an eye out for that in the coming weeks.
If you have any comments or concerns, feel free to reach out to me directly over message or on this thread and we can discuss.
Thank you.