Skip to content

KWin reconnect: keep fallback on dmabuf import failure and harden producer error transitions - #78

Closed
superturtlee with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-kwin-high-cpu-loop
Closed

KWin reconnect: keep fallback on dmabuf import failure and harden producer error transitions#78
superturtlee with Copilot wants to merge 8 commits into
mainfrom
copilot/fix-kwin-high-cpu-loop

Conversation

Copilot AI commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

KWin could leave fallback and resume rendering after consumer reconnect even when dmabuf import failed, creating a split state (fallback=false + zero imported buffers) that can sustain high CPU. This change makes reconnect/import atomic and ensures transport failures consistently re-enter fallback.

  • Reconnect transaction is now commit-on-success

    • In AnlandBackend::onReconnectTimer(), dmabuf import is attempted before publishing connected state.
    • If import fails, the candidate generation is rejected and fallback/retry remains active; notifier setup, render resume, and repaint are skipped.
  • Producer-side generation rejection API

    • Added reject_consumer_resources(display_ctx*) to display_producer and used it from the backend on import failure.
    • Rejection path reuses producer fallback transition so C producer state and C++ backend state stay aligned for subsequent retries.
  • Transport failure handling tightened

    • trigger_refresh() now handles sendmsg() failure/short-send by entering fallback and returning error.
    • poll_input_event(), poll_input_event_extend_fds(), and poll_input_event_extend_data() now enter fallback on receive failures / invalid framing paths that previously returned errors without guaranteed fallback transition.
if (try_exit_fallback(m_display) != 0) {
    return;
}

AnlandEglLayer *layer = m_outputs[0]->eglLayer();
if (layer && !layer->importBuffers(get_buf_count(m_display))) {
    qCWarning(KWIN_ANLAND) << "failed to import consumer buffer generation";
    reject_consumer_resources(m_display);
    return; // remain in fallback; retry later
}

// commit reconnect only after successful import
m_inFallback = false;
m_reconnectTimer->stop();
setupNotifiers();
m_outputs[0]->resumeRendering();

Co-authored-by: superturtlee <160681686+superturtlee@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix KWin high-CPU loop after Anland consumer resize/reconnect KWin reconnect: keep fallback on dmabuf import failure and harden producer error transitions Sep 7, 2026
Copilot AI requested a review from superturtlee September 7, 2026 16:18
@superturtlee
superturtlee force-pushed the copilot/fix-kwin-high-cpu-loop branch from b69cdd5 to 79eb980 Compare September 8, 2026 09:46
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.

KWin high-CPU loop after Anland consumer resize/reconnect when dmabuf import fails

2 participants