citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.57k stars 2.11k forks source link

``RequestScaleformMovie`` fails to execute/invoke if called again after resource restart. #1576

Open significant-quart opened 2 years ago

significant-quart commented 2 years ago

Description: While developing scaleforms I've come to discover that if a streamed scaleform is loaded (and although not required disposed of accordingly with SetScaleformMovieAsNoLongerNeeded) then the resource responsible restarts and attempts to load the scaleform again (for example, if you've made changes and wish to test) the call to RequestScaleformMovie will fail.

I'm Unsure how long this problem has existed however the repro I've provided was tested on the latest server artefacts although that shouldn't affect anything AFAIK.

How to use repro:

  1. Download and install repro resource here (repro.zip).
  2. Once in server start the resource
  3. Ensure the resource to which an error will be displayed in the console.

Misc details: The scaleform being streamed is a random scaleform I chose from the vanilla game however this issue can observed with both vanilla or custom scaleforms.

Local9 commented 2 years ago

I believe this was raised in the past by manups4e when working on ScaleformUI, but was in the Discord at the time.

FingerlessGlov3s commented 1 year ago

Calling SetScaleformMovieAsNoLongerNeeded on onResourceStop, then creating the same scaleform again, causes native errors and then eventually crashes your client. Even if I add a 10 second delay before creating the scale forms, the problem still happens, I assume the scaleforms stops getting cleaned up after the resource stops?

One workaround so far is to unload it before you restart the resource, eg distance checking and unloading. then once it's unloaded restart the resource and the issue won't happen.

EDIT:

If if create a unload command, run that, then wait 2-5 seconds, do a restart of the resource the problem doesn't happen. Done this about 20+ times now with no errors happening.

gottfriedleibniz commented 9 months ago

Have any of you Scaleform GFx users played with the SCALEFORM_DLC_FILE manifest entry?

Running the reproduction it does seem like the GFx is not being instantly unloaded from CScaleformStore and the subsequent scaleform request is still using the remnants of the previous Scaleform definition (the data file entry solves all of this). Any additional progress/updates made on this since initial reporting?

In this specific case it may be possible to work around this by emulating something similar RELOAD_MAP_STORE for CScaleformStore, e.g., mirror the CScaleformPreallocationDataFileMounter unload logic. It may be possible to force a SCALEFORM_DLC_FILE entry gfx files in stream/.

IT would be nice if SCALEFORM_DLC_FILE could be tested here.

tens0rfl0w commented 8 months ago

Just stumbled across this issue when testing stuff with DUIs today.

IT would be nice if SCALEFORM_DLC_FILE could be tested here.

Registering the .gfx file as SCALEFORM_DLC_FILE doesn't help resolving the mentioned issue.

gottfriedleibniz commented 8 months ago

Would it be possible to provide a reproduction? My uses of SCALEFORM_DLC_FILE with generic_texture_renderer_gfx (presumably what you are using) seem to work fine.

tens0rfl0w commented 8 months ago

Would it be possible to provide a reproduction?

Didn't really have time to test this on different game builds, but on a vanilla server with only base-resources started, this is constantly reproducible for me (with using generic_texture_renderer_gfx).

Restarting the resource that contains the scaleform and DUI (with or without manual scaleform unload and DUI destruction per onResourceStop handler) produces the following error when invoking RequestScaleformMovie again:

Error executing native 0x11fe353cf9733e6f at address FiveM_b2944_GTAProcess.exe+168B8E.

Gamebuild was: 2944 Resource used for testing: scaleform-repro.zip

gottfriedleibniz commented 8 months ago

SCALEFORM_DLC_FILE expects ScaleformPreallocation entries, e.g., from contents:

284       <filename>dlc_mpBusiness2:/common/data/ui/CacheAndCarry.xml</filename>
285       <fileType>SCALEFORM_DLC_FILE</fileType>  

However, playing with this a bit further there still does seem something else racey involved with scaleform unloading.