Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix execNextFrame out of order in preInit #410

Merged
merged 2 commits into from
Jul 8, 2016
Merged

Conversation

PabstMirror
Copy link
Contributor

Exec next frame uses the logic diag_frameno != GVAR(nextFrameNo),
but between preInit and postInit there can be more than 1 frame.

Items can be called out of order and items added can be called in the same frame (see C/D):

Before:

[13657] - Adding A (@preInit)
[13659] - Adding C (@PostInit)
[13660] - Running C, adding D
[13660] - Running D
[13661] - Running A, adding B
[13662] - Running B

After:

[2455] - Adding A (@preInit)
[2457] - Adding C (@PostInit)
[2458] - Running A, adding B
[2458] - Running C, adding D
[2459] - Running B
[2459] - Running D

This fix addes an extra conditional, pushing everything into the first buffer until it has been run.

@commy2
Copy link
Contributor

commy2 commented Jul 8, 2016

Is there any reason why we skip the frames between pre and postInit in the first place?
Because OEF eh works for that just fine.

@PabstMirror
Copy link
Contributor Author

I'm not seeing any difference between stacked onEachFrame and missionEvent EachFrame.
Both can be installed in preInit and aren't called until 2 frames later.

Install @ 21677
onEachFrame @ 21679
EachFrame @ 21679

Interestingly, we moved from preInit to postInit in #312 because of some problem with 3den in 1.58, which seems to have been fixed. But this wouldn't really have any effect except making the first frame run the same as postInit's frame.

@commy2
Copy link
Contributor

commy2 commented Jul 8, 2016

postInit isn't frame 2. It's the frame after all objects are initialized. It only happens to be frame 2 on dedicated servers, because BIS_fnc_initFunctions isn't waiting for !isNull player to continue with postInit.

@commy2
Copy link
Contributor

commy2 commented Jul 8, 2016

I think it's weird that we will be doing a
if (GVAR(nextFramePreInit) check every frame, despite this being true every time after mission start.

Somehow I don't feel like this is worth it just to guarantee the order in which these things are executed.

@PabstMirror
Copy link
Contributor Author

Our code did something like

3den attribute: execNextFrame: {setVar on group} 
postInit: execNextFrame : {something that uses group var};

and the order was all wrong and things broke

It does add overhead to the adder, not each frame; but still not ideal.

I suppose we can just find a different workaround.

@commy2
Copy link
Contributor

commy2 commented Jul 8, 2016

It does add overhead to the adder, not each frame; but still not ideal.

I see. Can you explain why it messes up the order? I still don't understand why that would be just by leaving out a few frames.

@PabstMirror
Copy link
Contributor Author

Opps, looks like the problem was simpler than I thought.

Fixed by just changing the initial GVAR(nextFrameNo)

@commy2
Copy link
Contributor

commy2 commented Jul 8, 2016

And now I understand what the problem was too. Merge?

@Killswitch00 Killswitch00 merged commit e84dd76 into master Jul 8, 2016
@Killswitch00 Killswitch00 deleted the fixExecNextFrame branch July 9, 2016 10:25
@commy2 commy2 added this to the 2.4.2 milestone Jul 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants