removeWorldModel() can cause MTA to load default game model instead of replaced one
Describe the bug On my server the above function fails for some very special objects when the game is minimized, maybe it fails when the object is not streamed in either. A very common object is 3916 (snowover04). The object will get replaced as soon as it streams out and in again. The strange thing is, most objects will always get replaced correctly, some objects are more likely to get this bug.
To reproduce
- Join my server (SAAW World War II) on the map Stalingrad Railroad
- After connecting, minimize the game immediately
- Wait for a decent while
- Maximize the game, go to spectators and see the white original snowover04 instead of a tower :D
Multi Theft Auto v1.5.7-release-20288
Please provide a minimal reproduction resource. Joining your server isn't sufficient, because it doesn't allow us to rule out interference (like doing tricky things on stream in/out), other things in your gamemode causing a lack of VRAM, or loading order problems.
I cannot reproduce this problem on a server with various models (including the ID you mentioned) and replacing it when minimized. Is a custom model applied to that model ID on your server? Then please attach it to the requested reproduction resource.
@Einheit-101
I have a resource that can reproduce the bug in 100% of all cases but that resource is the whole model replacement resource of my server (300 mb). I am currently investigating the issue ̶a̶̶n̶̶d̶̶ ̶̶i̶̶t̶̶ ̶̶s̶̶e̶̶e̶̶m̶̶s̶̶ ̶(̶n̶̶o̶̶t̶̶ ̶̶s̶̶u̶̶r̶̶e̶)̶ ̶̶t̶̶h̶̶a̶̶t̶̶ ̶̶i̶̶t̶̶ ̶̶i̶̶s̶̶ ̶̶c̶̶a̶̶u̶̶s̶̶e̶̶d̶̶ ̶̶b̶̶y̶̶ ̶"̶t̶̶o̶̶o̶̶ ̶̶m̶̶a̶̶n̶̶y̶̶ ̶̶o̶̶b̶̶j̶̶e̶̶c̶̶t̶̶s̶̶ ̶̶g̶̶e̶̶t̶̶ ̶̶r̶̶e̶̶p̶̶l̶̶a̶̶c̶̶e̶̶d̶̶ ̶̶i̶̶n̶̶ ̶̶1̶̶ ̶̶f̶̶r̶̶a̶̶m̶̶e̶̶ ̶̶b̶̶y̶̶ ̶̶a̶̶ ̶̶l̶̶a̶̶r̶̶g̶̶e̶̶ ̶̶f̶̶o̶̶r̶̶ ̶̶l̶̶o̶̶o̶̶p̶"̶.̶
The bug also stops happening when certain requirements are met: As soon as i remove 50% of the replaced models and restart the resource, the bug can no longer be reproduced. Even when re-adding all models, it wont happen again. In order to reproduce it again you have to close MTA and close the server, then restart everything...
€DIT: The problem is removeWorldModel() ! What i am doing is this with 150 objects:
for i, str in pairs(objects) do
engineImportTXD(engineLoadTXD("models/"..str..".txd", true), i)
engineReplaceModel(engineLoadDFF("models/"..str..".dff"), i)
removeWorldModel(i, 10000, 0, 0, 0)
end
And as soon as i remove the "removeWorldModel" line, the issue stops. I can join the server all day and nothing unusual happens. removeWorldModel can even prevent a model replacement only for certain objects of a kind, which is ridiculous: https://i.imgur.com/MYlw5V1.png And this explains why the objects are correctly replaced once they get streamed out and back in.
€DIT 2: removeWorldModel causes default MTA objects to "blink" when it gets executed, i guess something bad happens in this moment that should not affect MTA objects at all.
Maybe this problem is related to the issue where, if you load a custom model and you are too close to it , it does not replace (only the collisions file does).
I dont think so, because the bug really disappeared after removing all 2 "removeWorldModel()" lines.
Does engineRestreamWorld fix this issue?