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

Add defensive checks for null frame #42

Merged
merged 2 commits into from
Oct 21, 2023
Merged

Add defensive checks for null frame #42

merged 2 commits into from
Oct 21, 2023

Conversation

cacheflowe
Copy link
Contributor

@cacheflowe cacheflowe commented Oct 20, 2023

Noted in this issue, I was experiencing many null pointer exceptions while running the Realsense library in a thread. I've added null checks before using the frame objects, which were causing exceptions if they were null. This has solved the errors I was seeing, and hopefully doesn't have any negative impacts

@cansik cansik self-requested a review October 21, 2023 08:42
@cansik cansik self-assigned this Oct 21, 2023
@cansik cansik added the enhancement New feature or request label Oct 21, 2023
@cansik
Copy link
Owner

cansik commented Oct 21, 2023

Thank you very much for the PR, it looks good for me and I am happy to merge it.

DepthFrame frame = frames.getDepthFrame();
depthStream.updateDepthData(frame);
frame.release();
if (frames != null) {
Copy link
Owner

Choose a reason for hiding this comment

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

So this means that the depthStream won't be updated if the frame is null and we get the same depth data back? I guess for stability this is good but it could be misleading for the user. But I think for now this is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is my understanding. I think that I've been running into these errors because I'm running Realsense updates in a separate thread. Receiving an occasional frame of cached data seems better to me than potential multithreading-related errors.

@cansik cansik merged commit 0fbc9e5 into cansik:master Oct 21, 2023
@cacheflowe
Copy link
Contributor Author

Thank you! I'll test the new release today 🙌 🙇

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

Successfully merging this pull request may close these issues.

2 participants