https://bugs.kde.org/show_bug.cgi?id=529062

            Bug ID: 529062
           Summary: Object mask: Clip Monitor ignores clicks after frame
                    export, next mask says "Another mask task is running"
    Classification: Applications
           Product: kdenlive
      Version First 26.08.3
       Reported In:
          Platform: Microsoft Windows
                OS: Microsoft Windows
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Video Effects & Transitions
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

SUMMARY
Sometimes after pressing "+" in the mask manager, the frame export finishes but
the Clip Monitor does not accept point/box input: clicks do nothing and the
"Click on an object or draw a box" hint does not show. The SAM process keeps
running, so every new mask attempt reports "Another mask task is running, try
later." The only way out is Abort Mask, which forces a full frame export again.

STEPS TO REPRODUCE (suspected trigger)
1. Open a project with a clip on the timeline.
2. Make sure the Clip Monitor shows a *different* clip (or nothing), or the
Project Monitor tab is in front.
3. Select the timeline clip, press "Create an object mask" in the effect stack
header, then "+".
4. Wait for "Exporting video frames for analysis" to finish.

OBSERVED RESULT (intermittent)
The Clip Monitor shows the clip but clicks are ignored; the SAM process stays
alive; retrying gives "Another mask task is running, try later."

EXPECTED RESULT
The Clip Monitor shows the clip in mask input mode and accepts clicks.

When the clip is already shown in the Clip Monitor before pressing "+", it
worked every time in my tests.

ANALYSIS (source v26.08.3)
In MaskManager::exportFrames (src/effects/effectstack/view/maskmanager.cpp) the
export callback does, for a timeline clip:
  pCore->window()->slotClipInProjectTree(m_owner, true);   // ->
Bin::selectClipById
  ...
  clipMon->loadQmlScene(SceneType::MonitorSceneAutoMask);
  clipMon->getControllerProxy()->setMaskMode(MaskModeType::MaskInput);
  m_maskHelper->launchSam(...);

Bin::selectClipById calls selectClip(clip) when the Clip Monitor is not already
showing that clip, which opens it through Monitor::slotOpenClip, which calls
loadQmlScene(SceneType::MonitorSceneDefault). Monitor::loadQmlScene switches
scenes asynchronously (root->deleteLater() plus a destroyed handler using
m_nextSceneType). If the clip open, or its producer becoming ready, lands after
the AutoMask request, the Default scene wins while maskMode stays MaskInput and
SAM keeps running. Edit Mask uses the same path (selectClipById with editMode).

Suggested fix: open the clip in the Clip Monitor before starting the export (or
wait for the clip-opened signal before calling
loadQmlScene(MonitorSceneAutoMask)), and/or make slotOpenClip not reset the
scene while a mask task owns the monitor.

POSSIBLY THE SAME ROOT CAUSE
- Bug 504582 "Remove background does not work": mask input mode appears and
disappears right after the export.
- Bug 509910 "AI mask generation plugin crashes if a search filter is active in
project bin": also goes through slotClipInProjectTree -> Bin::selectClipById
after the export.

RELATED
After the "You must define include points in the first video frame of the
sequence." dialog (Generate Mask without a point on the zone's first frame),
mask mode is left but the SAM process stays alive, and the next "+" again says
"Another mask task is running, try later." until Abort Mask.

A related lock problem (effect stack frozen after leaving Preview/Edit Mask
from the panel) is addressed in
https://invent.kde.org/multimedia/kdenlive/-/merge_requests/1151

SOFTWARE/OS VERSIONS
Windows: Windows 10 22H2 (19045)
Kdenlive: 26.08.3 standalone (Qt 6.12)
GPU: NVIDIA GeForce RTX 4060 Ti 8 GB, SAM2.1 hiera base+, offload enabled

ADDITIONAL INFORMATION
Found while debugging with the help of an AI assistant (Claude); the analysis
is from reading the source, the stuck state was observed in 26.08.3.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to