[Bug] [C#] System.Exception: Failed to get result on native API calls during GC/Async tasks #165
Replies: 4 comments
|
Hey! There was a major issue involving native invocation for some specific native calls (mostly those with ref arguments), including SetScaleformMovieAsNoLongerNeeded and GetMouseEvent, that was not related with threading issues. Those natives should be already fixed with CitizenFX.FiveM.Client 0.0.2-alpha and will be fixed in the next patch for the backwards compatibility module. However, we'll look deeper into potentials issues that could arise from calling natives from the background GC thread. |
|
Thanks!! The wrapper is in mono (legacy mode) for now. I'm planning to port it to the new API in the future! |
|
Regardiung the Resolution thingy that errors out... using the SET_DISPLAY_CONFIG function is then passed to the inheriting class (ScaleformUI in my case) and i suspect that other scaleforms like in |

Uh oh!
There was an error while loading. Please reload this page.
Summary
Bug Title
Regression in Enhanced Runtime:
System.Exception: Failed to get resultwhen invoking CitizenFX Native APIs (GetResInt,SetScaleformMovieAsNoLongerNeeded,GetMouseEvent)Description
Multiple unhandled exceptions occur during runtime in ScaleformUI when running on the Enhanced runtime environment. The same code works without issues on the Legacy runtime.
The script throws
System.Exception: Failed to get resultacross several modules (InstructionalButtonsScaleform,MinimapOverlays,ScaleformWideScreen).This issue stems from the stricter thread-affinity rules enforced in the Enhanced runtime, where CitizenFX native APIs are invoked from background threads—specifically during Garbage Collection (
GC.RunFinalizers/Dispose) or inside async tasks on the .NET ThreadPool.Environment & Regression Context
System.Exception: Failed to get result.Stack Traces / Exception Details
1. Native API call in GC Finalizer (
ScaleformWideScreen.Dispose)SetScaleformMovieAsNoLongerNeededinsideFinalize()executes on the GC background thread rather than the main FiveM execution thread, which fails under Enhanced.2. Screen Resolution / Native Call Failure in
InstructionalButtonsScaleformScreen.Resolution/GetResInt) fail when executed off the main thread inside async tasks.3. Tick Handler Exception in
MinimapOverlays/ScaleformUIThread_TickSuggested Fixes / Expected Behavior
SetScaleformMovieAsNoLongerNeeded, etc.) inside destructors/finalizers (~Class()orFinalize()). Native resources should be explicitly disposed of on the main tick thread before references are dropped.await BaseScript.Delay(0)) before querying game native functions likeGetResIntorGetMouseEvent.Issue type
Client
Repro rate
Always
Server build version
FXServer-early-access b94 win32
OS
No response
CPU
No response
GPU
No response
RAM
No response
Storage type
None
Connection type
None
ISP and bandwidth
No response
DxDiag
No response
Network graph
No response
Platform
None
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
Expected Behavior
Actual Behavior
GetResInt,SetScaleformMovieAsNoLongerNeeded,GetMouseEvent) throwSystem.Exception: Failed to get resulton the Enhanced runtime.GC.RunFinalizers) and async execution loops (ScaleformUIThread_Tick,InstructionalButtonsScaleform.Load).Evidence
Additional Context
No response
All reactions