Skip to content

replace libcamera::Span with std::span - #213

Merged
ayufan merged 2 commits into
ayufan:mainfrom
kenohassler:fix-stdspan
Oct 22, 2026
Merged

ayufan merged 2 commits into
ayufan:mainfrom
kenohassler:fix-stdspan

Conversation

@kenohassler

Copy link
Copy Markdown
Contributor

The current version will not compile with a recent raspberry pi OS. This is due to raspberrypi/libcamera@b7694f7 dropping libcamera::Span.
This small fix bumps the C++ standard to c++20, which unlocks std::span, and replaces two occurrences of libcamera::Span on our side with std::span.

Signed-off-by: Patrick Gehrsitz <github@mryel.de>
Signed-off-by: Patrick Gehrsitz <github@mryel.de>
@mryel00

mryel00 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Just updating it like this will break compilation on Bookworm and non updated libcamera version. I think this action run was done with your changes:
https://github.com/mryel00/camera-streamer/actions/runs/38803823237/job/116659405768#step:5:2395

Right now it's just deprecated and as they didn't change the libcamera version yet, it's kinda messy to distinguish between an updated 0.7.2+rpt20261009 and not updated 0.7.2+rpt20260817.

Therefore my recommendation is to add a dedicated #include <libcamera/base/span.h> as I did here:
61bf2da

The above changes should fix the compilation error and keep backwards compatibility with Bookworm and non updated libcamera for now.
With the next version change, this should then be replaced with std::span and according version checks, imho.

P.S.: I forgot to open a PR as I got sick the day I fixed it for our pipeline 🙈

edit: Here the successful run: https://github.com/mryel00/camera-streamer/actions/runs/38812205620
If you want you can just adjust your PR like I did, otherwise I will open a PR myself, as I think backwards compatibility is important, especially if it's basically the same numerical version 🙈

@kbingham

Copy link
Copy Markdown

Right now it's just deprecated and as they didn't change the libcamera version yet, it's kinda messy to distinguish between an updated 0.7.2+rpt20261009 and not updated 0.7.2+rpt20260817.

RPi made a release on top of the master branch which is in effect an unreleased libcamera-0.8.

If it helps, I'm planning to tag 0.8 early next week.

@mryel00

mryel00 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RPi made a release on top of the master branch which is in effect an unreleased libcamera-0.8.

Yeah, not the first time they did this... 🙈

If it helps, I'm planning to tag 0.8 early next week

For this specific case a version bump of libcamera won't help, as they already released their breaking update with 0.7.2.
I think it's good to know that there will be a new release soon on your side, so it might make sense to adjust the code now with 0.8.0 in mind that it hopefully won't break again in a month when it hits the RPi.
Thanks for the headups 😄

@kenohassler

kenohassler commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Alright, thanks for the feedback! Yes, these API-breaking updates are a bit annoying. They're the main reason I have to keep updating camera-streamer 😅
I tried your changes @mryel00 and they work just as well as mine. Should I close this and you PR them in, or should I keep this PR open?
(My thinking is, they will surely remove that deprecated header soon, creating the next API breaking change. But is it acceptable to drop bookworm support with the next release?)

@mryel00

mryel00 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

They're the main reason I have to keep updating camera-streamer 😅

Feel free to use my branch, as I have an automated build pipeline for libcamera updates. Therefore I often find build issues within like 6-12h and try my best to fix them asap. Especially as my software is depending on it working, as the rpi software can be quite a bi*** downgrading libcamera ^^

Should I close this and you PR them in, or should I keep this PR open?

I'm fine with both. You can even just copy my commits and add me as co-author, if you want. Just tell me your decision and I will act accordingly.

But is it acceptable to drop bookworm support with the next release?

It's not my decision tbh ^^
I just provide, and kinda "maintain", this software for the klipper community. I just want to be able to give as much people as possible the latest features of camera-streamer, as it's quite good.

As there are no new features recently, it most likely would be fine drop it.
In that case I would recommend @ayufan to make this compatibility drop clearly visible on this repo and tell us about this decision.

Further supporting it wouldn't be hard either. It would need some version check, as they were already added e.g. here:

#if LIBCAMERA_VERSION_MAJOR > 0 || \
LIBCAMERA_VERSION_MAJOR == 0 && LIBCAMERA_VERSION_MINOR > 3 || \
LIBCAMERA_VERSION_MAJOR == 0 && LIBCAMERA_VERSION_MINOR == 3 && LIBCAMERA_VERSION_PATCH >= 2 // Support for older libcamera versions

I can to this later this week in preparation for libcamera 0.8.0, if you want. (Have to do this anyway if Bookworm support won't get dropped)

If the support would get dropped, such checks should get removed too, as most of them wouldn't be needed anymore. Anyway this would be a job for another PR ^^

@kenohassler

Copy link
Copy Markdown
Contributor Author

I just replaced my commit by yours :)
Let's see what @ayufan says.

@ayufan

ayufan commented Oct 21, 2026

Copy link
Copy Markdown
Owner

@kenohassler Will look tomorrow morning :)

@ayufan

ayufan commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Thanks. This looks great. Lets ship it!

@ayufan
ayufan merged commit aec3311 into ayufan:main Oct 22, 2026
10 checks passed
@mryel00

mryel00 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

@ayufan did you read the rest of this thread too?

Especially this from kenohassler:

My thinking is, they will surely remove that deprecated header soon, creating the next API breaking change. But is it acceptable to drop bookworm support with the next release?

And my opinion on this:

Further supporting it wouldn't be hard either. It would need some version check, as they were already added e.g. here:

#if LIBCAMERA_VERSION_MAJOR > 0 || \
LIBCAMERA_VERSION_MAJOR == 0 && LIBCAMERA_VERSION_MINOR > 3 || \
LIBCAMERA_VERSION_MAJOR == 0 && LIBCAMERA_VERSION_MINOR == 3 && LIBCAMERA_VERSION_PATCH >= 2 // Support for older libcamera versions

edit: Additional information from kbingham for libcamera:

If it helps, I'm planning to tag 0.8 early next week.

@ayufan

ayufan commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

edit: Additional information from kbingham for libcamera:

Lets wait for 0.8.x, as once the 0.8.x lands we will have a proper cutover for the changes. Now, we seem that we can compile on all platforms for time being.

@kenohassler
kenohassler deleted the fix-stdspan branch October 23, 2026 14:45
f1adang pushed a commit to f1adang/camera-streamer that referenced this pull request Oct 28, 2026
…n` now (ayufan#213)

Bump the required `stdc++` to `c++20` as required by `std::span`.

Signed-off-by: Patrick Gehrsitz <github@mryel.de>
Co-authored-by: Patrick Gehrsitz <github@mryel.de>
(cherry picked from commit aec3311)
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.

4 participants