[go: nahoru, domu]

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

RFU: Check for pixelformat availability before accessing to avoid crash #36

Open
rsglobal opened this issue Dec 24, 2021 · 3 comments
Open

Comments

@rsglobal
Copy link
rsglobal commented Dec 24, 2021

RFU - Request for upstream :)

@kbingham ,

Hi Kieran,

Could you please send this patch to ML if relevant for other.

Currently I'm trying to run uvccamera pipeline on Android and got crash at cfg.pixelFormat = pixelFormats.front();

--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
@@ -122,6 +122,9 @@ CameraConfiguration::Status UVCCameraConfiguration::validate()
        const Size size = cfg.size;
 
        const std::vector<PixelFormat> pixelFormats = formats.pixelformats();
+       if (pixelFormats.empty())
+               return Invalid;
+
        auto iter = std::find(pixelFormats.begin(), pixelFormats.end(), pixelFormat);
        if (iter == pixelFormats.end()) {
                cfg.pixelFormat = pixelFormats.front();
@kbingham
Copy link
Owner

Looks same initially, can you provide since more information regarding the crash that occurs and what you tried when it happened please?

@rsglobal
Copy link
Author

I decided to use libcamera for external cameras support for Android instead of external camera HAL built-in into android.

Built-in HAL doesn't support a set of cheap cameras, which was my motivation to use libcamera.

But it turned-out that enabling of uvcpipeline isn't enough and there are a lot of work need to be done to accomplish my goal.

I started to put stubs in a places which caused pipeline initialization to fail expecting to get at least any results and at some point faced this crash. With this patch I can see Camera configuration invalid log which is much better than the crash.

@kbingham
Copy link
Owner

This https://patchwork.libcamera.org/patch/17290/ was merged in September, which I think should also fix / prevent the issue you hit here. If you're able to retest this - let me know if it's still an issue or we can close this off.

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

No branches or pull requests

2 participants