Skip to content

bug: linux-pipewire: camera format labels and framerate list can disagree when the settings have no valid format yet (part 2 of #390) #1068

Closed

Description

@zackees

Reported by EberhartLeberhart on #390 (Surface Pro 5, Intel IPU3 behind libcamera), measured on their hardware. Split out of the resolution-change fix (#933, #934) so it is not lost. Not yet reproduced here.

  1. The format list in plugins/linux-pipewire/camera-portal.c contains the camera's default format twice: once as entry 0 and again at its sorted position (both 640x480 on their camera). The dropdown shows a visible duplicate.
  2. Every format label says 30 FPS, but framerate_list() finds no framerates for the same format and size (has_framerates == 0).

Not part of this issue: the stutter below 800x600 on IPU3. They measured it with cam, outside OBS and PipeWire (the pipeline handler uses the 90 fps binned mode), so it is not an OBS bug.

Refs #390, #933.

Activity

  1. added
    bug
    on Oct 16, 2026
  2. zackees commented on Oct 17, 2026

    @zackees
    MemberAuthor

    Claiming part 1 (duplicate default format).

    Cause, from PipeWire's libcamera plugin (spa_libcamera_enum_format, 1.2.x through master): for each pixel format it emits size index 0 as the size closest to 640x480, then indices 1..N as every size in formats.sizes(), so the default size comes twice as identical EnumFormat params. camera_format_list() adds one list item per param. Fix: skip a param whose format and size an earlier item already has; RED is a fake-camera test node advertising the same YUY2 size twice.

    Part 2 (30 FPS label): the same plugin's EnumFormat carries no SPA_FORMAT_VIDEO_framerate at all, so neither camera_format_list() nor framerate_list() gets a rate from it, and I can't explain the 30 from source. Leaving that part open pending a pw-dump of the camera node from the reporter.

  3. added
    claimed
    on Oct 17, 2026
  4. removed
    claimed
    on Oct 19, 2026
  5. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Triage: part 1 is fixed by #1217 (merged). Part 2 (every label says 30 FPS with no framerates) is underdefined: per the 2026-10-17 analysis PipeWire's libcamera plugin sends no SPA_FORMAT_VIDEO_framerate, and the 30 can't be explained from source. Missing: a pw-dump of the camera node from the reporter (or any libcamera camera), so the label source can be found. Retitle or close part 2 if no dump arrives.

    /investigate

  6. added
    needs-investigation
    on Oct 25, 2026
  7. moved this from Triage to Investigating in obs-rust Multiviewon Oct 25, 2026
  8. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Research on part 2 (coordinator), from plugins/linux-pipewire/camera-portal.c.h on master. Not reproduced, since there's no libcamera device here.

    • The node does send a framerate. The resolution-list label (~l.415) appends ... FPS only when the EnumFormat param has a SPA_FORMAT_VIDEO_framerate prop, and it prints 30 for a SPA_CHOICE_None value of 30/1 (or an Enum whose non-default values are 30). So "PipeWire's libcamera plugin sends no framerate" can't be right for that camera: the 30 comes from the param.
    • camera_framerates() (~l.844) reads the same prop the same way. Same EnumFormat filter, same SPA_FORMAT_VIDEO_size parse, SPA_CHOICE_None handled. Given the same pixel format and size, it would return 30.
    • So the likely cause is the arguments. framerate_list() (~l.1086) is called with camera_source->format.spa_format and camera_source->resolution.rect, the stored selection, not the listed entry. has_framerates == 0 with a 30 FPS label means the stored format or size doesn't match any param at that moment. Candidates: the resolution not yet set when the framerate list is rebuilt (callback order on first open), or the stored video_format differing from the param's raw SPA_FORMAT_VIDEO_format.

    That gives a RED test without hardware: a cmocka case that feeds a param list with one raw format at 640x480 and framerate = SPA_CHOICE_None 30/1, selects it the way the UI does (format, then resolution), and asserts that framerate_list() finds 30. With that test, this is Ready. The reporter's OBS log with the source's properties opened would confirm which argument is off, but it's no longer required.

  9. zackees commented on Oct 27, 2026

    @zackees
    MemberAuthor

    Triage: still not Ready for part 2, and the test sketch I posted on 10-25 would not be a RED test — it would pass on master. Reading the code again:

    • The format label appends ... FPS only inside if (framerate_prop) and handles the choice type the same way the framerate list does (plugins/linux-pipewire/camera-portal.c.h:415-467).
    • camera_framerates() matches on the same SPA_FORMAT_VIDEO_format and SPA_FORMAT_VIDEO_size and appends for SPA_CHOICE_None and SPA_CHOICE_Enum identically (:862-916), and framerate_list() is called with the selection parse_format() has just stored — parse_format writes format and width/height together (:1030-1057, called at :1080), so the two arguments cannot be half-updated.
    • Therefore a param set of one raw format at one size with framerate = 30/1 produces both a 30 FPS label and a one-item framerate list. The fake camera the dedup test already uses is exactly that: SPA_POD_CHOICE_ENUM_Fraction(2, &SPA_FRACTION(30, 1), &SPA_FRACTION(30, 1)) at test/cmocka/test_pipewire_camera_format_dedup.c:219-220. A case that feeds it and asserts the framerate property is non-empty would go green today; I did not run it, this is from the code paths above, but it is the reason the sketch cannot stand as the RED test.

    The two remaining explanations predict different data, which is why two comments have now guessed in opposite directions:

    1. format_selected() returns before building the list because the device is not in camera_connection->devices yet (:1076-1078), leaving the dropdown cleared and disabled (:1086-1088). This would explain an empty list next to labels that the format list built from cached params.
    2. The stored format.spa_format or resolution.rect differs from the listed entry's param at :1087, so nothing matches although the label (built from the param, :415) still shows 30.

    Missing for Ready, one item, from a libcamera camera (the reporter's IPU3, or any other):

    • pw-dump (or pw-cli enum-params <node-id> EnumFormat) of the camera node, showing which params carry SPA_FORMAT_VIDEO_framerate; and
    • the reporter's log with the source properties opened, which contains [camera-portal] Selected format for '<id>' (:1074) and, if a rate was skipped, Ranged/Stepped framerates not supported (:437, :904).

    With that, the failing test is a case in the existing fake-camera binary (the test-binary policy asks for a case in an existing binary, not a new executable) whose node advertises that param set and asserts that the framerate property matches the format labels. Without it there is no reproduction, and part 2 cannot be given acceptance criteria beyond "the label and the dropdown agree", which the code already does for a well-formed param set.

    Part 1 stays fixed by #1217 (merged); retitling this to part 2 only would make it claimable once the dump arrives.

  10. zackees commented on Oct 27, 2026

    @zackees
    MemberAuthor

    Re-checked part 2 against master. Read-only: there is no libcamera camera on this machine, so nothing below is a reproduced observation, only what the code does.

    Part 1 is fixed by #1217 (merged 2026-10-17): camera_format_list() skips a param whose video format and size are already listed (plugins/linux-pipewire/camera-portal.c.h:392-401). Only the 30 FPS label is left.

    What master does, from the source:

    • The label is built from the EnumFormat param. ... FPS is appended only inside if (framerate_prop), after the choice switch (:415-466), so a label reading 30 proves that param carried SPA_FORMAT_VIDEO_framerate with SPA_CHOICE_None 30/1 or an Enum whose non-default entries are 30.
    • The framerate list is built by the same function over the same dev->param_list, matching the raw SPA_FORMAT_VIDEO_format and an exact SPA_FORMAT_VIDEO_size (camera_framerates(), :844-916), and framerate_list() receives the values parse_format() stores together in one call (:1030-1057, call at :1086-1087). The stored spa_format is the table entry's own value (plugins/linux-pipewire/formats.c.h:125-138), so it round-trips unchanged for every format camera_format_list() lists.

    For one well-formed param set the label and the dropdown therefore cannot disagree, which is why a test over a single param set cannot be RED (the fake camera at test/cmocka/test_pipewire_camera_format_dedup.c:213-220 already advertises YUY2 at a size with SPA_POD_CHOICE_ENUM_Fraction(2, 30/1, 30/1); on master that yields both a 30 FPS label and a one-item framerate list). The reported symptom needs the two call sites to see different data. Three candidates, distinguishable:

    1. format_selected() returns at :1080 when parse_format() fails because the settings have no valid format value yet, before :1086 fills the list. obs_property_modified() passes the caller's settings through unchanged (libobs/obs-properties.c.h:802-814), the plugin writes nothing before that point, and pipewire_camera_get_defaults() sets only device_id (:1531-1534), so the labels built in device_selected() (:821) can be on screen while the framerate dropdown was never filled. This is the only candidate that could be pinned by a test in this repo today (call format_selected() with settings that have no format and assert the list is filled), and it only becomes worth writing once the symptom is reproduced.
    2. The stored or saved format and size differ from the listed entry (for example after a device change): the dropdown comes out empty and disabled (:1086-1088).
    3. dev->param_list changed between the device_selected() and format_selected() calls, so the labels come from params that are gone by the time camera_framerates() runs.

    Both remaining explanations predict different data, so the missing evidence is one item, from a libcamera camera (the reporter's IPU3, or any other):

    • pw-dump of the camera node, or pw-cli enum-params <node-id> EnumFormat, showing which params carry SPA_FORMAT_VIDEO_framerate;
    • the reporter's OBS log with the source's properties opened, which contains [camera-portal] Selected format for '<id>' (:1074) and, if a rate was dropped, Ranged framerates not supported / Stepped framerates not supported (:437-440, :904-907).

    Without that there is no reproduction and no acceptance criterion beyond "the label and the dropdown agree", which the code already does for a well-formed param set. Retitling this to part 2 keeps #1217's fix in the history and makes the remainder claimable once the dump arrives.

  11. 9 remaining items

  12. removed
    claim-blocked
    on Oct 30, 2026
  13. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    Investigation (worker): what is left of #1068, with code references

    Part 1 — duplicate default format/size — already fixed. camera_format_list() dedupes on (format, size) through struct listed_format (plugins/linux-pipewire/camera-portal.c.h:330-402, "libcamera lists each pixel format's default size first, then every size"), from #1217. Nothing to do for the duplicate dropdown entry; if a camera still shows one, that is a new report with its EnumFormat params attached.

    Part 2 — labels vs. framerate_list() — root cause is the initial-properties path, not the framerate parsing. Both sides now read the same helper: camera_framerates() (:843-921) feeds framerate_list() (:943-971) and camera_has_framerate(), and the " - <n> FPS" part of a format label (:415-467) is built from the same SPA_FORMAT_VIDEO_framerate choice the helper walks, with the same "i=0 is the default, skip it" rule. What is absent is any population at dialog-open time:

    • pipewire_camera_get_properties() (:1563-1594) creates the format and framerate lists and registers device_selected/format_selected as modified callbacks, then returns. It never calls camera_format_list() or framerate_list().
    • device_selected() (:796-831) is the only caller of camera_format_list(); format_selected() (:1063-1124) is the only caller of framerate_list() and of obs_property_set_enabled(property, has_framerates).

    So for a source whose saved format is missing or does not parse (parse_format() returns false at :1082), the frame-rate list is never filled and never disabled: it shows as an enabled, empty dropdown, and framerate_list()'s has_framerates is never computed. That is the observable half of the report I can prove from the source; the reporter's "every label says 30 FPS" comes from the format-list labels (built per EnumFormat param), which is exactly what an empty framerate list next to a populated format list looks like.

    Acceptance / failing-test sketch (extends test/cmocka/test_pipewire_camera_format_dedup.c, whose fake camera already emits libcamera's default-size-first order and needs no reporter hardware):

    1. Create the camera source with no format in settings, call obs_source_get_properties(), and assert the format list has N entries, framerate list has framerate_list()'s entries for the chosen format and obs_property_enabled(framerate) == has_framerates — RED today: the framerate list is empty and enabled.
    2. Same with a saved format whose size the camera no longer lists: the dialog falls back to the first listed format instead of an empty list, with its frame rates (this is the path the reporter hits after importing an upstream profile).
    3. Keep the format-label text and the framerate list consistent: for each added item, the rates in its label equal the strings framerate_list() adds for that format and size (they share camera_framerates(), so this pins the sharing).

    Status: this is a Linux C plugin fix; Tier 1 Rust and Tier 3 differential do not apply, Tier 2 is the cmocka camera test above, Tier 4 does not apply. Note for the coordinator: PR #3053 had the approved shape but was closed without the RED→GREEN runs the review asked for, and its branch has since been reused for #3047, so the change is not on master or on any live branch. I am not re-claiming implementation in this tick: the fix touches the stream-restart path in format_selected(), so it needs the focused Tier 2 run (D-Bus + PipeWire daemon) to be honest about RED/GREEN rather than a code-only patch.

  14. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    /ready

    Ready per the investigation above: one bounded surface (plugins/linux-pipewire/camera-portal.c.h, the initial-properties path), a failing-test sketch on an existing fake camera that needs no reporter hardware, and an agreed fix shape (fill format then framerate for the source's format at dialog open, falling back to the first listed format). No open design question; the only unknown in the report — the exact EnumFormat layout of the IPU3 camera behind libcamera — is pinned by the label/list consistency case rather than assumed.

  15. added
    ready
    and removed
    needs-investigation
    on Oct 30, 2026
  16. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    Releasing: implementation

    The investigation is delivered above and the issue is Ready; I am not taking the code change in this session because the fix touches the stream-restart path in format_selected() and I will not ship it without the focused Tier 2 cmocka run (D-Bus + private PipeWire daemon, test_pipewire_camera_format_dedup) producing real RED then GREEN output — the reason #3053 was closed. Whoever takes it: start from the acceptance sketch in the investigation comment, add the initial-properties case to test/cmocka/test_pipewire_camera_format_dedup.c, and push the RED commit before the fix.

  17. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    Claiming: implementation of the initial-properties framerate list (part 2 of #1068)

    Starting from the acceptance sketch in the investigation comment:

    1. Add the initial-properties case (settings with no valid format) to test/cmocka/test_pipewire_camera_format_dedup.c against the fake camera, so format_selected()'s early return leaves has_framerates == 0 while the format label shows a framerate: RED on master.
    2. Fill the source's format and framerate from the listed formats at dialog open, falling back to the first listed format, so the dropdown and the label agree: GREEN.
    3. Run the focused Tier 2 cmocka binary and ./lint, then open one non-draft PR with the RED/GREEN evidence.

    I expect the first PR today.

  18. moved this from Blocked to In progress in obs-rust Multiviewon Oct 30, 2026
  19. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    Implementation: #3070 (fix/1068-initial-framerate-list).

    RED on master, in the Tier 2 Linux container against the fake camera portal (no reporter hardware needed): the format list labels 64x48 (1.33:1) - 30 FPS - YUYV422 while framerate items: 0. The case is in the existing test_pipewire_camera_format_dedup.c binary, as the investigation sketched.

    GREEN: format_selected() fills the framerate list for the first format the properties show when the settings hold no valid format, and keeps the source's own format unset so the stream negotiates one as before (no restart, no pinned size). The RED run also turned up the same duplication class as part 1 in the framerate list — the fake camera repeats its default size's EnumFormat, so 30 FPS arrived twice — now deduped in camera_framerates().

    All nine pipewire camera/context cmocka tests pass in both libobs modes. Still unverified: the reporter's Intel IPU3 camera by eye in a running OBS.

  20. zackees commented on Oct 31, 2026

    @zackees
    MemberAuthor

    Closing: #3070 (fix(pipewire): fill the framerate list for the format the properties show) is merged (2026-10-30T14:54Z), and it carries the acceptance sketch from the investigation above — the initial-properties case in test/cmocka/test_pipewire_camera_format_dedup.c (RED: format list labels 64x48 (1.33:1) - 30 FPS - YUYV422 with framerate items: 0) plus the GREEN fix in format_selected().

    Both halves of #390's split are now fixed: part 1 (duplicate default format) by #1217, part 2 (label/framerate list disagreeing when the settings have no valid format yet) by #3070. Nothing is left on this issue; the IPU3 sub-800x600 stutter stays out of scope, as the report says.

  21. moved this from In progress to Done in obs-rust Multiviewon Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions