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

Async loading #7513

Merged
merged 3 commits into from
Nov 10, 2024
Merged

Async loading #7513

merged 3 commits into from
Nov 10, 2024

Conversation

glebm
Copy link
Collaborator

@glebm glebm commented Nov 9, 2024

Does the loading on a separate thread, so we're now loading while fading in and while updating the progress bar (resulting in much faster loads; fade outs still happen only after loading).

I had to separate the virtual gamepad surface and texture (de)initialization code because it was logging error messages, and upon further investigation I learned that per https://wiki.libsdl.org/SDL3/CategoryRender:

These functions must be called from the main thread. See this bug for details: libsdl-org/SDL#986

I also had to adjust fatal error reporting: app_fatal can only be called from the main thread, so during loading we instead propagate a tl::expected and send a custom message to the main thread if there is an error. Introduces RETURN_IF_ERROR and ASSIGN_OR_RETURN macros for more ergonomic status propagation.

I think I found most of the places where we currently call app_fatal during load and replaced them with tl::expected propagation. If I missed any, we won't see an error dialog for these errors and the loading process will appear to hang with lots of console spam instead.

Also adds an advanced (ini-only) setting to skip showing loading screen on fast loads. This is what it looks like on my machine with the threshold set to 500ms.

vokoscreenNG-2024-11-09_22-29-53.mp4

@glebm glebm force-pushed the async-load branch 2 times, most recently from 62ce616 to e673902 Compare November 9, 2024 08:21
Source/utils/ini.cpp Outdated Show resolved Hide resolved
@glebm glebm force-pushed the async-load branch 9 times, most recently from e8591be to fa3b52a Compare November 9, 2024 16:18
@glebm glebm force-pushed the async-load branch 3 times, most recently from be37c9e to 04f0fb0 Compare November 9, 2024 18:10
@glebm glebm marked this pull request as ready for review November 9, 2024 18:14
@glebm glebm force-pushed the async-load branch 3 times, most recently from 8f4e8af to c41a9e9 Compare November 9, 2024 22:41
@glebm glebm enabled auto-merge (rebase) November 9, 2024 22:43
Does the loading on a separate thread, so we're
now loading while fading in and while updating
the progress bar.
@AJenbo
Copy link
Member

AJenbo commented Nov 10, 2024

Hail Marry!

(don't have time to fully review, but it's a good time for me to test it with others)

@AJenbo AJenbo merged commit 66b0f43 into diasurgical:master Nov 10, 2024
23 checks passed
@glebm glebm deleted the async-load branch November 10, 2024 15:35
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.

4 participants