[v3,1/2] libcamera: camera_manager: Non-fatal duplicate id detection
diff mbox series

Message ID 20261029-kbingham-duplicate-id-v3-1-0a6537277d50@ideasonboard.com
State New
Headers show
Series
  • libcamera: camera_manager: Non-fatal duplicate id detection
Related show

Commit Message

Kieran Bingham Oct. 29, 2026, 4:06 p.m. UTC
There are some hardware configurations which currently generate a
duplicate camera ID when the camera is on a shared but multiplexed bus.

At present this is somewhat difficult to adapt to ensure a consistent
and unique id.

While this case is undesired, it presently causes libcamera to hit a
Fatal asssertion on real world hardware which then causes pipewire to
close.

This behaviour is even less desirable, and we can easily continue to
operate libcamera without a potentially duplicate camera.

Reduce the Fatal log level to an Error allowing the code to continue
without constructing this duplicate camera.

Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/camera_manager.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Oct. 29, 2026, 4:46 p.m. UTC | #1
On Thu, Oct 29, 2026 at 04:06:13PM +0000, Kieran Bingham wrote:
> There are some hardware configurations which currently generate a
> duplicate camera ID when the camera is on a shared but multiplexed bus.

A link to the bug report would be nice. Have you hit the issue with a
non-thunderbolt setup, or is that the only one known to fail ?

With that,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> At present this is somewhat difficult to adapt to ensure a consistent
> and unique id.
> 
> While this case is undesired, it presently causes libcamera to hit a
> Fatal asssertion on real world hardware which then causes pipewire to
> close.
> 
> This behaviour is even less desirable, and we can easily continue to
> operate libcamera without a potentially duplicate camera.
> 
> Reduce the Fatal log level to an Error allowing the code to continue
> without constructing this duplicate camera.
> 
> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/camera_manager.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> index 0dd4e0c590a1..9c9073053710 100644
> --- a/src/libcamera/camera_manager.cpp
> +++ b/src/libcamera/camera_manager.cpp
> @@ -210,7 +210,7 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera)
>  
>  		for (const std::shared_ptr<Camera> &c : cameras_) {
>  			if (c->id() == camera->id()) {
> -				LOG(Camera, Fatal)
> +				LOG(Camera, Error)
>  					<< "Trying to register a camera with a duplicated ID '"
>  					<< camera->id() << "'";
>  				return;
Kieran Bingham Oct. 29, 2026, 5:12 p.m. UTC | #2
Quoting Laurent Pinchart (2026-10-29 16:46:33)
> On Thu, Oct 29, 2026 at 04:06:13PM +0000, Kieran Bingham wrote:
> > There are some hardware configurations which currently generate a
> > duplicate camera ID when the camera is on a shared but multiplexed bus.
> 
> A link to the bug report would be nice. Have you hit the issue with a
> non-thunderbolt setup, or is that the only one known to fail ?

Aha, I originally had the link, but as Closes: and Barnabás didn't want
the issue to close. I should have changed it to Link: instead of
removing it.

I'll add it back in as :

Link: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/303

> With that,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> > At present this is somewhat difficult to adapt to ensure a consistent
> > and unique id.
> > 
> > While this case is undesired, it presently causes libcamera to hit a
> > Fatal asssertion on real world hardware which then causes pipewire to
> > close.
> > 
> > This behaviour is even less desirable, and we can easily continue to
> > operate libcamera without a potentially duplicate camera.
> > 
> > Reduce the Fatal log level to an Error allowing the code to continue
> > without constructing this duplicate camera.
> > 
> > Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > ---
> >  src/libcamera/camera_manager.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> > index 0dd4e0c590a1..9c9073053710 100644
> > --- a/src/libcamera/camera_manager.cpp
> > +++ b/src/libcamera/camera_manager.cpp
> > @@ -210,7 +210,7 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera)
> >  
> >               for (const std::shared_ptr<Camera> &c : cameras_) {
> >                       if (c->id() == camera->id()) {
> > -                             LOG(Camera, Fatal)
> > +                             LOG(Camera, Error)
> >                                       << "Trying to register a camera with a duplicated ID '"
> >                                       << camera->id() << "'";
> >                               return;
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Patch
diff mbox series

diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index 0dd4e0c590a1..9c9073053710 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -210,7 +210,7 @@  void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera)
 
 		for (const std::shared_ptr<Camera> &c : cameras_) {
 			if (c->id() == camera->id()) {
-				LOG(Camera, Fatal)
+				LOG(Camera, Error)
 					<< "Trying to register a camera with a duplicated ID '"
 					<< camera->id() << "'";
 				return;