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

player owns the reader #725

Merged
merged 6 commits into from Apr 19, 2021
Merged

player owns the reader #725

merged 6 commits into from Apr 19, 2021

Conversation

Karsten1987
Copy link
Collaborator

One step closer to #716

The player takes a unique_ptr to the reader and thus owns the reader/storage access.

I'll do the same for the recorder in a different PR to keep the diff small.

@Karsten1987 Karsten1987 requested a review from a team as a code owner April 9, 2021 02:12
@Karsten1987 Karsten1987 requested review from jaisontj and prajakta-gokhale and removed request for a team April 9, 2021 02:12
@Karsten1987 Karsten1987 mentioned this pull request Apr 9, 2021
@Karsten1987
Copy link
Collaborator Author

Karsten1987 commented Apr 14, 2021

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987
Copy link
Collaborator Author

I am not sure what's happening with the Windows installer, but it looks like it can't download Qt at the moment.

@emersonknapp
Copy link
Collaborator

I am not sure what's happening with the Windows installer, but it looks like it can't download Qt at the moment.

This exact thing has definitely been a problem in the past. Seems like the windows agent setup is pretty finicky.

@Karsten1987
Copy link
Collaborator Author

Karsten1987 commented Apr 17, 2021

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
@Karsten1987
Copy link
Collaborator Author

Fast-RTPS is still unreliable in terms of discovery. I had to limit the amount of "expected messages" when played twice for Fast-RTPS to not introduce flakiness :/

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

{
auto current = std::chrono::high_resolution_clock::now();
if (current - start_time > std::chrono::seconds(10)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is "10 seconds" here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a 10 seconds time out. If the test messages are not arrived by then, the thread canceled. I needed that to avoid running in a Gtest timeout situation (60 seconds) at which point one does not know why the test timed out.

@Karsten1987
Copy link
Collaborator Author

I am a bit hesitant to merge this quite yet as the equivalent changes to the recorder class are far from trivial in order to keep a minimal PR.
I really would love to push forward with removing the rosbag2_transport.[cpp/hpp] files all together to have a clean API ASAP. That however - as discussed in #716 - won't come with a small PR.

@Karsten1987 Karsten1987 merged commit 28ed9d5 into master Apr 19, 2021
@delete-merged-branch delete-merged-branch bot deleted the kk/player_own_storage branch April 19, 2021 23:03

rosbag2_cpp::Reader * Player::release_reader()
{
reader_->reset();
Copy link
Contributor

Choose a reason for hiding this comment

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

@Karsten1987 What a rational to delete current reader object via reset just before calling release?
Player::release_reader() is going to always return null_ptr.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't .reset, it's ->reset, which is calling the reset method of the object itself, not the reset method for the smart pointer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I missed that "This isn't .reset, it's ->reset".
But it is still unclear for me why do we need to reset underlying storage in reader before releasing pointer to the reader?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes it so that the reader is not in an intermediate state, like halfway through the bag. The new owner can call open successfully after this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok good. now it is clear for me.
While it's arguable whether it should be reset or not, at least I wouldn't expect it to be reset on release_reader call.
I think at least we will need to add comment about it somewhere, perhaps in doxygen comment for the Player::release_reader() method.

Copy link
Contributor

Choose a reason for hiding this comment

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

@emersonknapp @Karsten1987 BTW. This method Player::release_reader() looks very unsafe. What if someone will call it somewhere in the middle of the playback?

It would be more safely to force "stop" for player before releasing reader from it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

At this point I think I will default to "PRs welcome" instead of continuing to discuss minor points on merged PRs. If you can provide a test proving the unsafeness of the current behavior, all the better.

Copy link
Contributor

Choose a reason for hiding this comment

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

@emersonknapp I didn't expect that someone will take my comments as an action items for fixing already merged PR's.
The purpose of my comments is a discussion to eliminate potential issues and come to the common opinion about findings and perhaps introduce some improvements in future if we would agree up on it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that this intention is good. In practice, a merged PR is not a very good place to track future work, though. A PR or an enhancement ticket are more likely to move forward - this conversation is likely to get forgotten.

On open source projects, the most important motion comes in the form of contributions. Discussion is fine but if nobody commits to action, it doesn't usually amount to anything. So that's my opinion on this particular conversation - that it would be more productively continued in the form of a code review or backlog ticket.

Copy link
Contributor

Choose a reason for hiding this comment

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

@emersonknapp I agree that separate issue or pull request would be more appropriate place for discussion. I've just have some many things to do that I don't have time for it. And if I will not write my thoughts somewhere It will be forgotten completely. At least here is a PR where relevant changes was introduced. I will try to raise a new issue for discussion next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants