fix(esx_lib/streaming): give asset requests a timeout - #1843
Open
seltonmt012 wants to merge 2 commits into
Open
Conversation
Every request function loops `while not HasXLoaded(...) do Wait(500) end` and never gives up. A misspelled or unavailable anim dict, texture dict or ptfx asset makes that loop run forever, so the calling coroutine never returns. esx_progressbar waits on RequestAnimDict, so a bad dict there leaves the player stuck. A not yet loaded asset also costs at least 500 ms, since the first check always fails. dev fixed this in 0f5f6a6 with a waitForLoaded helper: 5000 ms timeout, 50 ms step, and a shortcut when the asset is already loaded. It was not carried over when the module moved into esx_lib, so v1.14.1 and main still run the old code. This ports it and does the same for requestAudioBank, which dev does not have. Callers already deal with nil. requestModel could always return nil through the IsModelInCdimage guard, and esx_multicharacter and spawnVehicle both check for it. Measured in game on artifact 25770 with a dict name that does not exist: before: never returned, still hanging after 8 seconds after: returns nil after 5026 ms A valid dict still returns immediately.
Contributor
|
I suggest implementing a default streaming timeout and allowing an optional timeout for each streaming function |
Review feedback: keep the default timeout, but let each streaming function take one of its own. The parameter is appended after the callback, so existing calls keep working and still get the 5000 ms default. Measured in game on artifact 25770: bad anim dict, no timeout arg nil after 5004 ms bad anim dict, 1000 ms nil after 1040 ms bad anim dict, 200 ms nil after 231 ms bad texture dict, 800 ms nil after 830 ms valid anim dict, no timeout arg returned after 0 ms valid anim dict, 1000 ms returned after 56 ms valid anim dict, callback, 3000 ms callback result after 0 ms valid model, 4000 ms returned after 119 ms
Contributor
Author
|
Added. The default stays at 5000 ms and every request function takes an optional timeout after the callback, so existing calls are unchanged. Measured in game on artifact 25770: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every request function loops
while not HasXLoaded(...) do Wait(500) endand never gives up. A misspelled or unavailable anim dict, texture dict or ptfx asset makes that loop run forever, so the calling coroutine never returns.esx_progressbarwaits onRequestAnimDict, so a bad dict there leaves the player stuck. A not yet loaded asset also costs at least 500 ms, since the first check always fails.devfixed this in 0f5f6a6 with awaitForLoadedhelper: 5000 ms timeout, 50 ms step, and a shortcut when the asset is already loaded. It was not carried over when the module moved intoesx_lib, sov1.14.1andmainstill run the old code. This ports it and does the same forrequestAudioBank, whichdevdoes not have.Callers already deal with nil.
requestModelcould always return nil through theIsModelInCdimageguard, andesx_multicharacterandspawnVehicleboth check for it.Measured in game on artifact 25770 with a dict name that does not exist:
A valid dict still returns immediately.