Skip to content

Complete a requested restore after its provider retires - #30

Merged
archledger merged 1 commit into
plasma-fusionfrom
fix/restore-outlives-provider
Nov 14, 2026
Merged

archledger merged 1 commit into
plasma-fusionfrom
fix/restore-outlives-provider

Conversation

@archledger

Copy link
Copy Markdown
Owner

What

An explicit restore whose provider retires before the client answers it is now placed and completed. Until now it never was: the window took its floating size at the tile's position, and its record stayed Restoring until the window closed. Found by plasma-fusion's NT08 session check (archledger/plasma-fusion#174, cause in its comment).

How it happened

The placement script's teardown (when it is disabled, reloaded or unloaded during a tiling session) asks for the master's restore (restoreWindow = UntileOrRestoreOp) and releases the tree. Then KWin destroys the script, and with it the writer's provider: the writer clears the token on QObject::destroyed at once, and providerRetired follows queued.

  • transientRestoreAttemptIsCurrent required transientProviderIsCurrent, so when the client's answer arrived the restoration was no longer current.
  • configurePlacementPolicy gave ContentOnly: the floating size without the position.
  • completeTransientRestoration refused: the record stayed Restoring. A new provider's admission answered busy (3), and settleWindow wants the admitting provider, so nothing ended it but closing the window.

The change

  • requestTransientRestore marks the attempt requestReturned at its success exit, after its own last check.
  • transientRestoreAttemptIsCurrent: a provider that is not current now refuses only an attempt without that mark.

Why this is safe:

  • The provider decides whether a restore starts. Once its request has returned, the target is the record's own floating frame A, the configure is the client's to answer, and the writer keeps the restoring reservation through the retirement (providerRetirementKeepsReservation); its completeRestore asks nothing of the provider.
  • A retirement while the request is being made, its last check included, still supersedes it.
  • Writer loss, a newer manual action, close, context changes and the attempt's own state check stop it as before. NT03's stop list ("Writer loss, identity loss, close and unsupported context changes") never included the provider.
  • A replacement provider still cannot adopt the window in flight: admission is busy, and settle answers NotReleased.
  • The writer null check moves in front: the provider check no longer covers it.

Tests

  • testRestoreCompletion: the provider retires after the request returned:

    • with the controller gone (row 8, as in the script's teardown);
    • with a replacement provider registered (row 9);
    • for the configure-less shape whose next plain commit completes it (row 10).

    Each completes: A placed, the record and the reservation cleared. While in flight, a settle answers NotReleased (not StaleProvider) and the floating frame is A.

  • testTransientConfigurePlacement row 10 (provider-retired-before-commit) changes its expectation. It expected the old rule (the configure unplaced at the tile's position, the record kept), which is #174's symptom. It now expects A placed and the record completed, as rows 5, 6, 7 and 11 (row 11 deletes the tree before the commit). The row came with the configure-provenance work of 2026-11-05, before the completion boundary and the settle operation existed.

  • New rows after a retirement, where the configure stays unplaced and the record kept:

    • a manual resize (row 27);
    • a manual move (row 28);
    • a minimum size that no longer admits A, with no request at all (row 29). Only the attempt's own state check sees this, so it pins that the exception does not skip the rest of the rule.
  • testTransientTilingFacadeRestoreAfterProviderRetired: #174 end to end through Workspace.transientTiling(), as the script's teardown runs it (restoreWindow, releaseTile, the provider destroyed, a new one registered).

    • Before the client answers, the new provider's settle answers NotReleased and its admission is busy.
    • After, the window is on A, the record is gone, and the new provider tiles it again.

Rows 8, 9 and 10 of testRestoreCompletion, row 10 of testTransientConfigurePlacement and the facade test fail without the change.

Unchanged and passing:

  • the retirements during the request: testTransientRestoreRequest provider-first-callback and provider-final-callback; testTransientRestoreClaim provider-retired-during-release and provider-retired-after-claim; testMaximizeRestoreNormalization provider-lost-callback;
  • testNoRequestFinalizationValidity provider-retired;
  • testTransientOwnershipPreparation retired-provider;
  • testTransientReceiptLifetime stale-after-provider-retired and provider-retired-before-apply;
  • testTransientOwnershipBeforeRequest provider-retired-before-call;
  • testTransientOwnershipNativeProgress provider-before-request and provider-after-request.

Evidence

  • Failing first. With the final tests, the old rule fails five rows: the facade test, rows 8, 9 and 10 of testRestoreCompletion, and row 10 of testTransientConfigurePlacement. In each, the record is not cleared or the configure is not placed.

  • This branch:

    • the whole testXdgShellWindow binary passes, 916 of 916;
    • the CI's suite campaign (27 suites, the writer and the surface test included) passes;
    • git clang-format on the changed lines: clean.
  • Mutations, each against the whole binary:

    Variant Result
    the old rule (the field kept) 5 rows fail
    no provider check for restores at all 5 rows fail (the retirements during the claim, the request and the maximize normalization)
    the mark never set 8 rows fail
    no writer null check crash at writer-lost-during-release
    once marked, the rest of the rule skipped row 29 fails (its settle answer)
    the mark set in the scope guard, before the post-request check equivalent: nothing can call back in between
    the exception granted during the dispatch too equivalent: the post-request check still applies the strict rule, before the mark
  • In a Fedora 44 VM, with trial RPMs of the 6.8.2 line carrying the first version of this change (release pf3.174.1) and plasma-fusion#173's script. That version used a stage test instead of the mark, and passed 27 of 27 suites on that line. The master's frame and its native record were read every 0.3 s:

    Case v6.8.2-pf3 trial
    the Tile Workspace shortcut's untoggle on its float within 0.32 s, record settled the same
    the script disabled (kwinrc + reconfigure) float size at the tile's corner, record held on its float, record cleared
    the script unloaded over D-Bus the same as above on its float, record cleared
    a reconfigure with the script kept session survives the same

    In plasma-fusion's NT08 session pass, the re-toggle after the script went and came back is accepted (refused on v6.8.2-pf3). An orderly restart and a kill -9 mid-session keep the placement file, leave no tree and dump no core.

  • Between that trial and this branch: the mark changes nothing in a reachable state. It closes the gap between the request's last strict check and its post-check, where nothing can call back today. The tagged build gets the same VM checks.

Not in this change

Other ways a record can be left Restoring after its provider retires still end only when the window closes (archledger/plasma-fusion#175): a restore that never starts before the tree's release, a restore superseded after the retirement, and a provider retired while the window is still owned. Ending those needs an adoption or expiry rule of its own.

An explicit restore whose provider retired before the client answered
it was never placed or completed. The placement script's teardown asks
for the master's restore and releases the tree; then KWin destroys the
script, and with it the writer's provider. When the client's answer
arrived the restoration was no longer current: configurePlacementPolicy
gave ContentOnly, so the window took its floating size at the tile's
position, and completeTransientRestoration refused, so the record
stayed Restoring until the window closed. A new provider could neither
settle it nor admit the window again (plasma-fusion#174).

The provider decides whether a restore starts. Once its request has
returned, the target is the record's own floating frame, the configure
is the client's to answer, and the writer keeps the restoring
reservation through the retirement. requestTransientRestore now marks
the attempt (requestReturned) at its success exit, after its own last
check, and a provider that is not current refuses only an attempt
without that mark. A retirement while the request is being made, its
last check included, still supersedes it; writer loss, a newer manual
action, close, context changes and the attempt's own state check stop
it as before. The writer null check moves in front: the provider check
no longer covers it.

Tests:
- testRestoreCompletion: the provider retires after the request
  returned, with the controller gone (row 8), with a replacement
  provider registered (row 9), and for the configure-less shape whose
  next plain commit completes it (row 10). Each completes: A placed,
  the record and the reservation cleared. While in flight a settle
  answers NotReleased, not StaleProvider, and the floating frame is A.
- testTransientConfigurePlacement: row 10
  (provider-retired-before-commit) expected the old rule, the configure
  unplaced and the record kept; it now expects A placed and the record
  completed, as rows 5, 6, 7 and 11. After a retirement, a manual
  resize (row 27) or move (row 28), or a minimum size that no longer
  admits A with no request at all (row 29), still leaves the configure
  unplaced and the record kept.
- testTransientTilingFacadeRestoreAfterProviderRetired: #174 through
  the scripting facade, as the script's teardown runs it
  (restoreWindow, releaseTile, the provider destroyed, a new one
  registered): before the client answers, the new provider's admission
  is busy; after, the window is on A, the record is gone, and the new
  provider tiles it again.
Rows 8, 9 and 10 of testRestoreCompletion, row 10 of
testTransientConfigurePlacement and the facade test fail without the
change. The rows that retire the provider during the request
(provider-first-callback, provider-final-callback) and the other
provider-retirement rows pass unchanged.

Mutations, each run against the whole testXdgShellWindow binary: the
old rule, no provider check for restores at all, the mark never set
and no writer null check each fail rows or crash. A check that, once
marked, skips the rest of the rule fails row 29 (its settle answer).
Two are equivalent: the mark set in the scope guard before the
post-request check (nothing can call back in between), and the
exception also granted during the dispatch (the post-request check
still applies the strict rule, before the mark).

Signed-off-by: Wisbendji Fimerlus <archledger236@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 14, 2026 07:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T07:47:21.740175Z 001b5a8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@archledger
archledger merged commit 786470f into plasma-fusion Nov 14, 2026
2 checks passed
@archledger
archledger deleted the fix/restore-outlives-provider branch November 14, 2026 10:36
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.

2 participants