YarnSpinnerTool / YarnSpinner

Yarn Spinner is a tool for building interactive dialogue in games!
https://yarnspinner.dev
MIT License
2.3k stars 201 forks source link

Error if multiple fast calls to UserRequestedViewAdvancement() when dialogue ends #340

Closed vlanf closed 1 year ago

vlanf commented 1 year ago

What is the current behavior?

Example: game has multiple ways to advance dialogue, for example mouse click on window and keyboard button click. If user accidentally (or not) simultaneously use both ways to advance at the final dialogue line, runner will crash.

UPD: I found out that problem is in VoiceOverView. The cause is in DismissLine().

Please provide the steps to reproduce, and if possible a minimal demo of the problem:

  1. Add VoiceOverView and setup it.
  2. Try to double call UserRequestedViewAdvancement() on every user "continue" button click, runner crashes on final line with following trace:
InvalidOperationException: Stack empty.
System.Collections.Generic.Stack`1[T].Pop () (at <0463b2ef957545c0a51b42f372cd4fbb>:0)
Yarn.VirtualMachine+State.PopValue () (at <6c636279ac2e42a283a06cfe6df54f4a>:0)
Yarn.VirtualMachine.RunInstruction (Yarn.Instruction i) (at <6c636279ac2e42a283a06cfe6df54f4a>:0)
Yarn.VirtualMachine.Continue () (at <6c636279ac2e42a283a06cfe6df54f4a>:0)
Yarn.Dialogue.Continue () (at <6c636279ac2e42a283a06cfe6df54f4a>:0)
Yarn.Unity.DialogueRunner.ContinueDialogue () (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/DialogueRunner.cs:1283)
Yarn.Unity.DialogueRunner.DialogueViewCompletedDismissal (Yarn.Unity.DialogueViewBase dialogueView) (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/DialogueRunner.cs:1358)
Yarn.Unity.DialogueRunner+<>c__DisplayClass89_0.<DismissLineFromViews>b__0 () (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/DialogueRunner.cs:1343)
Yarn.Unity.VoiceOverView.DismissLine (System.Action onDismissalComplete) (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/Views/VoiceOverView.cs:250)
Yarn.Unity.DialogueRunner.DismissLineFromViews (System.Collections.Generic.IEnumerable`1[T] dialogueViews) (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/DialogueRunner.cs:1343)
Yarn.Unity.DialogueRunner.DialogueViewCompletedInterrupt (Yarn.Unity.DialogueViewBase dialogueView) (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/DialogueRunner.cs:1276)
Yarn.Unity.DialogueRunner+<>c__DisplayClass77_0.<InterruptLine>b__0 () (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/DialogueRunner.cs:1023)
Yarn.Unity.VoiceOverView+<DoRunLine>d__9.MoveNext () (at Library/PackageCache/dev.yarnspinner.unity@2.2.3/Runtime/Views/VoiceOverView.cs:208)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0)

What is the expected behavior?

UserRequestedViewAdvancement() should be safe to call multiple times in described case.

Please tell us about your environment:

Other information

vlanf commented 1 year ago

Moved to https://github.com/YarnSpinnerTool/YarnSpinner-Unity/issues/213