Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3 beta] Stopping then starting a new node skips a line and breaks #86

Open
ptlthg opened this issue Feb 25, 2025 · 7 comments
Open

[v3 beta] Stopping then starting a new node skips a line and breaks #86

ptlthg opened this issue Feb 25, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@ptlthg
Copy link

ptlthg commented Feb 25, 2025

Discussed in Discord starting here: https://discord.com/channels/754171172693868585/1154619415665574009/1343420213982400573

In my game, I often interrupt running dialogue and then immediately start a new node. This worked fine in v2 without any delays between the calls, just like this:

DialogueRunner.Stop();
DialogueRunner.StartDialogue("New_Node");

After updating and using the AsyncLineView, this code now stops the running dialogue, then starts the new node, skips the first line instantly, and only displays about half of the second line in the new node before the typewriter breaks (disabling the typewriter fixes only that part of the problem).

I've made a reproduction project here: StartStopBugRepro.zip
You can also open this in 4.3 stable to observe the same bug (you might have to reassign the main scene).

Image

I added 5 different buttons that all stop then start a new node in different ways. You can see their implementations in DialogueManager.cs

  1. Bid Normal Stops then Starts with no delay
  2. Bid Deferred Stops then Start is called with CallDeferred
  3. Bid OnComplete Stops then Starts when DialogeRunner.onDialogueComplete is emitted
  4. Bid Next Frame Stops then Start is called after waiting for a process frame
  5. Bid After Timer Stops then Starts after a 3 second timer times out. This is the only one that works

After clicking any of these buttons you should see Bidder: I'll bid! I'll bid!. But you usually see the line after that. Sometimes spamming the buttons can made the correct line show up.

2025-02-24.21-19-04.mp4
@ptlthg
Copy link
Author

ptlthg commented Feb 25, 2025

Also want to add that I don't need stopping then starting instantly to work, but at least the stopping then starting when onDialogueComplete is fired should work. Maybe even a await DialogueRunner.Stop() then start?

@dogboydog
Copy link
Collaborator

Thank you for the reproduction project. I'll try to fix this as soon as I can.

I'm hesitant to make Stop() be async as I like to keep the API as similar to the Unity plugin as possible, but it might make sense to emit the onDialogueComplete signal after the views have finished their async cleanup.

@ptlthg
Copy link
Author

ptlthg commented Feb 25, 2025

Stop doesn't need to be async, was just throwing that out there. A .StopAsync() alternate method might be a good idea? But I definitely think onDialogueComplete should wait until everything is cleaned up so at least that button in the reproduction works as expected

@dogboydog
Copy link
Collaborator

I got the project set up to debug. I don't know the cause so far but I can definitely confirm the bug. What I'm seeing is that RunLineAsync is immediately called twice when the bug happens

Image

Image

But while the second RunLineAsync is running, the first is still running, as I then hit the breakpoint for the first line toward the bottom of RunLineAsync. So the two are running simultaneously, and I think the key will be figuring out why the second RunLineAsync triggers before the first line is done. I'll continue looking

Image

@ptlthg
Copy link
Author

ptlthg commented Feb 25, 2025

Yep, that was the behavior I was seeing. I had trouble tracing the bug within this plugins code at all, so it might be a bug in the YarnSpinner library itself? Worth trying that out if you have the ability to test in Unity or something.

@dogboydog
Copy link
Collaborator

I would have to install Unity, but I might if further investigation leads me to think it might be a problem with the base library

@dogboydog
Copy link
Collaborator

At the moment I'm awaiting an example of a fix upstream in the Unity plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants