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

Improve stuttering when starting a timeline #17

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

paperman5
Copy link
Contributor

This PR addresses some causes of stuttering that happens when starting a timeline. Changes include:

  1. Keep a cached version of DialogNode.tscn or whatever node the user has chosen. This allows ResourceLoader to have a cached version in memory so it doesn't have to load it from the disk every time. The cache is created during the Dialogic.preload() call (Optional, includes a setting to enable & pick cached scene).
  2. Using the built-in timeline cache when loading a timeline from its filename on disk (timeline-xxxx.json). It seems like this may have been a simple oversight originally, but it was causing every timeline to be loaded from the disk for me because I was using custom resources with an exported value that used the custom timeline selector.
  3. Multi-threaded image loading for themes and portraits. This is probably the biggest stutter reduction but also has the highest risk of breaking things. Threading is automatically disabled in the editor and on web exports, and there is an additional setting to turn it off for other exports.

My changes seem to work fine in my use/testing, but I haven't tested it extensively with very many use cases. I tested on Windows/Linux/Web builds, Godot 3.5.3, i7-11700KF, RX6800XT.

@paperman5
Copy link
Contributor Author

I have found an issue with the multi-threaded portrait image loading that I'm not exactly sure how to fix. I will occasionally get the following errors when playing a timeline, and I think it's when there is a character join event (with a portrait specified) directly followed by a text event with the same character and portrait. The portraits still load properly when running through the editor and in debug builds, but in release builds this error results in texture corruption issues.

image

I'm thinking it might be caused by multiple threads trying to load the same resource at once? Admittedly I'm not super familiar with multi-threading best practices, but maybe this could be solved with a mutex/thread lock of some kind.

- Emit signals from 'Portrait.gd' slightly differently
- Use mutexes to lock texture assignments
@paperman5
Copy link
Contributor Author

Texture assignment issues should be fixed with the latest commit, hopefully thread-safe now. I am using these changes in my game currently with no issues.

@paperman5
Copy link
Contributor Author

I found and fixed some more issues that happened when the theme took too long to load. I updated my testing project textures (textbox, portraits) to be 8K pngs so that it takes my PC a proper half second to load them, and I think I've finally ironed everything out...

This threading stuff got much more involved than I intended, so I'm willing to put those changes in a separate PR if the reviewers want. Or if it's just too messy/risky to be meddling in core logic like this I can just maintain my own fork - no hard feelings, just let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant