Skip to content

Don't interact with Libcamera cameras until connected#2447

Open
thatcomputerguy0101 wants to merge 1 commit intoPhotonVision:mainfrom
thatcomputerguy0101:Missing-libcamera-crash-fix
Open

Don't interact with Libcamera cameras until connected#2447
thatcomputerguy0101 wants to merge 1 commit intoPhotonVision:mainfrom
thatcomputerguy0101:Missing-libcamera-crash-fix

Conversation

@thatcomputerguy0101
Copy link
Copy Markdown
Contributor

@thatcomputerguy0101 thatcomputerguy0101 commented Apr 26, 2026

Description

The Libcamera frame provider was trying to reset the video mode to the saved value regardless of whether the camera is currently attached or not. This waits until the camera is connected first to prevent crashing PhotonVision.

Meta

Merge checklist:

  • Pull Request title is short, imperative summary of proposed changes
  • The description documents the what and why
  • If this PR changes behavior or adds a feature, user documentation is updated
  • If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly
  • If this PR touches configuration, this is backwards compatible with settings back to v2025.3.2
  • If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated
  • If this PR addresses a bug, a regression test for it is added

@github-actions github-actions Bot added documentation Anything relating to https://docs.photonvision.org photonlib Things related to the PhotonVision library backend Things relating to photon-core and photon-server labels Apr 26, 2026
@thatcomputerguy0101 thatcomputerguy0101 changed the base branch from main to 2027 April 26, 2026 00:58
@thatcomputerguy0101 thatcomputerguy0101 changed the title Missing libcamera crash fix Check that CSI cameras are connected before interacting with them during init Apr 26, 2026
@thatcomputerguy0101
Copy link
Copy Markdown
Contributor Author

Tested, this resolves the crash when a libcamera CSI camera is not found.

@thatcomputerguy0101 thatcomputerguy0101 marked this pull request as ready for review April 26, 2026 02:02
@thatcomputerguy0101 thatcomputerguy0101 requested a review from a team as a code owner April 26, 2026 02:02
@thatcomputerguy0101 thatcomputerguy0101 force-pushed the Missing-libcamera-crash-fix branch from 8102a9f to b061737 Compare April 27, 2026 09:20
@github-actions github-actions Bot removed documentation Anything relating to https://docs.photonvision.org photonlib Things related to the PhotonVision library labels Apr 27, 2026
@thatcomputerguy0101 thatcomputerguy0101 changed the base branch from 2027 to main April 27, 2026 09:21
@thatcomputerguy0101 thatcomputerguy0101 force-pushed the Missing-libcamera-crash-fix branch from 1c9ba69 to 06d41db Compare April 28, 2026 00:19
@thatcomputerguy0101 thatcomputerguy0101 changed the title Check that CSI cameras are connected before interacting with them during init Don't interact with Libcamera cameras until connected Apr 28, 2026
* Returns if the camera is currently connected. Use checkCameraConnected instead to properly
* handle camera connection.
*/
public abstract boolean isConnected();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

With how I restructured things isConnected probably should not be called by unrelated classes. The only place it is currently called is in VisionModule, for which I'm not sure which method yields better results.

@thatcomputerguy0101
Copy link
Copy Markdown
Contributor Author

I reconfirmed this still prevents the CSI camera crash, and the connection handler is run for a properly connected camera. Hot plugging is untested since CSI does not support it, and USB cameras take a different code path right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Things relating to photon-core and photon-server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants