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
Callback after cancel #2281
Callback after cancel #2281
Conversation
b70093d
to
061201a
Compare
8e4ec02
to
371bf4e
Compare
371bf4e
to
f574591
Compare
Some more thoughts on this PR (also discussed in the last Client Library WG meeting).
This means that the documentation is wrong, but the demo code is correct. Having to hold the future even if you don't do anything with it is a very strange user experience, since I proposed to fix the bug by:
This should ensure proper destruction of things |
Note, this will break the code of users not setting the callback. Just to make sure that we are all on the same page, the current behavior is:
If you don't set a result callback:
Whatever we decide, we will break the code of someone... |
This is true, that's why I think we should rather focus on what we think is the correct behavior.
I think that this is a good summary of the the current state and the two proposals My vote is for "proposal 2" |
I think @ros2/team is worth pinging here. |
I vote for 1, as users at least get a compile warning. Additional I would propose, that we directly return the goal handle by the async_send_goal method, as this would also give us a way to drop the goal, before it was accepted. This is currently a second design flaw in the API. |
Can you explain more of your thinking around this? Today, if users are not setting the result callback, then either:
If we change it so that the action client keeps the goals alive, then in case 1., they are unnecessarily holding the But it is entirely possible I'm missing something here. |
Users that don't set the callback might rely on the fact, that the goal gets canceled the second they drop the handle. |
Ah, right. Thanks. So I have a proposal, and then an opinion. The proposal is option 3, where we add in a completely new API for sending goals ( My opinion is this: I like option 3 the best, as it is clear to users that changes to these APIs are coming. If we don't want to do option 3 today, then I think we should go for option 1, as it is the least surprising for users. In the future we can always decide to go for option 3 if we think that is better. Thoughts? |
I don't think we can implement option 3 until the feature freeze next week. I would also go more into the direction of a whole API redesign, introducing two new client classes, that solve the common 'I called wait on the future and deadlocked' issue. |
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/client-library-wg-meeting-april-5-2024/36998/1 |
Edit: Sorry my vote is proposal-1. I second proposal-1. (from #2281 (comment)) I am okay with current implementation. (note, i do not think i can make it tomorrow meeting, depends on traffic.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still under discussion but lgtm with green CI atm.
Summary of the discussion: async_send_goal_unowned() This version will work as described in the documentation. My vote is for adding the deprecated prior to jazzy, as users might then recognize a bug they were experiencing. |
just checking. so the decision is, to keep |
Jazzy will have both of them. |
While implementing the proposed solution I rechecked the code and figured out, that the problem is different than described by me in this thread before. The current behavior of the action client library is : async_send_goal
Using the current implementation of async_send_goal will create a memory leak, as the goal handle will not be deleted.
I am undecided on what to do with the async_send_goal function, still migrate to a new version owned ? I would propose, to add a new function void stop_callbacks(typename GoalHandle::SharedPtr goal_handle) instead of void drop_goal_handle(typename GoalHandle::SharedPtr goal_handle) I would also update the documentation. Opinions? @clalancette @fujitatomoya @alsora @mjcarroll @wjwwood |
d419b35
to
f366e26
Compare
@alsora updated docs |
Thank you! |
f366e26
to
b475151
Compare
This function allows us to drop the handle in a locked context. If we do not do this within a lock, there will be a race condition between the deletion of the shared_ptr of the handle and the result / feedback callbacks. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
This fixes deadlocks due to release of goal handles in callbacks etc. Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
This fixes a memory leak due to a self reference in the ClientGoalHandle. Note, this fix will only work, if the ClientGoalHandle ever receives a result callback. Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <j.machowinski@cellumation.com>
Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
b475151
to
60b5b1a
Compare
rebased to rolling. CI seems to hang, can someone restart it ? |
Ready for merge ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmachowinski lgtm anyway, but one question for doc section.
fixes #2265
Note, this commit fixes a bug, that makes the current version of the tutorial
not work any more, as the code now acts according to its documentation.