Repository navigation
[Bug] Enhanced client runs the first tick of load-time CreateThreads BEFORE onClientResourceStart (server and Legacy do the opposite) #522
Closed
Enz0Z
started this conversation in
[BUG] FiveM for GTAV Enhanced
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
On the FiveM for GTAV Enhanced client, threads created with
CreateThreadwhile a resource's scripts are loading receive their first tick before that resource'sonClientResourceStartevent fires (same frame, threads first). On the server the order is the opposite:onResourceStartfires right after all scripts load and before any thread ticks, and Legacy resources have relied on that same order on the client for years.Any resource that fills a shared table (config, locales, blip lists, ...) from an
onClientResourceStarthandler and reads it from a thread on its first tick now reads it empty on Enhanced. In our case that broke blips and crashed load-time threads across ~20 ESX resources with no error pointing at the cause.Verified with a standalone probe resource (attached below) that logs every step with frame number and game timer, relayed to the server console.
Issue type
Client
Repro rate
Always
Server build version
139
OS
No response
CPU
No response
GPU
No response
RAM
No response
Storage type
None
Connection type
None
ISP and bandwidth
not relevant
DxDiag
not relevant
Network graph
not relevant
Platform
Docker
OS version / distribution
container image Alpine Linux 3.22 (FXServer runs on musl via
ld-musl-x86_64.so.1); host Debian 12 (bookworm), kernel 6.1.0-41-amd64, Docker Engine 29.4.2CPU
Intel Core i7-4790K (8 threads); the container has no CPU limit (
cpu.max = max), all 8 threads visibleRAM
32 GB on the host; the container has no memory limit (
memory.max = max)Using txAdmin?
Yes
Hosting provider
Cloud provider (AWS, GCP, Azure, etc.)
Machine type
Dedicated
/perf endpoint output
not relevant (not a performance issue)
DDoS protection
OVH Game DDoS (provider default)
ulimit -n value (Linux only)
soft 1024 / hard 524288
Docker Compose file (Docker only)
Steps to Reproduce
ordertest(5 small files, attached at the bottom) intoresources/and addensure ordertesttoserver.cfg. It has no dependencies.[S]).[from client N] [C]), each withframe=(GetFrameCount()) andt=(GetGameTimer()).onResourceStart firedrelative toCreateThread first tickon each side.Expected Behavior
Same order on the client as on the server (and as on the Legacy client):
onClientResourceStartfor the resource fires after all of its scripts have loaded and before the first tick of any thread created during loading. So a table populated inside that handler is already filled when a load-time thread reads it on its first tick.Server, measured (b139, same resource):
(
CFG.xis nil on the server becauseb_config.luais a client script; that is expected.)Actual Behavior
Enhanced client, measured (b139). Everything happens in the same frame (247), but every thread gets its first tick before
onClientResourceStart:Also observed: threads tick in creation order, all script chunks have finished loading before the first tick, and a
TriggerEventto another resource with a function callback is still executed synchronously on both sides. So the difference is purely whenonClientResourceStartfires relative to the first tick.Evidence
Real-world failures this caused on our server (ESX-based; ~20 resources share one bootstrap file that requests the config from a central resource inside
onClientResourceStart, exactly the pattern above). Client console on connect:Both scripts read a config table from a
CreateThreadon its first tick. Other resources (shop blips) failed silently:for _, v in pairs(Config.List) do AddBlipForCoord(...) enditerated an empty table and never retried. The same resources, unchanged, work on Legacy.The probe resource used to measure the order is attached (
ordertest/, 5 files, ~60 lines). Its whole client log is relayed to the server console, so no client log collection is needed.Additional Context
Attachment:
ordertestresourcefxmanifest.luaa_first.luab_config.luac_main.luad_server.luaAll reactions