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

Move activity now uses ChildActivity #13749

Merged
merged 1 commit into from
Nov 12, 2017
Merged

Conversation

forcecore
Copy link
Contributor

@forcecore forcecore commented Jul 29, 2017

Removing THE obstacle for waypoint visualization PR #13336.

In line 245, the tick runs the child activity before returning. I commented why. However, what I didn't write there is that it changes the behavior when the move order has first ticked to that part. It used to return MoveFirstHalf and not tick it.

I also tried to make Move activity more understandable but, I failed because I couldn't understand Move.cs. I am not even 50% sure what MoveFirstHalf and MoveSecondHalf are. No comments and not self-explanatory :( I'll just make minimal changes.

@forcecore forcecore force-pushed the MoveParChild branch 2 times, most recently from 6b8117c to c771c3f Compare July 29, 2017 06:31
// will not end up in an odd place.
if (ChildActivity != null)
{
ActivityUtils.RunActivity(self, ChildActivity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be assigning the returned activity back to ChildActivity?

Copy link
Contributor Author

@forcecore forcecore Jul 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so, but in Transform.cs, they do this too.

Copy link
Contributor Author

@forcecore forcecore Jul 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into RunActivity and ChildActivity getting set implicitly but when I look at it now it is completely different. What did I see yesterday xD I must had been looking into something else.

Seems to be OuterTick that is doing this child activity management.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly think it wrong because that would prevent an activity from running multiple children activities properly. They do run, as you might see in my simultaneous reload + resupply code but ChildActivity pointer is invalid.

https://github.com/OpenRA/OpenRA/pull/13733/files/a16b9b52c295ea5c24ed2bba71a159275bd260cc#diff-268b61855646bbc4ed78d90265240289R43

Copy link
Contributor

@obrakmann obrakmann Jul 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be assigning the returned activity back to ChildActivity?

You can, but it's not necessary. As forcecore found out, OuterTick automatically makes sure that the parent's ChildActivity pointer gets updated.

I think it is wrong to do implicit management here

It has to be done there, as there is no other place where that could happen for a CompositeActivity. Your example shouldn't matter at all, as neither ChildActivity nor Tick's return value are used there. In fact, those resupplyActivities aren't even a part of the graph, and their Parent should be null. But let's discuss that in the other PR.

if (path != null)
path.Clear();

if (keepQueue == false && NextActivity != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!keepQueue && NextActivity != null)

// While carrying out one Move order, MoveSecondHalf finishes its work from time to time and returns null.
// That causes the ChildActivity to be null and makes us return to this part of this function.
// If we only queue the activity and not run it, units will pause for one tick!
ActivityUtils.RunActivity(self, ChildActivity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here?

@pchote pchote requested a review from obrakmann July 29, 2017 07:16
@pchote
Copy link
Member

pchote commented Jul 29, 2017

I am not even 50% sure what MoveFirstHalf and MoveSecondHalf are. No comments and not self-explanatory :( I'll just make minimal changes.

MoveFirstHalf moves the actor from its start point (either its starting subcell or the edge of a cell for chained moves) to the edge of the next cell. MoveSecondHalf moves the actor from the edge of the cell back to a defined subcell.

@obrakmann
Copy link
Contributor

MoveFirstHalf moves the actor from its start point (either its starting subcell or the edge of a cell for chained moves) to the edge of the next cell. MoveSecondHalf moves the actor from the edge of the cell back to a defined subcell.

Suggestion: rename them MoveOutOfCell and MoveIntoCell, respectively, to make their purpose clearer?

@forcecore
Copy link
Contributor Author

forcecore commented Jul 29, 2017

Suggestion: rename them MoveOutOfCell and MoveIntoCell, respectively, to make their purpose clearer?

I also tried to modify moveFraction to moveStep, TotalMoveFraction to TotalMoveSteps, as they have nothing to do with division. Then I changed my mind. I want to induce fewer changes so that the correctness is easier to be seen. I think it would be better to make rename PR right after this one.

Copy link
Contributor

@obrakmann obrakmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, just one minor nit. Turning on the StrictActivityChecking setting doesn't crash in Move anymore, so that's a good. I'd like to do some more in-game testing, though.

path.Clear();

if (keepQueue == false && NextActivity != null)
NextActivity.Cancel(self, keepQueue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use NextInQueue here, not NextActivity. You don't want to match against the parent. You can also just set it to null, it's unnecessary to cancel it.

@forcecore
Copy link
Contributor Author

Minor code correction reflecting comments above.

@pchote
Copy link
Member

pchote commented Aug 17, 2017

My understanding is that @obrakmann has made some progress here, but is currently stalled on an unknown but possibly unrelated crash issue:

From 2017-08-13 (#1, #2):

[16:13:50] <pchote> antares79: any new thoughts on #13749?
[16:14:34] <antares79> I think it's good. I'm gonna play two or three more games on it, but it looks good

[20:47:11] <antares79> I've been playtesting #13749 all evening and I get a SEGV on at least d2k after about 15min into the game
[20:47:29] <antares79> haven't yet been able to reproduce it on bleed or in other mods, but I'm still trying

// While carrying out one Move order, MoveSecondHalf finishes its work from time to time and returns null.
// That causes the ChildActivity to be null and makes us return to this part of this function.
// If we only queue the activity and not run it, units will pause for one tick!
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
Copy link
Member

@pchote pchote Aug 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing a lot of pauses/stalls when units move, so I don't think this is sufficient to fix whatever the real problem is?

Repro case: build a ranger in RA and order it to move across the map. Works fine on bleed, unit pauses for a tick every few cells on this PR rebased against bleed.

Copy link
Member

@pchote pchote Aug 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem might be with

https://github.com/forcecore/OpenRA/blob/ab536f5452da590ace46797e4bf22dd7753cc6df/OpenRA.Mods.Common/Activities/Move/Move.cs#L216-L218

If the path becomes invalid then it will stop and wait for the next tick before attempting to repath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually turns out that it is related to Turn child activity.

@forcecore
Copy link
Contributor Author

Rebased to take advantage of any other Mobile related fixes. Fixed "turn pause".

@forcecore forcecore force-pushed the MoveParChild branch 2 times, most recently from 704bd8b to 521f65d Compare August 18, 2017 03:45
pchote
pchote previously approved these changes Aug 19, 2017
Copy link
Member

@pchote pchote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested this extensively (but someone else should!) but the code changes look sensible, and the basics (moving, turning, cancelling while moving or turning) all seem to work as expected.

Can you please squash your fixups in the the appropriate parent commits?

@forcecore
Copy link
Contributor Author

Squashed

@Mailaender
Copy link
Member

Mailaender commented Aug 27, 2017

I played a small test game. No crashes. It seemed at one point a stop command was ignored and the unit was accepting orders only until it moved to its destination. I don't think I can reproduce and I am not sure if that is related. It happened only once with a large group and narrow corridors so units took a detour. Looks good I guess. ✅

@forcecore
Copy link
Contributor Author

I see your bug: force fire on the ground to a place far away so that the unit will move. Then the stop order will be ignored.

@forcecore
Copy link
Contributor Author

In MoveAdjacentTo (or any other activities that may use Move as its inner/Child activity), when Cancel() is called on Move, it will not think it is canceled as Move.cancel returns false. Is it possible to mark Move as "due to be canceled"?

@obrakmann
Copy link
Contributor

obrakmann commented Sep 10, 2017

[20:47:11] < antares79> I've been playtesting #13749 all evening and I get a SEGV on at least d2k after about 15min into the game
[20:47:29] < antares79> haven't yet been able to reproduce it on bleed or in other mods, but I'm still trying

Sorry for the delay. The crash I encountered is also happening on bleed, just took a bit longer to appear there (~1h).

@obrakmann
Copy link
Contributor

Is it possible to mark Move as "due to be canceled"?

Not currently, but I've come to realize that we need something like this. Really it's just required for Move, but since any activity can have Move as a child, it's probably best to bake support for that into the Activity class.

@pchote
Copy link
Member

pchote commented Sep 10, 2017

The original goal was for the return value to be that check, and in cases like this Move (or docking, or whatever else) could return true to indicate that they are cancelling, even if they won't be canceled for another few ticks. This detail may not longer hold true in all cases, and would need some testing.

@pchote
Copy link
Member

pchote commented Oct 14, 2017

Any progress here @forcecore?

@pchote
Copy link
Member

pchote commented Oct 14, 2017

The best solution for now may simply be to lie: unconditionally return true; in Move.Cancel, with a comment explaining why. I suspect that the rest of the code will then just work in the way that we want.

Copy link
Member

@pchote pchote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed over your branch to rebase and fix the activity cancellation as mentioned above.

I did some (admittedly limited) testing, and it now seems to behave as desired so 👍

@reaperrr reaperrr merged commit d49c98c into OpenRA:bleed Nov 12, 2017
@forcecore forcecore deleted the MoveParChild branch January 5, 2018 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants