acemod / ACE3

Open-source realism mod for Arma 3
https://ace3.acemod.org
Other
1.01k stars 736 forks source link

fnc_onDrawScope2D using more than 50ms frametime > using any ACE PIP optic drops the framerate to <10fps #6811

Closed Auge103 closed 1 year ago

Auge103 commented 5 years ago

Arma 3 Version: stable 1.88.145302 CBA Version: stable 3.9.1 ACE3 Version: stable 3.12.5

Mods: see list in attached .rpt

Description:

Steps to reproduce:

  1. Load empty Altis in Eden editor. (optional: have a script profiler running)
  2. Place any unit with a rifle.
  3. Edit its loadout in ACE Arsenal
  4. Place a ace_optic_arco_pip on the rifle and apply
  5. Start the scenario. Watch the framerate drop. (optional: script profiler will show the drawscope2D function using most of the frametime)

Where did the issue occur?

Additional information:

RPT log file: https://pastebin.com/jMwbqsfC ACE debug paste: https://pastebin.com/eArS011c

dedmen commented 5 years ago

https://i.imgur.com/It6JbFr.jpg

To embed images ![](<link>) Also your link is wrong when you click on it

https://github.com/acemod/ACE3/blob/master/addons/optics/functions/fnc_onDrawScope2D.sqf#L30 This is problematic, should only be called on first frame though.

https://github.com/acemod/ACE3/blob/master/addons/optics/functions/fnc_onDrawScope2D.sqf#L82 ~That might be expensive? Though it doesn't show up on the profiler (assuming the profiler is not bugging out..)~ Doesn't matter perf wise, and doesn't show up in profiler because it exits early. Read TLDR below.

~https://github.com/acemod/ACE3/blob/master/addons/optics/functions/fnc_onDrawScope2D.sqf#L98-L103 This does seem bad. It's a PFH. If the control is already shown we shouldn't re-show it. Though I don't know the perf impact of that.~ Would need instruction level prof. I'll do that gimme a min.

dedmen commented 5 years ago

TLDR at bottom.

When attaching a ACE PIP scope/optic to a weapon, using it causes the framerate to drop from >60 to <10fps for me.

Can't reproduce. Not looking through scope 200us, looking through scope 400us. Does the problem take some time to appear?

This happens everywhere, but has more impact the larger the map / the richer the environment is.

Speaks for ambient brightness script. actually really weird that it's missing in your capture.... Maybe something is deleting the GVAR(camera) Can you make a capture with -profilerEnableInstruction Arma start parameter, and attach the capture here in a zip file? doesn't have to be long, all that matters is that the function is on there.

I stay on smooth 60fps while looking through a pip scope ace_optic_arco_pip I assume the camera is nullobj, instruction profiling will confirm it if it's the case.

Can't see any mod in your RPT that might cause that. Well unless bwmod.... @commy2 you got any idea? Same kind of allMissionObjects "camera" that BW was doing.

TLDR; nvm all that I wrote. https://github.com/acemod/ACE3/blob/master/addons/optics/functions/fnc_onDrawScope2D.sqf#L31 It loops here, into the exitWith. Same bug as BWMod had. The _x != GVAR(camera) check doesn't make any sense if camera is null. Also findIf. Didn't we get a new feature camera thing in CBA?

Auge103 commented 5 years ago

tracytrace.zip Here's a full capture //Edit: regarding your question, the problem appears instantly when starting the scenario or when attaching such an optic in the field

dedmen commented 5 years ago

Did you test in editor preview? Can you test if it still happens without BWMod? I assume that's the cause. Are you running the latest version of BWMod?

commy2 commented 5 years ago

Strange enough, when pressing ESC (multiplayer - not paused), the framerate goes back to normal while it is still rendering the same scene as before. This also happens when having a scope attached in the ace arsenal loadout screen.

This draw handler is not executed when the esc menu is opened, because the focus is no longer on the mission display, where the draw handler is (indirectly) attached to.

Auge103 commented 5 years ago

@dedmen Yes, editor preview. And you are right, its working again with disabled BWMod. (it is the latest version from Steam, as are all loaded mods)

dedmen commented 5 years ago

Up to commy then. Dunno what he did inside bwmod.

commy2 commented 5 years ago

@Auge103 You can try disabling the PIP Optics in the settings of BWA3.

Auge103 commented 5 years ago

@commy2 I set BWA3_usePipOptics to false, didn't change anything regarding the ACE optics.

commy2 commented 5 years ago

Don't set the variable to false. Change the setting in the menu and maybe restart the mission.

madpat3 commented 5 years ago

i have this issue, too. but only in the "liberation mission" and only with ace-pip scopes.https://github.com/KillahPotatoes/KP-Liberation/issues/570#issuecomment-467534483

dedmen commented 5 years ago

@madpat3 only on liberation? Are you running BWMod? If not then that is the same cause as how I found the same bug in BWMod.

madpat3 commented 5 years ago
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

dedmen commented 5 years ago

We now use CBA optics right so should probably be fixed now?

commy2 commented 5 years ago

We don't use CBA optics in master and there is no branch for it. However, if I find time to spare I will implement that.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Mike-MF commented 1 year ago

Closing due to age, inactivity or already solved. May be re-opened if the issue is still present, even better just open a new up-to-date Issue.