Mir

[regression] MultiThreadedCompositor fails to schedule sufficient frames and may lag at random times

Bug #1379610 reported by Daniel van Vugt
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mir
Incomplete
High
Daniel van Vugt
mir (Ubuntu)
Incomplete
High
Unassigned
mir (Ubuntu RTM)
Incomplete
High
Unassigned

Bug Description

MultiThreadedCompositor fails to schedule sufficient frames in a mostly-idle single surface scenario:

1. surfaceA emits a frame, one is scheduled
2. surfaceA emits another frame, but still only one is scheduled for compositing
3. We composite only one frame (frames_scheduled == 1)
4. System is idle for some unknown time, with no compositing scheduled but surfaceA has its 2nd frame rendered that we're not seeing.

The problem is:

    void schedule_compositing(int num_frames)
    {
        std::lock_guard<std::mutex> lock{run_mutex};

        if (num_frames > frames_scheduled)
        {
            frames_scheduled = num_frames;
            run_cv.notify_one();
        }
    }

If a surface only emits schedule_compositing(1) but does it multiple times per compositor frame, then the second and subsequent frames won't get scheduled. This can happen for surfaces that are triple (or higher) buffered; i.e. any Mir client right now.

If correct, this would explain bug 1295851 but I will keep them separate while we're not 100% sure.

Tags: regression

Related branches

description: updated
summary: - MultiThreadedCompositor fails to schedule sufficient frames
+ MultiThreadedCompositor fails to schedule sufficient frames and may lag
+ at random times
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I know for a fact that MultiThreadedCompositor has employed a few different algorithms over the past year or so. And most of them are immune to this problem. So this is a relatively recent (past ~6 months) regression. Can't quite find which revision introduced the regression.

summary: - MultiThreadedCompositor fails to schedule sufficient frames and may lag
- at random times
+ [regression] MultiThreadedCompositor fails to schedule sufficient frames
+ and may lag at random times
tags: added: regression
Changed in mir (Ubuntu RTM):
importance: Undecided → High
status: New → Triaged
Changed in mir (Ubuntu):
importance: Undecided → High
status: New → Triaged
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

And there's another apparently separate bug --> LP: #1379685

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> 1. surfaceA emits a frame, one is scheduled
> 2. surfaceA emits another frame, but still only one is scheduled for compositing

Isn't schedule_compositing() called with num_frames=2 the second time (I would expect buffers_ready_for_compositor() to return 2 the second time, if the first frame hasn't been rendered)?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yes indeed. I realised that yesterday.

So this bug might be invalid in the presence of BufferQueue, but the class design safety in isolation should probably still be improved.

Changed in mir:
milestone: 0.9.0 → none
status: In Progress → Incomplete
Changed in mir (Ubuntu):
status: Triaged → Incomplete
Changed in mir (Ubuntu RTM):
status: Triaged → Incomplete
no longer affects: mir/0.7
no longer affects: mir/0.8
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This is being dealt with more accurately as bug 1395581 now.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.