Forum Discussion
Maximum call stack size exceeded
Hi there,
I am working on a project and ran into an issue. When testing i found this entry in the console log: "Maximum call stack size exceeded". To my knowledge, this happens when a javascript function is executed to often.
I found a simple workaround (posted down here), but i still struggle to understand how this works. It seems to be connected in the order in which triggers are handled.
In order to better understand the situation, I've recreated the issue in the simples way possible (file is attached).
Can somebody help me understand the inner workings of Storyline 360? :)
Here's the process:
- Create a new project
- Create two text variables called START and CHANGE. (named doesn't matter).
- START has a default value of "off".
- CHANGE has an empty default value.
- Create a trigger on the main slide, where you set the variable CHANGE to "01" at the start of the timeline.
- Create a new layer called progress and create a trigger to open this layer at the start of the timeline.
- Make sure you first run the change trigger, before you open the new layer.
- Make sure you first run the change trigger, before you open the new layer.
- On the layer progress, create an object and give it an extra state (named CHANGED).
- On this layer, create two triggers:
- When timeline starts on object: Set state of object to hidden -> if (the variable) START = "off".
- When timeline starts on object: Set state to object 01 -> if (the variable) CHANGE = "01".
- Make sure both tiggers are in this order.
If you test this project and inspect the console in the log, you will see the error.
This error will not occur:
- If i will start both triggers on the start of the timeline;
- If i change the order of both triggers.
I'm very curious about this situation. I've solved the issue in my project by changing the order of the triggers, but it feels a bit fragile to me. Can anyone give me a bit of insight in this issue?
Thanks!
- NedimCommunity Member
Hi Daan,
Storyline lets you apply multiple triggers to the same object. If there are multiple triggers on the same object that are triggered by the same action (such as "when the timeline starts"), the triggers execute in the same order in which they appear in the Triggers panel (top to bottom). What you’re describing is a conflict between simultaneous triggers, where two or more triggers attempt to modify the same object's state at the same time, potentially leading to erratic and unexpected behavior and in extreme cases, it might overload the underlying JavaScript engine (hence the stack size error). There are few ways to resolve this:- Prioritize Triggers
- Determine which trigger should take precedence when both conditions are met.
- Reorder the triggers in the Triggers Panel so the higher-priority trigger appears first.
- Add Conditional Logic
- Modify the conditions to ensure only one trigger executes at a time.
- For example:
- Trigger A: Change state of an object to "Hidden" if Var1 = true AND Var2 = false.
- Trigger B: Change state of an object to "New State" if Var2 = true AND Var1 = false.
- Use a Mediating Variable
- Introduce a new variable to act as a "tie-breaker" for conflicting conditions.
I'm not exactly sure what you're trying to accomplish in your example, but you did a good job reordering the triggers to manage the stack size error. Let me know if you need further assistance in refining the triggers to achieve the desired outcome.
- DaanGroenCommunity Member
Thank you for the feedback. Already very insightful.
I didn't realize triggers where executed based on priority. I assumed the top trigger would be executed first and then the other triggers would follow from top to bottom. So with 2 state triggers on the same object i assumed the top trigger would be executed first (setting a certain state) and then the second trigger would be executed, setting a different state.
But it looks like it keeps bouncing between the two triggers, creating this stack size error.
I'm also confused why the problem occurs when i start the triggers at object start on timeline, but not when both triggers occur at the start of the timeline.
- Prioritize Triggers