[Bug] .NET 10 SharedEventManager.DecodeSource Throws System.FormatException on NUI Callbacks #257
unknown-urge
started this conversation in
[BUG] FiveM for GTAV Enhanced
Replies: 3 comments 3 replies
|
This please.. |
0 replies
|
Hey! This issue has been fixed in the latest patch b123 and CitizenFX.FiveM NuGets 0.0.4-alpha. Please try again and let us know if the issue persists. You can now also retrieve resource name by requesting |
2 replies
|
Can confirm this is fixed. |
1 reply
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.
Uh oh!
There was an error while loading. Please reload this page.
Summary
When triggering a client-side NUI callback (via
fetch/fetchNuiin NUI JS), FiveM native host dispatches the event__cfx_nui:<callbackName>witheventSourceformatted as"nui:<resourceName>"(e.g."nui:abrp"for a resource namedabrp).Inside
CitizenFX.FiveM.Shared.SharedEventManager, theDecodeSource(string source)method unconditionally executesint.Parseon the substring following"nui:"(int.Parse(array[1])). Because resource names are non-numeric strings (e.g.,"abrp"),int.ParsethrowsSystem.FormatException: The input string 'abrp' was not in a correct format., preventing NUI event handlers from running.Issue type
Client
Repro rate
Always
Server build version
FXServer-early-access b96 win32
OS
Windows 11 24H2
CPU
i5
GPU
RTX 4060Ti
RAM
32gb DDR4
Storage type
SSD NVMe
Connection type
WiFi
ISP and bandwidth
No response
DxDiag
No response
Network graph
No response
Platform
Windows
OS version / distribution
No response
CPU
No response
RAM
No response
Using txAdmin?
None
Hosting provider
None
Machine type
None
/perf endpoint output
No response
DDoS protection
No response
ulimit -n value (Linux only)
No response
Docker Compose file (Docker only)
No response
Steps to Reproduce
ClientScript.cs:index.html:fxmanifest.lua:Expected Behavior
No errors when handling NUI events.
Actual Behavior
System.FormatException: The input string 'abrp' was not in a correct format.exception thrown when NUI callback fires.Evidence
No response
Additional Context
Decompiling
CitizenFX.FiveM.Shared.SharedEventManager.DecodeSource:Why
int.TryParseResolves the Bugint.Parse("abrp"): When an event source contains a non-numeric resource name like"nui:abrp"(array[0] = "nui",array[1] = "abrp"),int.Parsethrows an unhandledSystem.FormatException, breaking event invocation.int.TryParse("abrp", out handle): When given a non-numeric string,int.TryParsereturnsfalseand setshandle = 0without throwing an exception, allowing event invocation to complete cleanly.Temporary Workaround / Bytecode Patch Details
As a temporary local workaround, I used
Mono.Cecilto modifyCitizenFX.FiveM.Shared.dllduring build time:Replacing
int.Parsewithint.TryParseatIL_001Ausing Mono.Cecil allowsDecodeSourceto decode NUI event sources like"nui:abrp"safely without throwing exceptions.Proposed Fix:
Replace
int.Parse(array[1])withint.TryParse(array[1], out var handle)inCitizenFX.FiveM.Shared.SharedEventManager.DecodeSource.All reactions