Skip to content

[OFX][TWiR] Clear stale clip input state in the render driver between jobs #14

Open

Description

@Mike-Solar

Difficulty: easy — good first issue (~2–3 hours, CPU-only, no GPU, no third-party plugin)

Background

Oak Video Editor is a professional non-linear video editor; Quercus is its editing
engine. OpenFX (OFX) is the cross-editor plugin standard that editors such as
DaVinci Resolve and Natron support, and thousands of third-party plugins ship
against it. Quercus implements the OFX host side in
crates/quercus-ofx-plugin.

A plugin instance is created once and reused across frames. Before every render,
the driver attaches the input textures the job provides — render_frame step 3,
src/render_driver.rs:255:

for clip in &inst.clips {
    if clip.name == "Output" {
        continue;
    }
    if let Some(tex) = pick_input(&clip.name, job) {
        if usable(&tex) {
            clip.set_input_texture(Some(tex), job.time);
        }
    }
}

The "no input this job" case is silently skipped. For an optional mask that the
user just disconnected, the clip therefore keeps the previous job's texture
and keeps OfxImageClipPropConnected = 1 — see
ClipInstance::set_input_texture,
which only ever runs on the Some path. ClipInstance::fetch_image
(src/clip.rs:251)
reads the stored texture and never consults Connected, so the plugin's
clipGetImage really does hand back last frame's mask.

The GL zero-copy path in the same file already clears its per-job state
(set_input_gl_texture(None) at src/render_driver.rs:640 and :662); the CPU
texture path is the one that was forgotten.

This is the host-side defect tracked by the mask issue
#5; it is
independent of the fixture work in
#3.

What the ask is

Make the per-job input state describe the current job instead of the previous
one: for every non-Output clip, attach the resolved texture when the job
provides one and clear the clip when it does not.

A straightforward shape:

for clip in &inst.clips {
    if clip.name == "Output" {
        continue;
    }
    let input = pick_input(&clip.name, job).filter(usable);
    clip.set_input_texture(input, job.time);
}

Keep pick_input and usable as they are. Step 6 (src/render_driver.rs:315,
region-of-definition and pixel format) already guards on the input being present;
leave that behavior alone unless the fix genuinely requires it.

Tests to add

In src/render_driver/tests.rs, next to render_frame_identity_passthrough
(the file already has make_instance, job, f32_texture and first_pixel
helpers, and the fake test_entry plugin, so no real plugin or GPU is needed):

  1. Build an instance with clips &["Source", "Matte", "Output"]. Render once
    with job.src set and job.inputs = vec![("Matte".into(), mask)];
    assert the Matte clip reports PROP_CLIP_CONNECTED == 1 and
    input_texture_value().is_some().
  2. Render a second time on the same instance with job.inputs empty.
    Assert Matte now reports PROP_CLIP_CONNECTED == 0,
    input_texture_value().is_none(), and
    fetch_image(0.0, RenderScale { x: 1.0, y: 1.0 }, None) returns
    Error::NotFound.
  3. In the same second render, assert the Source clip is still attached, so the
    fix cannot be "clear everything".

Both renders must return Ok — the test entry point accepts them.

Acceptance criteria

  • A render job that omits a previously connected input leaves that clip
    disconnected: OfxImageClipPropConnected = 0 and no stored texture.
  • fetch_image on such a clip returns Error::NotFound instead of stale
    pixels.
  • Clips the job does provide behave exactly as before; the existing
    render_driver and node_e2e tests pass unchanged.
  • cargo test -p quercus-ofx-plugin passes, cargo fmt --all is applied, and
    the change stays inside crates/quercus-ofx-plugin.

Out of scope

How to run

From the workspace root:

tooling/install-deps.sh
tooling/ffmpeg/build-ffmpeg.sh --shared
cargo test -p quercus-ofx-plugin

build.rs compiles the C fixture and the C shims automatically; the first build
takes a few minutes. Filter the new test with
cargo test -p quercus-ofx-plugin render_driver.

Mentoring

A maintainer can pair on the test scaffolding and review the change;
comment here to claim the issue and you will be assigned.

Contributing

Quercus follows Oak's CONTRIBUTING.md
and Code Style Guide.
In short: format with cargo fmt --all, keep the change focused (no new
dependencies, no unrelated refactors), propagate errors instead of silently
falling back, and run the tests for the files you change.

Contributions are accepted under the
Contributor License Agreement
(inbound = outbound, GPL-3.0-or-later; no copyright transfer).

Activity

  1. added
    bug
    enhancement
    good first issue
    on Nov 21, 2026
  2. Mike-Solar commented on Nov 21, 2026

    @Mike-Solar
    ContributorAuthor

    Reproduction (confirmed on main @ 0f7205e, after the mask fixture from #3/PR #12 landed)

    No third-party plugin or GPU needed — the in-tree fixture org.quercus.test-plugin.mask
    reproduces this in two render_frame calls on one instance:

    1. Create the instance and two solid 2×2 F32/RGBA textures:
      src = [0.8, 0.6, 0.4, 1.0], mask = [0.5, 0.5, 0.5, 1.0].
    2. Render 1 — RenderJob { src: Some(src), effect_input_id: Some("Source"), inputs: vec![("Mask", mask)], .. }.
      The fixture computes Source RGB × mask.red, output is [0.4, 0.3, 0.2, 1.0] (correct).
    3. Render 2 — same instance, same src, inputs: Vec::new() (the mask input disappeared,
      as when the user disconnects it). Expected pass-through [0.8, 0.6, 0.4, 1.0].

    Actual on main:

    render 1 (mask connected) => [0.4, 0.3, 0.2, 1.0]
    render 2 (mask removed)   => [0.4, 0.3, 0.2, 1.0]   <-- stale mask still applied
    Mask clip after render 2  => OfxImageClipPropConnected = 1, input_texture_value() = Some(..)
    

    So the plugin still sees the previous frame's mask as a live, connected input
    (clipGetImage returns it, because ClipInstance::fetch_image never consults
    Connected).

    A regression test can be exactly this pair of renders: assert the second output is
    [0.8, 0.6, 0.4, 1.0] and that the Mask clip reports
    OfxImageClipPropConnected = 0 with input_texture_value().is_none(). That covers
    the "clear" half of the acceptance criteria without any C fixture changes; the
    dimension/format and masked-pixel assertions stay in the follow-up issue #15.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions